Salome HOME
Merge branch 'ASL_TREE_STATE' into asl/hydro_porting_741
authorasl <alexander.solovyov@opencascade.com>
Tue, 9 Sep 2014 07:28:56 +0000 (11:28 +0400)
committerasl <alexander.solovyov@opencascade.com>
Tue, 9 Sep 2014 07:28:56 +0000 (11:28 +0400)
122 files changed:
CMakeLists.txt
SalomeGUIConfig.cmake.in
adm_local/cmake_files/FindQwt.cmake
adm_local/cmake_files/UsePyQt4.cmake
doc/salome/gui/images/plot2d_view_settings.png
doc/salome/gui/images/pref_salome_general.png
doc/salome/gui/images/pref_salome_plot2dviewer.png
doc/salome/gui/input/occ_3d_viewer.doc
doc/salome/gui/input/plot2d_viewer.doc
doc/salome/gui/input/setting_preferences.doc
doc/salome/gui/input/vtk_3d_viewer.doc
src/CAF/resources/CAF_msg_ja.ts
src/CAM/resources/CAM_msg_ja.ts
src/GLViewer/resources/GLViewer_msg_ja.ts
src/GraphicsView/resources/GraphicsView_msg_fr.ts
src/GraphicsView/resources/GraphicsView_msg_ja.ts [new file with mode: 0644]
src/LightApp/LightApp_Application.cxx
src/LightApp/LightApp_Application.h
src/LightApp/LightApp_Displayer.h
src/LightApp/LightApp_Module.cxx
src/LightApp/LightApp_Module.h
src/LightApp/LightApp_PreferencesDlg.cxx
src/LightApp/LightApp_PyInterp.cxx
src/LightApp/LightApp_PyInterp.h
src/LightApp/resources/LightApp.xml
src/LightApp/resources/LightApp_msg_en.ts
src/LightApp/resources/LightApp_msg_fr.ts
src/LightApp/resources/LightApp_msg_ja.ts
src/LogWindow/resources/LogWindow_msg_ja.ts
src/OCCViewer/OCCViewer_ClippingDlg.cxx
src/OCCViewer/OCCViewer_ViewFrame.cxx
src/OCCViewer/OCCViewer_ViewFrame.h
src/OCCViewer/OCCViewer_ViewModel.cxx
src/OCCViewer/OCCViewer_ViewModel.h
src/OCCViewer/OCCViewer_ViewPort3d.cxx
src/OCCViewer/OCCViewer_ViewPort3d.h
src/OCCViewer/OCCViewer_ViewWindow.cxx
src/OCCViewer/OCCViewer_ViewWindow.h
src/OCCViewer/resources/OCCViewer_msg_en.ts
src/OCCViewer/resources/OCCViewer_msg_ja.ts
src/ObjBrowser/resources/OB_msg_ja.ts
src/Plot2d/Plot2d.cxx
src/Plot2d/Plot2d.h
src/Plot2d/Plot2d_AnalyticalCurve.cxx
src/Plot2d/Plot2d_Curve.cxx
src/Plot2d/Plot2d_Histogram.cxx
src/Plot2d/Plot2d_Histogram.h
src/Plot2d/Plot2d_Object.cxx
src/Plot2d/Plot2d_Object.h
src/Plot2d/Plot2d_PlotItems.cxx
src/Plot2d/Plot2d_PlotItems.h
src/Plot2d/Plot2d_SetupViewDlg.cxx
src/Plot2d/Plot2d_SetupViewDlg.h
src/Plot2d/Plot2d_ViewFrame.cxx
src/Plot2d/Plot2d_ViewFrame.h
src/Plot2d/Plot2d_ViewManager.cxx
src/Plot2d/Plot2d_ViewModel.cxx
src/Plot2d/Plot2d_ViewModel.h
src/Plot2d/Plot2d_ViewWindow.cxx
src/Plot2d/resources/Plot2d_msg_en.ts
src/Plot2d/resources/Plot2d_msg_fr.ts
src/Plot2d/resources/Plot2d_msg_ja.ts
src/PyConsole/PyConsole_Editor.cxx
src/PyConsole/PyConsole_EnhInterp.cxx
src/PyConsole/PyConsole_Interp.cxx
src/PyConsole/PyConsole_Interp.h
src/PyConsole/resources/PyConsole_msg_ja.ts
src/PyInterp/PyInterp_Dispatcher.cxx
src/PyInterp/PyInterp_Interp.cxx
src/PyInterp/PyInterp_Interp.h
src/PyInterp/PyInterp_Request.h
src/QDS/resources/QDS_msg_ja.ts
src/Qtx/QtxResourceMgr.cxx
src/QxScene/resources/QxSceneViewer_msg_ja.ts
src/SALOME_PY/SalomePy.cxx
src/SALOME_PYQT/SALOME_PYQT_GUI/SALOME_PYQT_Module.cxx
src/SALOME_PYQT/SALOME_PYQT_GUILight/SALOME_PYQT_ModuleLight.cxx
src/SALOME_PYQT/SALOME_PYQT_GUILight/SALOME_PYQT_ModuleLight.h
src/SALOME_PYQT/SALOME_PYQT_GUILight/SALOME_PYQT_PyInterp.cxx
src/SALOME_PYQT/SALOME_PYQT_GUILight/SALOME_PYQT_PyInterp.h
src/SALOME_PYQT/SALOME_PYQT_GUILight/SALOME_PYQT_PyModule.cxx
src/SALOME_PYQT/SALOME_PYQT_GUILight/SALOME_PYQT_PyModule.h
src/SALOME_PYQT/SalomePyQt/CMakeLists.txt
src/SALOME_PYQT/SalomePyQt/SalomePyQt.h
src/SALOME_PYQT/SalomePyQt/SalomePyQt.sip
src/SALOME_SWIG/CMakeLists.txt
src/SALOME_SWIG/SALOMEGUI_shared_modules.py [deleted file]
src/SPlot2d/SPlot2d_ViewModel.cxx
src/SPlot2d/SPlot2d_ViewModel.h
src/STD/STD_Application.cxx
src/STD/STD_Application.h
src/STD/resources/STD_msg_ja.ts
src/SUIT/SUIT_TreeModel.cxx
src/SUIT/resources/SUIT_msg_ja.ts
src/SUITApp/SUITApp.cxx
src/SUITApp/SUITApp_init_python.cxx
src/SUITApp/SUITApp_init_python.hxx
src/SUITApp/resources/SUITApp_msg_ja.ts
src/SVTK/SVTK_Renderer.cxx
src/SVTK/SVTK_Renderer.h
src/SVTK/SVTK_ViewWindow.cxx
src/SVTK/SVTK_ViewWindow.h
src/SVTK/resources/SVTK_msg_en.ts
src/SVTK/resources/SVTK_msg_ja.ts
src/SalomeApp/SalomeApp_Application.cxx
src/SalomeApp/SalomeApp_Application.h
src/SalomeApp/SalomeApp_DoubleSpinBox.cxx
src/SalomeApp/SalomeApp_ExceptionHandler.cxx
src/SalomeApp/SalomeApp_IntSpinBox.cxx
src/SalomeApp/SalomeApp_Module.cxx
src/SalomeApp/SalomeApp_Module.h
src/SalomeApp/SalomeApp_NoteBook.cxx
src/SalomeApp/SalomeApp_PyInterp.cxx
src/SalomeApp/SalomeApp_PyInterp.h
src/SalomeApp/SalomeApp_Study.cxx
src/SalomeApp/resources/SalomeApp_msg_en.ts
src/SalomeApp/resources/SalomeApp_msg_fr.ts
src/SalomeApp/resources/SalomeApp_msg_ja.ts
src/Session/SALOME_Session_Server.cxx
src/TOOLSGUI/resources/ToolsGUI_msg_ja.ts
src/VTKViewer/resources/VTKViewer_msg_ja.ts
src/ViewerTools/resources/ViewerTools_msg_ja.ts

index b82a29a2454b58f1f7e7860d1ea95f6369cd0ad3..d95bc62a10aff2c5b14c24b35f2103ec2ac16c10 100755 (executable)
@@ -30,11 +30,11 @@ CMAKE_POLICY(SET CMP0003 NEW)
 STRING(TOUPPER ${PROJECT_NAME} PROJECT_NAME_UC)
 
 SET(${PROJECT_NAME_UC}_MAJOR_VERSION 7)
-SET(${PROJECT_NAME_UC}_MINOR_VERSION 3)
-SET(${PROJECT_NAME_UC}_PATCH_VERSION 0)
+SET(${PROJECT_NAME_UC}_MINOR_VERSION 4)
+SET(${PROJECT_NAME_UC}_PATCH_VERSION 1)
 SET(${PROJECT_NAME_UC}_VERSION
   ${${PROJECT_NAME_UC}_MAJOR_VERSION}.${${PROJECT_NAME_UC}_MINOR_VERSION}.${${PROJECT_NAME_UC}_PATCH_VERSION})
-SET(${PROJECT_NAME_UC}_VERSION_DEV 1)
+SET(${PROJECT_NAME_UC}_VERSION_DEV 0)
 
 # Find KERNEL
 # ===========
@@ -75,10 +75,12 @@ OPTION(SALOME_USE_PYCONSOLE "Enable Python GUI interface (Mandatory in classic c
 OPTION(SALOME_USE_QXGRAPHVIEWER "Enable QX graph visualization (Mandatory in classic configurations)" ON)
 CMAKE_DEPENDENT_OPTION(SALOME_USE_SALOMEOBJECT "Enable Salome Object (Mandatory in classic configurations)" ON
                        "SALOME_LIGHT_ONLY" ON)
+OPTION(SALOME_USE_SINGLE_DESKTOP "Enable multiple document interface" ON)
 
 MARK_AS_ADVANCED(SALOME_LIGHT_ONLY SALOME_USE_VTKVIEWER SALOME_USE_GRAPHICSVIEW)
 MARK_AS_ADVANCED(SALOME_USE_SALOMEOBJECT SALOME_USE_OCCVIEWER SALOME_USE_GLVIEWER SALOME_USE_PLOT2DVIEWER)
 MARK_AS_ADVANCED(SALOME_USE_PYCONSOLE SALOME_USE_QXGRAPHVIEWER)
+MARK_AS_ADVANCED(SALOME_USE_SINGLE_DESKTOP)
 
 # Prerequisites
 # =============
@@ -129,6 +131,10 @@ IF(SALOME_GUI_USE_OBSERVERS)
   ADD_DEFINITIONS(-DWITH_SALOMEDS_OBSERVER)
 ENDIF()
 
+IF(SALOME_USE_SINGLE_DESKTOP)
+  ADD_DEFINITIONS(-DSINGLE_DESKTOP)
+ENDIF()
+
 # OCCT
 FIND_PACKAGE(SalomeCAS REQUIRED)
 IF(NOT SALOME_USE_OCCVIEWER)
@@ -150,7 +156,7 @@ ELSE()
 ENDIF()
 IF(SALOME_USE_VTKVIEWER)
   # Required components are listed in the FindSalomeVTK.cmake file: 
-  FIND_PACKAGE(SalomeVTK 6.0
+  FIND_PACKAGE(SalomeVTK 6.1
   SALOME_LOG_OPTIONAL_PACKAGE(VTK SALOME_USE_VTKVIEWER)
 ELSE()
   ADD_DEFINITIONS("-DDISABLE_VTKVIEWER")
index b658ac406a04c42f3144c1290a8e78a1bf79b170..a2807ff0d041c5e96ec0f410df86d01da5a5ac38 100644 (file)
@@ -52,15 +52,51 @@ SET(SALOME_GUI_BUILD_TESTS  @SALOME_BUILD_TESTS@)
 SET(SALOME_GUI_LIGHT_ONLY   @SALOME_LIGHT_ONLY@)
 
 # Advanced options
-SET(SALOME_USE_OCCVIEWER     @SALOME_USE_OCCVIEWER@)
-SET(SALOME_USE_GLVIEWER      @SALOME_USE_GLVIEWER@)
-SET(SALOME_USE_VTKVIEWER     @SALOME_USE_VTKVIEWER@)
-SET(SALOME_USE_PLOT2DVIEWER  @SALOME_USE_PLOT2DVIEWER@)
-SET(SALOME_USE_GRAPHICSVIEW  @SALOME_USE_GRAPHICSVIEW@)
-SET(SALOME_USE_QXGRAPHVIEWER @SALOME_USE_QXGRAPHVIEWER@)
-
-SET(SALOME_USE_PYCONSOLE     @SALOME_USE_PYCONSOLE@)
-SET(SALOME_USE_SALOMEOBJECT  @SALOME_USE_SALOMEOBJECT@)
+SET(SALOME_USE_OCCVIEWER      @SALOME_USE_OCCVIEWER@)
+SET(SALOME_USE_GLVIEWER       @SALOME_USE_GLVIEWER@)
+SET(SALOME_USE_VTKVIEWER      @SALOME_USE_VTKVIEWER@)
+SET(SALOME_USE_PLOT2DVIEWER   @SALOME_USE_PLOT2DVIEWER@)
+SET(SALOME_USE_GRAPHICSVIEW   @SALOME_USE_GRAPHICSVIEW@)
+SET(SALOME_USE_QXGRAPHVIEWER  @SALOME_USE_QXGRAPHVIEWER@)
+SET(SALOME_USE_PYCONSOLE      @SALOME_USE_PYCONSOLE@)
+SET(SALOME_USE_SALOMEOBJECT   @SALOME_USE_SALOMEOBJECT@)
+SET(SALOME_USE_SINGLE_DESKTOP @SALOME_USE_SINGLE_DESKTOP@)
+SET(SALOME_GUI_USE_OBSERVERS  @SALOME_GUI_USE_OBSERVERS@)
+
+IF(SALOME_GUI_LIGHT_ONLY)
+  LIST(APPEND GUI_DEFINITIONS "-DGUI_DISABLE_CORBA")
+ENDIF() 
+IF(SALOME_USE_SINGLE_DESKTOP)
+  LIST(APPEND GUI_DEFINITIONS "-DSINGLE_DESKTOP")
+ENDIF()
+IF(SALOME_GUI_USE_OBSERVERS)
+  LIST(APPEND GUI_DEFINITIONS "-DWITH_SALOMEDS_OBSERVER")
+ENDIF()
+IF(NOT SALOME_USE_OCCVIEWER)
+  LIST(APPEND GUI_DEFINITIONS "-DDISABLE_OCCVIEWER")
+ENDIF()
+IF(NOT SALOME_USE_GLVIEWER)
+  LIST(APPEND GUI_DEFINITIONS "-DDISABLE_GLVIEWER")
+ENDIF()
+
+IF(NOT SALOME_USE_VTKVIEWER)
+  LIST(APPEND GUI_DEFINITIONS "-DDISABLE_VTKVIEWER")
+ENDIF()
+IF(NOT SALOME_USE_PLOT2DVIEWER)
+  LIST(APPEND GUI_DEFINITIONS "-DDISABLE_PLOT2DVIEWER")
+ENDIF()
+IF (NOT SALOME_USE_GRAPHICSVIEW)
+  LIST(APPEND GUI_DEFINITIONS "-DDISABLE_GRAPHICSVIEW")
+ENDIF()
+IF(NOT SALOME_USE_PYCONSOLE)
+  LIST(APPEND GUI_DEFINITIONS "-DDISABLE_PYCONSOLE")
+ENDIF()
+IF(NOT SALOME_USE_QXGRAPHVIEWER)
+  LIST(APPEND GUI_DEFINITIONS "-DDISABLE_QXGRAPHVIEWER")
+ENDIF()
+IF(NOT SALOME_USE_SALOMEOBJECT)
+  LIST(APPEND GUI_DEFINITIONS "-DDISABLE_SALOMEOBJECT")
+ENDIF()
 
 # Level 1 prerequisites:
 SET_AND_CHECK(KERNEL_ROOT_DIR_EXP "@PACKAGE_KERNEL_ROOT_DIR@")
index fb4f66adc543c4c07524316fa22e764676388189..13ba70ef9e180be7af1d74c956088573930d44cb 100644 (file)
@@ -39,12 +39,20 @@ IF(WIN32)
   SET(QWT_DEFINITIONS "-DQWT_DLL")
   
   IF(CMAKE_BUILD_TYPE STREQUAL Debug)
-    FIND_LIBRARY(QWT_LIBRARY qwtd5)
-  ELSE()
-    FIND_LIBRARY(QWT_LIBRARY qwt5)
+    FIND_LIBRARY(QWT_LIBRARY qwtd)
   ENDIF()
+  FIND_LIBRARY(QWT_LIBRARY qwt)
 ELSE(WIN32)
-  # Give precedence to qwt-qt4 library:
+  # Give precedence to qwt-qt4 library.
+  # Note: on some platforms there can be several native qwt libraries linked against different 
+  #       versions of Qt; for example /usr/lib/libqwt.so for qwt linked against Qt 3 and
+  #       /usr/lib/libqwt-qt4.so for qwt linked against Qt 4.
+  #       We need only qt4-based qwt library, so we search libqwt-qt4, then libqwt library
+  #       first ignoring system paths, then including system paths.
+  FIND_LIBRARY(QWT_LIBRARY qwt-qt4 PATH_SUFFIXES lib lib64 PATHS "${QWT_ROOT_DIR}" NO_DEFAULT_PATH)
+  FIND_LIBRARY(QWT_LIBRARY qwt-qt4 PATHS "${QWT_ROOT_DIR}" NO_DEFAULT_PATH)
+  FIND_LIBRARY(QWT_LIBRARY qwt PATH_SUFFIXES lib lib64 PATHS "${QWT_ROOT_DIR}" NO_DEFAULT_PATH)
+  FIND_LIBRARY(QWT_LIBRARY qwt PATHS "${QWT_ROOT_DIR}" NO_DEFAULT_PATH)
   FIND_LIBRARY(QWT_LIBRARY qwt-qt4 PATH_SUFFIXES lib lib64)
   FIND_LIBRARY(QWT_LIBRARY qwt-qt4)
   FIND_LIBRARY(QWT_LIBRARY qwt PATH_SUFFIXES lib lib64)
index a6048af450bc1aa92c8903ee6050f569c52a987c..11d2d115020c543ca77ceb89f0ced901193f05f0 100644 (file)
@@ -63,6 +63,9 @@ ENDFUNCTION()
 # 
 ####################################################################
 MACRO(PYQT4_WRAP_UIC outfiles)
+
+ IF(NOT WIN32)
+
   FOREACH(_input ${ARGN})
     GET_FILENAME_COMPONENT(_input_name ${_input} NAME)
     STRING(REPLACE ".ui" "_ui.py" _input_name ${_input_name})
@@ -76,6 +79,33 @@ MACRO(PYQT4_WRAP_UIC outfiles)
   ENDFOREACH()
   _PYQT4_WRAP_GET_UNIQUE_TARGET_NAME(BUILD_UI_PY_FILES _uniqueTargetName)
   ADD_CUSTOM_TARGET(${_uniqueTargetName} ALL DEPENDS ${${outfiles}})
+
+ ELSEIF(NOT WIN32)
+####
+# ANA: Workaround for the Microsoft Visual Studio 2010. Seems there is a bug in 
+# the Microsoft Visual Studio 2010 or CMake 2.8.10.2: custom target doesn't work 
+# for the list of the dependencies. It works only for the first dependency in the 
+# list. So generate separate target for the each input file. This problem will be 
+#investigated in the future.
+####
+
+  SET_PROPERTY(GLOBAL PROPERTY USE_FOLDERS ON)
+  _PYQT4_WRAP_GET_UNIQUE_TARGET_NAME(BUILD_UI_PY_FILES _uniqueTargetName)
+  ADD_CUSTOM_TARGET(${_uniqueTargetName} ALL)
+  FOREACH(_input ${ARGN})
+    GET_FILENAME_COMPONENT(_input_name ${_input} NAME)
+    STRING(REPLACE ".ui" "_ui.py" _input_name ${_input_name})
+    SET(_output ${CMAKE_CURRENT_BINARY_DIR}/${_input_name})
+    _PYQT4_WRAP_GET_UNIQUE_TARGET_NAME(BUILD_UI_PY_FILES _TgName)
+    ADD_CUSTOM_TARGET(${_TgName} ${PYQT_PYUIC_PATH} -o ${_output} ${CMAKE_CURRENT_SOURCE_DIR}/${_input}
+      COMMENT ANA:${_output}
+      DEPENDS ${_input}
+      )
+    SET_TARGET_PROPERTIES(${_TgName} PROPERTIES FOLDER PYQT4_WRAP_UIC_TARGETS)
+    ADD_DEPENDENCIES(${_uniqueTargetName} DEPEND ${_TgName})
+    SET(${outfiles} ${${outfiles}} ${_output})
+  ENDFOREACH()
+ ENDIF(NOT WIN32)
 ENDMACRO(PYQT4_WRAP_UIC)
 
 ####################################################################
index 2b7ddffc78a3576d36460bd6833f0b2f08ebe41d..e87556beb23f2158c243e0c1230ac32740d9ce12 100644 (file)
Binary files a/doc/salome/gui/images/plot2d_view_settings.png and b/doc/salome/gui/images/plot2d_view_settings.png differ
index a9506accfb7b87f4a9c6846290189c3b2273621e..6dade45e1656fa039fe82e97170e6e740a2898cd 100644 (file)
Binary files a/doc/salome/gui/images/pref_salome_general.png and b/doc/salome/gui/images/pref_salome_general.png differ
index 339dbf95012b70579fe3293b43f7af6bfdf58641..b75a840691dcff86ac3435dfaf40f263136cc374 100644 (file)
Binary files a/doc/salome/gui/images/pref_salome_plot2dviewer.png and b/doc/salome/gui/images/pref_salome_plot2dviewer.png differ
index 0ff585d9c2a86b6234dcabe07a9704143100997d..d372e793b8412cae23d6c480c3e71632f7325d77 100644 (file)
@@ -94,14 +94,14 @@ box of an object.
 
 \image html set_rotation_point_dialog2.png
 
-Unchecking <b>Use Bounding Box Center</b> checkbox allows you to
+Disabling <b>Use Bounding Box Center</b> check-box allows you to
 define the coordinates of the rotation point manually.
 
 - <b>Set to Origin</b> button restores the default rotation point
   coordinates.
 
-- <b>Gravity Center of Select Object</b> button allows to choose Point, Edge, Face or Solid in drop-down menu.
-  As soon as corresponding object is selected in the viewer, its gravity center will be used as center of the rotation point.
+- <b>Gravity Center of Selected Object</b> button allows using the gravity center of the object selected in the viewer as the center of the rotation point. 
+When you click this button, you should first choose the type of selectable object: Point, Edge, Face or Solid and only then proceed with selection in the viewer.
 
 <hr>
 
index 11640c348850618340e378c5564fdc5792f588a0..823c8cf496d27239b925f82c653d0462d80bb4fd 100644 (file)
@@ -129,33 +129,40 @@ allows to specify advanced parameters for the Plot 2d Viewer.
 \anchor settings
 \image html plot2d_view_settings.png
 
-The options are as follows:
-
-- <b>Main title</b> the title of the XY plot. By default, it will
-  consist of the names of the tables, on the basis of which the curve
-  lines have been constructed.
+The following options are available:
 
-- <b>Curve type</b> you can select from \em Points, \em Lines or
-  \em Spline.
+- <b>Main title</b> is the XY plot title. By default, it contains the names of tables, from which the curve
+  lines are constructed.
 
-- <b>Show legend</b> here you can define the position of the
-  description table on the XY plot (to the \em Left, to the \em Right,
-  on \em Top or on \em Bottom).
-
-- <b>Legend font</b> here you can set type, face and color for the
-  font of Legend item.
+- <b>Curve type</b> allows selecting from \em Points, \em Lines or  \em Spline.
 
 - <b>Marker size</b> - size of the points (markers) forming curve lines.
 
 - <b>Background color</b> of the XY plot.
 
-- <b>Deviation marker</b> allows specifying the properties of the
-  marker, which is used for drawing deviations data.
+- <b>Selection color</b> - defines the color of selected object in the viewer.
+
+- <b>Legend</b> specifies the legend properties.
+  
+  - <b>Show legend</b> - specifies if the legend is shown by default.
+
+  - <b>Legend Position</b> allows positioning the
+  description table on XY plot (to the \em Left, to the \em Right,
+  on \em Top or on \em Bottom).
+  
+  - <b>Symbol type</b> allows positioning the legend item symbol: "Marker on line" or "Marker above line".
+
+  - <b>Legend font</b> allows setting font variant, size and style for legend items.
+  
+  - <b>Legend font color</b> allows selecting the font color for legend items.
+
+  - <b>Highlighted legend font color</b> allows selecting font color for selected legend items.
+
+- <b>Deviation marker</b> specifies the properties of the marker, which is used for drawing deviations data.
 
   - <b>Line width</b> line width of the marker.
 
-  - <b>Tick size</b> size of the upper and lower horizontal lines of
-    the marker.
+  - <b>Tick size</b> size of the upper and lower horizontal lines of the marker.
 
   - <b>Color</b> color of the marker.
 
index 9b0899efd768989ab90d18cb4aaeddf2e655e0e1..9fabab109f09755d21e2be44eaf455327e0add51 100644 (file)
@@ -35,6 +35,9 @@ the whole GUI SALOME session.
 - <b>Language</b>
   - <b>Current language</b> - the language used by the application
   GUI. The language change will come in force only after the application is restarted.
+  - <b>Use C locale</b>  - when checked, the C locale will be set for the application,
+  otherwise a system locale will be used. The locale change will come in force only after
+  the application is restarted.
 - <b>Look and feel</b>
   - <b>Opaque resize</b> - force opaque resize mode for viewers area (tabbed workspace).
   Clear this checkbox for less perfomant workstations.
@@ -186,39 +189,43 @@ titles displayed in the viewer:
 
 \image html pref_salome_plot2dviewer.png
 
-- <b>Show legend</b> - this options specifies if it's necessary to
-show legend by default.
-- <b>Legend Position</b> - this submenu allows to set the default position
-of the legend, it can be located to the left, to the right, on top or
-on bottom of the graph.
-- <b>Legend font</b> - this allows to set type and face for the font of Legend item.
-- <b>Curve Type</b> - this allows to set the representation of graphs in
-your presentations. You can see only <b>Points</b>, points connected with
-<b>Lines</b> or points connected with smooth <b>Splines</b>.
-- <b>Marker Size</b> - this submenu allows you to set the size of
-markers in your graphs.
-- <b>Horizontal</b> and <b>Vertical axis scale</b> - this submenus allow you to set
-the scale for vertical and horizontal axes. It can be either <b>Linear</b> or
-<b>Logarithmic</b>. Note that the <b>Logarithmic</b> scale can be used only
-if the minimum value of corresponding component (abscissa or ordinate)
-of all points displayed in the viewer is greater than zero.
-If this condition is not met, the scale is switched to <b>Linear</b>
-automatically, even if it is set to <b>Logarithmic</b>.
 - <b>Background color</b> - this submenu allows to select the background
 color. Click on the colored line to access to the
 \ref select_color_and_font_page "Select Color" dialog box.
-- <b>Legend font color</b> - this allows to select the color of the
-font of the legend item. 
-- <b>Highlighted legend font color</b> - this submenu allows to select
-the color of the font of the selected legend item. 
 - <b>Selection color</b> - this submenu allows to select the color of
 selected object in the viewer. 
-- <b>Deviation marker color</b> - this submenu allows to select the
-color of the deviation marker. 
-- <b>Deviation marker line width</b> allows to define line width of
-the deviation marker. 
-- <b>Deviation marker tick size</b> allows to define size of the upper
-and lower horizontal lines of the deviation marker. 
+- <b>Viewer</b> - allows specifying the properties of the Plot 2D Viewer.
+  - <b>Curve Type</b> - this allows to set the representation of graphs in
+  your presentations. You can see only <b>Points</b>, points connected with
+  <b>Lines</b> or points connected with smooth <b>Splines</b>.
+  - <b>Marker Size</b> - this submenu allows you to set the size of
+  markers in your graphs.
+  - <b>Horizontal</b> and <b>Vertical axis scale</b> - this submenus allow you to set
+  the scale for vertical and horizontal axes. It can be either <b>Linear</b> or
+  <b>Logarithmic</b>. Note that the <b>Logarithmic</b> scale can be used only
+  if the minimum value of corresponding component (abscissa or ordinate)
+  of all points displayed in the viewer is greater than zero.
+  If this condition is not met, the scale is switched to <b>Linear</b>
+  automatically, even if it is set to <b>Logarithmic</b>.
+  - <b>Deviation marker color</b> - this submenu allows to select the
+  color of the deviation marker. 
+  - <b>Deviation marker line width</b> allows to define line width of
+  the deviation marker. 
+  - <b>Deviation marker tick size</b> allows to define size of the upper
+  and lower horizontal lines of the deviation marker. 
+- <b>Legend</b> - allows specifying the properties of the legend.
+  - <b>Show legend</b> - this options specifies if it's necessary to
+  show legend by default.
+  - <b>Legend Position</b> - this submenu allows to set the default position
+  of the legend, it can be located to the left, to the right, on top or
+  on bottom of the graph.
+  - <b>Symbol type</b> you can select the type of legend item symbol from "Marker on line" 
+  or "Marker above line"
+  - <b>Legend font</b> - this allows to set type and face for the font of Legend item.
+  - <b>Legend font color</b> - this allows to select the color of the
+  font of the legend item. 
+  - <b>Highlighted legend font color</b> - this submenu allows to select
+  the color of the font of the selected legend item. 
 
 <br><h2>Directories Preferences</h2>
 
index 2224cfa53c8c245007ba37d03ff4b0678658a819..3e50278806c7bd655a139fb4893efe8c120e36df 100644 (file)
@@ -99,8 +99,8 @@ define the coordinates of the rotation point manually.
 - <b>Set to Origin</b> button restores the default rotation point
   coordinates.
 
-- <b>Gravity Center of Select Object</b> button allows to choose Point, Edge, Face or Volume in drop-down menu.
-  As soon as corresponding object is selected in the viewer, its gravity center will be used as center of the rotation point.
+- <b>Gravity Center of Selected Object</b> button allows using the gravity center of the object selected in the viewer as the center of the rotation point. 
+When you click this button, you should first choose the type of selectable object: Point, Edge, Face or Solid and only then proceed with selection in the viewer.
 
 <hr>
 
@@ -123,12 +123,12 @@ These buttons orientate the scene strictly about coordinate axes:
 
 \image html vtk_view_anticlockwise.png
 
-<b>Rotate counter-clockwise</b> - rotates view 90 counter-clockwise.
+<b>Rotate counter-clockwise</b> - rotates view 90° counter-clockwise.
 <hr>
 
 \image html vtk_view_clockwise.png
 
-<b>Rotate clockwise</b> - rotates view 90 clockwise.
+<b>Rotate clockwise</b> - rotates view 90° clockwise.
 <hr>
 
 \image html vtk_view_reset.png
index a1acc38e590948780c82492918763d698568107d..6bfb4899204025db08b6fdb2d832771f3f43a6d8 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!DOCTYPE TS>
-<TS>
+<TS version="2.0" language="ja" sourcelanguage="en">
   <context>
     <name>CAF_Application</name>
     <message>
index ef935126241d855b0c7533cfdc77c2cdff90f066..c013823929552277094f2d3bb670aab8cc502bcd 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!DOCTYPE TS>
-<TS>
+<TS version="2.0" language="ja" sourcelanguage="en">
   <context>
     <name>@default</name>
     <message>
index 4e9b7ca31dbeae643d7ed91e9721c1e9fa3208fe..f833a7930cd79f6cea27c946ba224fdd909a637b 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!DOCTYPE TS>
-<TS>
+<TS version="2.0" language="ja" sourcelanguage="en">
   <context>
     <name>@default</name>
     <message>
index a837c94d7939a9593a666621ddbe5f6baa3c3482..fe21b49279148c35a11b78ee586623fa2d461be8 100644 (file)
     <name>GraphicsView_Viewer</name>
     <message>
         <source>TEST_CROP_OPERATOR</source>
-        <translation type="unfinished">Test Crop operator</translation>
+        <translation>Test Crop operator</translation>
     </message>
     <message>
         <source>TEST_FUSE_OPERATOR</source>
-        <translation type="unfinished">Test Fuse operator</translation>
+        <translation>Test Fuse operator</translation>
     </message>
     <message>
         <source>PROPERTIES</source>
-        <translation type="unfinished">Properties</translation>
+        <translation>Propriétés</translation>
     </message>
     <message>
         <source>SEND_BACKWARD</source>
-        <translation type="unfinished">Send backward</translation>
+        <translation>Afficher derrière</translation>
     </message>
     <message>
         <source>BRING_FORWARD</source>
-        <translation type="unfinished">Bring forward</translation>
+        <translation>Afficher devant</translation>
     </message>
     <message>
         <source>SEND_TO_BACK</source>
-        <translation type="unfinished">Send to back</translation>
+        <translation>Afficher au fond</translation>
     </message>
     <message>
         <source>BRING_TO_FRONT</source>
-        <translation type="unfinished">Bring to front</translation>
+        <translation>Afficher au premier plan</translation>
     </message>
     <message>
         <source>REMOVE_IMAGES</source>
-        <translation type="unfinished">Remove image(s)</translation>
+        <translation>Supprimer image(s)</translation>
     </message>
     <message>
         <source>ADD_IMAGE</source>
-        <translation type="unfinished">Add image</translation>
+        <translation>Ajouter une image</translation>
     </message>
     <message>
         <source>CHANGE_BGCOLOR</source>
diff --git a/src/GraphicsView/resources/GraphicsView_msg_ja.ts b/src/GraphicsView/resources/GraphicsView_msg_ja.ts
new file mode 100644 (file)
index 0000000..23d0692
--- /dev/null
@@ -0,0 +1,125 @@
+<?xml version="1.0"?>
+<!DOCTYPE TS>
+<TS language="ja" sourcelanguage="en">
+  <context>
+    <name>GraphicsView_ViewFrame</name>
+    <message>
+      <source>DSC_DUMP_VIEW</source>
+      <translation>&#x30A2;&#x30AF;&#x30C6;&#x30A3;&#x30D6;&#x30D3;&#x30E5;&#x30FC;&#x306E;&#x753B;&#x50CF;&#x3092;&#x4FDD;&#x5B58;</translation>
+    </message>
+    <message>
+      <source>DSC_FITALL</source>
+      <translation>&#x30D3;&#x30E5;&#x30FC;&#x306E;&#x67A0;&#x5185;&#x306B;&#x3059;&#x3079;&#x3066;&#x306E;&#x30AA;&#x30D6;&#x30B8;&#x30A7;&#x30AF;&#x30C8;&#x3092;&#x30D5;&#x30A3;&#x30C3;&#x30C8;&#x3059;&#x308B;</translation>
+    </message>
+    <message>
+      <source>DSC_FITRECT</source>
+      <translation>&#x9818;&#x57DF;&#x3092;&#x30D3;&#x30E5;&#x30FC;&#x306E;&#x67A0;&#x5185;&#x306B;&#x30D5;&#x30A3;&#x30C3;&#x30C8;&#x3059;&#x308B;</translation>
+    </message>
+    <message>
+      <source>DSC_FITSELECT</source>
+      <translation>&#x9078;&#x629E;&#x9818;&#x57DF;&#x3092;&#x30D3;&#x30E5;&#x30FC;&#x306E;&#x67A0;&#x5185;&#x306B;&#x30D5;&#x30A3;&#x30C3;&#x30C8;&#x3059;&#x308B;</translation>
+    </message>
+    <message>
+      <source>DSC_GLOBALPAN_VIEW</source>
+      <translation>&#x30D3;&#x30E5;&#x30FC;&#x306E;&#x65B0;&#x3057;&#x3044;&#x4E2D;&#x5FC3;&#x306E;&#x9078;&#x629E;</translation>
+    </message>
+    <message>
+      <source>DSC_PAN_VIEW</source>
+      <translation>&#x30D3;&#x30E5;&#x30FC;&#x306E;&#x56DE;&#x8EE2;</translation>
+    </message>
+    <message>
+      <source>DSC_RESET_VIEW</source>
+      <translation>&#x30D3;&#x30E5;&#x30FC;&#x306E;&#x30EA;&#x30BB;&#x30C3;&#x30C8;</translation>
+    </message>
+    <message>
+      <source>DSC_ZOOM_VIEW</source>
+      <translation>&#x30D3;&#x30E5;&#x30FC;&#x306E;&#x62E1;&#x5927;</translation>
+    </message>
+    <message>
+      <source>LBL_TOOLBAR_LABEL</source>
+      <translation>&#x30D3;&#x30E5;&#x30FC;&#x306E;&#x64CD;&#x4F5C;</translation>
+    </message>
+    <message>
+      <source>MNU_DUMP_VIEW</source>
+      <translation>&#x8868;&#x793A;&#x72B6;&#x614B;&#x306E;&#x4FDD;&#x5B58;</translation>
+    </message>
+    <message>
+      <source>MNU_FITALL</source>
+      <translation>&#x5168;&#x8868;&#x793A;</translation>
+    </message>
+    <message>
+      <source>MNU_FITRECT</source>
+      <translation>&#x9818;&#x57DF;&#x306B;&#x30D5;&#x30A3;&#x30C3;&#x30C8;</translation>
+    </message>
+    <message>
+      <source>MNU_FITSELECT</source>
+      <translation>&#x9078;&#x629E;&#x7BC4;&#x56F2;&#x3092;&#x30BA;&#x30FC;&#x30E0;</translation>
+    </message>
+    <message>
+      <source>MNU_GLOBALPAN_VIEW</source>
+      <translation>&#x30B0;&#x30ED;&#x30FC;&#x30D0;&#x30EB;&#x56DE;&#x8EE2;</translation>
+    </message>
+    <message>
+      <source>MNU_PAN_VIEW</source>
+      <translation>&#x56DE;&#x8EE2;</translation>
+    </message>
+    <message>
+      <source>MNU_RESET_VIEW</source>
+      <translation>&#x30EA;&#x30BB;&#x30C3;&#x30C8;</translation>
+    </message>
+    <message>
+      <source>MNU_ZOOM_VIEW</source>
+      <translation>&#x30BA;&#x30FC;&#x30E0;</translation>
+    </message>
+  </context>
+  <context>
+    <name>GraphicsView_Viewer</name>
+    <message>
+      <source>CHANGE_BGCOLOR</source>
+      <translation>&#x80CC;&#x666F;&#x306E;&#x5909;&#x66F4;.</translation>
+    </message>
+    <message>
+      <source>ADD_IMAGE</source>
+      <translation>&#x753B;&#x50CF;&#x306E;&#x8FFD;&#x52A0;</translation>
+    </message>
+    <message>
+      <source>REMOVE_IMAGES</source>
+      <translation>&#x753B;&#x50CF;&#x306E;&#x524A;&#x9664;</translation>
+    </message>
+    <message>
+      <source>BRING_TO_FRONT</source>
+      <translation>&#x6700;&#x524D;&#x9762;&#x3078;&#x79FB;&#x52D5;</translation>
+    </message>
+    <message>
+      <source>SEND_TO_BACK</source>
+      <translation>&#x6700;&#x80CC;&#x9762;&#x3078;&#x79FB;&#x52D5;</translation>
+    </message>
+    <message>
+      <source>BRING_FORWARD</source>
+      <translation>&#x524D;&#x9762;&#x3078;&#x79FB;&#x52D5;</translation>
+    </message>
+    <message>
+      <source>SEND_BACKWARD</source>
+      <translation>&#x80CC;&#x9762;&#x3078;&#x79FB;&#x52D5;</translation>
+    </message>
+    <message>
+      <source>PROPERTIES</source>
+      <translation>&#x30D7;&#x30ED;&#x30D1;&#x30C6;&#x30A3;</translation>
+    </message>
+    <message>
+      <source>TEST_FUSE_OPERATOR</source>
+      <translation>&#x7D50;&#x5408;&#x306E;&#x30C6;&#x30B9;&#x30C8;</translation>
+    </message>
+    <message>
+      <source>TEST_CROP_OPERATOR</source>
+      <translation>&#x30C8;&#x30EA;&#x30E0;&#x306E;&#x30C6;&#x30B9;&#x30C8;</translation>
+    </message>
+  </context>
+  <context>
+    <name>GraphicsView_ViewManager</name>
+    <message>
+      <source>GRAPHICS_VIEW_TITLE</source>
+      <translation>&#x30B0;&#x30E9;&#x30D5;&#x30A3;&#x30C3;&#x30AF;&#x30B7;&#x30FC;&#x30F3;:%M - &#x30D3;&#x30E5;&#x30FC;&#x30EF;:%V</translation>
+    </message>
+  </context>
+</TS>
index e6970b23f1ab05c57bb867e79a67664ae00294f8..2640effb99ec3c32e32fc75c8a33035a1a0491ee 100644 (file)
@@ -43,6 +43,7 @@
 #include "LightApp_Module.h"
 #include "LightApp_DataModel.h"
 #include "LightApp_DataOwner.h"
+#include "LightApp_Displayer.h"
 #include "LightApp_Study.h"
 #include "LightApp_Preferences.h"
 #include "LightApp_PreferencesDlg.h"
@@ -378,6 +379,11 @@ LightApp_Application::LightApp_Application()
 #endif
 
   connect( mySelMgr, SIGNAL( selectionChanged() ), this, SLOT( onSelection() ) );
+  connect( desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
+           this,      SLOT( onWindowActivated( SUIT_ViewWindow* ) ), Qt::UniqueConnection );
+  connect( this, SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
+           this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ), Qt::UniqueConnection );
+
 
   // Set existing font for the python console in resources
   if( !aResMgr->hasValue( "PyConsole", "font" ) )
@@ -868,8 +874,14 @@ void LightApp_Application::onNewWindow()
 void LightApp_Application::onNewDoc()
 {
   //asl: fix for 0020515
-  if ( activeStudy() )
+  if ( activeStudy() ) {
     saveDockWindowsState();
+  }
+  
+#ifdef SINGLE_DESKTOP
+  if ( !checkExistingDoc() )
+    return;
+#endif
 
   CAM_Application::onNewDoc();
 }
@@ -881,9 +893,14 @@ void LightApp_Application::onOpenDoc()
 {
   SUIT_Study* study = activeStudy();
   saveDockWindowsState();
-
+  
+#ifdef SINGLE_DESKTOP
+  if ( !checkExistingDoc() )
+    return;
+#endif
+  
   CAM_Application::onOpenDoc();
-
+  
   if ( !study ) // new study will be create in THIS application
   {
     updateWindows();
@@ -897,9 +914,13 @@ void LightApp_Application::onOpenDoc()
 */
 bool LightApp_Application::onOpenDoc( const QString& aName )
 {
+#ifdef SINGLE_DESKTOP
+  if ( !checkExistingDoc() )
+    return false;
+#endif
   // We should take mru action first because this application instance can be deleted later.
   QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
-
+  
   bool res = CAM_Application::onOpenDoc( aName );
 
   if ( mru )
@@ -1671,6 +1692,11 @@ void LightApp_Application::onStudySaved( SUIT_Study* s )
 /*!Protected SLOT. On study closed.*/
 void LightApp_Application::onStudyClosed( SUIT_Study* s )
 {
+  /*
+  disconnect( this, SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
+             this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ) );
+  */
+
   // stop auto-save timer
   myAutoSaveTimer->stop();
 
@@ -2096,6 +2122,9 @@ void LightApp_Application::createPreferences( LightApp_Preferences* pref )
   }
   pref->setItemProperty( "strings", aLangs, curLang );
   pref->setItemProperty( "icons",   aIcons, curLang );
+
+  int curLocale = pref->addPreference( tr( "PREF_CURRENT_LOCALE" ), langGroup,
+                                          LightApp_Preferences::Bool, "language", "locale" );
   // ... "Language" group <<end>>
 
   // ... "Look and feel" group <<start>>
@@ -2434,22 +2463,18 @@ void LightApp_Application::createPreferences( LightApp_Preferences* pref )
   int plot2dGroup = pref->addPreference( tr( "PREF_GROUP_PLOT2DVIEWER" ), salomeCat ); //viewTab
   //pref->setItemProperty( "columns", 2, plot2dGroup );
 
-  // ... -> show legend
-  pref->addPreference( tr( "PREF_SHOW_LEGEND" ), plot2dGroup,
-                       LightApp_Preferences::Bool, "Plot2d", "ShowLegend" );
-  // ... -> legend position
-  int legendPosition = pref->addPreference( tr( "PREF_LEGEND_POSITION" ), plot2dGroup,
-                                            LightApp_Preferences::Selector, "Plot2d", "LegendPos" );
-  aValuesList.clear();
-  anIndicesList.clear();
-  aValuesList   << tr("PREF_LEFT") << tr("PREF_RIGHT") << tr("PREF_TOP") << tr("PREF_BOTTOM");
-  anIndicesList << 0               << 1                << 2              << 3                ;
-  pref->setItemProperty( "strings", aValuesList,   legendPosition );
-  pref->setItemProperty( "indexes", anIndicesList, legendPosition );
-  // ... -> legend font
-  pref->addPreference( tr( "PREF_LEGEND_FONT" ), plot2dGroup, LightApp_Preferences::Font, "Plot2d", "LegendFont" );
-  // ... -> curve type
-  int curveType = pref->addPreference( tr( "PREF_CURVE_TYPE" ), plot2dGroup,
+  // ... -> background
+  pref->addPreference( tr( "PREF_VIEWER_BACKGROUND_COLOR" ), plot2dGroup,
+                       LightApp_Preferences::Color, "Plot2d", "Background" );
+  // ... -> selection color
+  pref->addPreference( tr( "PREF_VIEWER_SELECTION" ), plot2dGroup,
+                       LightApp_Preferences::Color, "Plot2d", "SelectionColor" );
+
+  // ... "Viewer" group <<start>>
+  int plot2dViewerGroup = pref->addPreference( tr( "PREF_GROUP_VIEWER" ), plot2dGroup );
+
+  // .... -> curve type
+  int curveType = pref->addPreference( tr( "PREF_CURVE_TYPE" ), plot2dViewerGroup,
                                        LightApp_Preferences::Selector, "Plot2d", "CurveType" );
   aValuesList.clear();
   anIndicesList.clear();
@@ -2457,13 +2482,13 @@ void LightApp_Application::createPreferences( LightApp_Preferences* pref )
   anIndicesList << 0                 << 1                << 2                ;
   pref->setItemProperty( "strings", aValuesList,   curveType );
   pref->setItemProperty( "indexes", anIndicesList, curveType );
-  // ... -> marker size
-  int markerSize = pref->addPreference( tr( "PREF_MARKER_SIZE" ), plot2dGroup,
+  // .... -> marker size
+  int markerSize = pref->addPreference( tr( "PREF_MARKER_SIZE" ), plot2dViewerGroup,
                                         LightApp_Preferences::IntSpin, "Plot2d", "MarkerSize" );
   pref->setItemProperty( "min", 0, markerSize );
   pref->setItemProperty( "max", 100, markerSize );
-  // ... -> horizontal scaling mode
-  int horScale = pref->addPreference( tr( "PREF_HOR_AXIS_SCALE" ), plot2dGroup,
+  // .... -> horizontal scaling mode
+  int horScale = pref->addPreference( tr( "PREF_HOR_AXIS_SCALE" ), plot2dViewerGroup,
                                       LightApp_Preferences::Selector, "Plot2d", "HorScaleMode" );
   aValuesList.clear();
   anIndicesList.clear();
@@ -2471,34 +2496,59 @@ void LightApp_Application::createPreferences( LightApp_Preferences* pref )
   anIndicesList << 0                 << 1                     ;
   pref->setItemProperty( "strings", aValuesList,   horScale );
   pref->setItemProperty( "indexes", anIndicesList, horScale );
-  // ... -> vertical scaling mode
-  int verScale = pref->addPreference( tr( "PREF_VERT_AXIS_SCALE" ), plot2dGroup,
+  // .... -> vertical scaling mode
+  int verScale = pref->addPreference( tr( "PREF_VERT_AXIS_SCALE" ), plot2dViewerGroup,
                                       LightApp_Preferences::Selector, "Plot2d", "VerScaleMode" );
   pref->setItemProperty( "strings", aValuesList,   verScale );
   pref->setItemProperty( "indexes", anIndicesList, verScale );
-  // ... -> background
-  pref->addPreference( tr( "PREF_VIEWER_BACKGROUND_COLOR" ), plot2dGroup,
-                       LightApp_Preferences::Color, "Plot2d", "Background" );
-  // ... -> font color
-  pref->addPreference( tr( "PREF_FONT_COLOR" ), plot2dGroup, LightApp_Preferences::Color, "Plot2d", "LegendFontColor" );
-  // ... -> selection font color
-  pref->addPreference( tr( "PREF_SELECTED_FONT_COLOR" ), plot2dGroup, LightApp_Preferences::Color, "Plot2d", "SelectedLegendFontColor" );
-  // ... -> selection color
-  pref->addPreference( tr( "PREF_VIEWER_SELECTION" ), plot2dGroup,
-                       LightApp_Preferences::Color, "Plot2d", "SelectionColor" );
-  // ... -> errors/deviation colot
-  pref->addPreference( tr( "PREF_DEVIATION_COLOR" ), plot2dGroup,
+
+  // .... -> errors/deviation colot
+  pref->addPreference( tr( "PREF_DEVIATION_COLOR" ), plot2dViewerGroup,
                        LightApp_Preferences::Color, "Plot2d", "DeviationMarkerColor" );
-  // ... -> deviation markers line size
-  int deviationMarkerLw = pref->addPreference( tr( "PREF_DEVIATION_MARKER_LW" ), plot2dGroup,
+  // .... -> deviation markers line size
+  int deviationMarkerLw = pref->addPreference( tr( "PREF_DEVIATION_MARKER_LW" ), plot2dViewerGroup,
                                         LightApp_Preferences::IntSpin, "Plot2d", "DeviationMarkerLineWidth" );
   pref->setItemProperty( "min", 1, deviationMarkerLw );
   pref->setItemProperty( "max", 5, deviationMarkerLw );
-  // ... -> deviation markers tick mark size
-  int deviationMarkerTs = pref->addPreference( tr( "PREF_DEVIATION_MARKER_TS" ), plot2dGroup,
+  // .... -> deviation markers tick mark size
+  int deviationMarkerTs = pref->addPreference( tr( "PREF_DEVIATION_MARKER_TS" ), plot2dViewerGroup,
                                         LightApp_Preferences::IntSpin, "Plot2d", "DeviationMarkerTickSize" );
   pref->setItemProperty( "min", 1, deviationMarkerTs );
   pref->setItemProperty( "max", 5, deviationMarkerTs );
+  // .... "Viewer" group <<end>>
+
+  // ... "Legend" group <<start>>
+  int plot2dLegendGroup = pref->addPreference( tr( "PREF_GROUP_LEGEND" ), plot2dGroup );
+
+  // .... -> show legend
+  pref->addPreference( tr( "PREF_SHOW_LEGEND" ), plot2dLegendGroup,
+                       LightApp_Preferences::Bool, "Plot2d", "ShowLegend" );
+  // .... -> legend position
+  int legendPosition = pref->addPreference( tr( "PREF_LEGEND_POSITION" ), plot2dLegendGroup,
+                                            LightApp_Preferences::Selector, "Plot2d", "LegendPos" );
+  aValuesList.clear();
+  anIndicesList.clear();
+  aValuesList   << tr("PREF_LEFT") << tr("PREF_RIGHT") << tr("PREF_TOP") << tr("PREF_BOTTOM");
+  anIndicesList << 0               << 1                << 2              << 3                ;
+  pref->setItemProperty( "strings", aValuesList,   legendPosition );
+  pref->setItemProperty( "indexes", anIndicesList, legendPosition );
+  // .... -> Symbol type
+  int legendSymbolType = pref->addPreference( tr( "PREF_LEGEND_SYMBOL_TYPE" ), plot2dLegendGroup,
+                                            LightApp_Preferences::Selector, "Plot2d", "LegendSymbolType" );
+  aValuesList.clear();
+  anIndicesList.clear();
+  aValuesList   << tr("PREF_MARKER_ON_LINE") << tr("PREF_MARKER_ABOVE_LINE");
+  anIndicesList << 0                            << 1                        ;
+  pref->setItemProperty( "strings", aValuesList,   legendSymbolType );
+  pref->setItemProperty( "indexes", anIndicesList, legendSymbolType );
+  // .... -> legend font
+  pref->addPreference( tr( "PREF_LEGEND_FONT" ), plot2dLegendGroup, LightApp_Preferences::Font, "Plot2d", "LegendFont" );
+  // ... -> font color
+  pref->addPreference( tr( "PREF_FONT_COLOR" ), plot2dLegendGroup, LightApp_Preferences::Color, "Plot2d", "LegendFontColor" );
+  // ... -> selection font color
+  pref->addPreference( tr( "PREF_SELECTED_FONT_COLOR" ), plot2dLegendGroup, LightApp_Preferences::Color, "Plot2d", "SelectedLegendFontColor" );
+  // ... "Legend" group <<end>>
+
   // .. "Plot2d viewer" group <<end>>
 
   // .. "Directories" preferences tab <<start>>
@@ -2945,6 +2995,10 @@ void LightApp_Application::preferencesChanged( const QString& sec, const QString
   {
     SUIT_MessageBox::information( desktop(), tr( "WRN_WARNING" ), tr( "LANG_CHANGED" ) );
   }
+  if ( sec == "language" && param == "locale")
+  {
+    SUIT_MessageBox::information( desktop(), tr( "WRN_WARNING" ), tr( "LOCALE_CHANGED" ) );
+  }
   if ( sec == "desktop" && param == "opaque_resize" ) {
     bool opaqueResize = resMgr->booleanValue( "desktop", "opaque_resize", false );
     QMainWindow::DockOptions dopts = desktop()->dockOptions();
@@ -2964,14 +3018,22 @@ void LightApp_Application::preferencesChanged( const QString& sec, const QString
   }
 
 #ifndef DISABLE_PLOT2DVIEWER
-  if ( sec == "Plot2d" ) {
-    if( param == "SelectionColor" ) {
-      QColor c = resMgr->colorValue( sec, param );
-      Plot2d_Object::setSelectionColor(c);
-    }
-    else if (param == "SelectedLegendFontColor") {
-      QColor c = resMgr->colorValue( sec, param );      
-      Plot2d_Object::setHighlightedLegendTextColor(c);
+  QList<SUIT_ViewManager*> lst;
+  viewManagers( Plot2d_Viewer::Type(), lst );
+  QListIterator<SUIT_ViewManager*> itPlot2d( lst );
+  while ( itPlot2d.hasNext() ) {
+    SUIT_ViewManager* viewMgr = itPlot2d.next();
+    SUIT_ViewModel* vm = viewMgr->getViewModel();
+    if ( !vm || !vm->inherits( "Plot2d_Viewer" ) )
+      continue;
+
+    Plot2d_Viewer* Plot2dVM = dynamic_cast<Plot2d_Viewer*>( vm );
+
+    viewMgr->setViewModel( vm  );
+    Plot2d_ViewWindow* wnd = dynamic_cast<Plot2d_ViewWindow*>( viewMgr->getActiveView() );
+    if( wnd ) {
+      Plot2d_ViewFrame* frame = wnd->getViewFrame();
+      frame->SetPreference();
     }
   }
 #endif
@@ -3270,6 +3332,7 @@ void LightApp_Application::loadDockWindowsState()
     desktop()->restoreState( aTargetArray );
   }
 
+  /*
   if ( !myWinVis.contains( modName ) && aDefaultVisibility.isEmpty())
     return;
 
@@ -3299,7 +3362,7 @@ void LightApp_Application::loadDockWindowsState()
       dwMap =  &defaultDwMap;
     }
   }
-  
+
   if(tbMap) {
     QList<QToolBar*> tbList = findToolBars();
     for ( QList<QToolBar*>::iterator tit = tbList.begin(); tit != tbList.end(); ++tit )
@@ -3325,6 +3388,7 @@ void LightApp_Application::loadDockWindowsState()
          dw->setVisible( (*dwMap)[dw->objectName()] );
       }
   }
+  */
 }
 
 
@@ -3538,6 +3602,8 @@ void LightApp_Application::setDesktop( SUIT_Desktop* desk )
   if ( desk ) {
     connect( desk, SIGNAL( message( const QString& ) ),
              this, SLOT( onDesktopMessage( const QString& ) ), Qt::UniqueConnection );
+    connect( desk, SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
+             this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ), Qt::UniqueConnection );
   }
 }
 
@@ -4287,3 +4353,81 @@ void LightApp_Application::emitOperationFinished( const QString& theModuleName,
 {
   emit operationFinished( theModuleName, theOperationName, theEntryList );
 }
+
+/*!
+  Update visibility state of given objects
+*/
+void LightApp_Application::updateVisibilityState( DataObjectList& theList,
+                                                 SUIT_ViewModel*  theViewModel )
+{
+  if ( !theViewModel || theList.isEmpty() ) return;
+
+  LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>(activeStudy());
+  if ( !aStudy ) return;
+
+  SALOME_View* aView = dynamic_cast<SALOME_View*>( theViewModel );
+
+  for ( DataObjectList::iterator itr = theList.begin(); itr != theList.end(); ++itr ) {
+    LightApp_DataObject* obj = dynamic_cast<LightApp_DataObject*>(*itr);
+
+    if ( !obj || aStudy->isComponent( obj->entry() ) )
+      continue;
+
+    LightApp_Module* anObjModule = dynamic_cast<LightApp_Module*>(obj->module());
+    if ( anObjModule ) {
+      LightApp_Displayer* aDisplayer = anObjModule->displayer();
+      if ( aDisplayer ) {
+       Qtx::VisibilityState anObjState = Qtx::UnpresentableState;
+        if ( aDisplayer->canBeDisplayed( obj->entry(), theViewModel->getType() ) ) {
+          if ( aView && aDisplayer->IsDisplayed( obj->entry(), aView ) )
+            anObjState = Qtx::ShownState;
+          else
+            anObjState = Qtx::HiddenState;
+        }
+       aStudy->setVisibilityState( obj->entry(), anObjState );
+      }
+    }
+  }
+}
+
+/*!
+ * Called when window activated
+ */
+void LightApp_Application::onWindowActivated( SUIT_ViewWindow* theViewWindow )
+{
+  SUIT_DataBrowser* anOB = objectBrowser();
+  if ( !anOB )
+    return;
+  SUIT_DataObject* rootObj = anOB->root();
+  if ( !rootObj )
+    return;
+
+  DataObjectList listObj = rootObj->children( true );
+
+  SUIT_ViewModel* vmod = 0;
+  if ( SUIT_ViewManager* vman = theViewWindow->getViewManager() )
+    vmod = vman->getViewModel();
+  updateVisibilityState( listObj, vmod );
+}
+
+/*!
+  Called then view manager removed
+*/
+void LightApp_Application::onViewManagerRemoved( SUIT_ViewManager* )
+{
+  ViewManagerList lst;
+  viewManagers( lst );
+  if ( lst.count() == 1) { // in case if closed last view window
+    LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>( activeStudy() );
+    if ( aStudy )
+      aStudy->setVisibilityStateForAll( Qtx::UnpresentableState );
+  }
+}
+
+/*!
+  Check existing document.
+*/
+bool LightApp_Application::checkExistingDoc() {
+  return true;
+}
+
index f017b06e3b6e805923a7b8bff00da655feaafa9c..93b325c8a7e60d20989efbe6fedf476b371128bb 100644 (file)
@@ -33,6 +33,7 @@
 
 #include "LightApp.h"
 #include <SUIT_TreeModel.h>
+#include <SUIT_DataObject.h>
 #include <CAM_Application.h>
 
 #include <QPointer>
@@ -50,6 +51,7 @@ class LightApp_DataObject;
 class SUIT_DataBrowser;
 class SUIT_Study;
 class SUIT_Accel;
+class SUIT_ViewModel;
 class CAM_Module;
 
 class QString;
@@ -174,6 +176,11 @@ public:
 
   void                                emitOperationFinished( const QString&, const QString&, const QStringList& );
 
+  void                                updateVisibilityState( DataObjectList& theList,
+                                                             SUIT_ViewModel* theViewModel );  
+
+  virtual bool                        checkExistingDoc();
+
 signals:
   void                                studyOpened();
   void                                studySaved();
@@ -186,6 +193,7 @@ public slots:
   virtual void                        onHelpContextModule( const QString&, const QString&, const QString& = QString() );
   virtual void                        onNewDoc();
   virtual void                        onOpenDoc();
+
   virtual void                        onHelpAbout();
   virtual bool                        onOpenDoc( const QString& );
   virtual void                        onCopy();
@@ -223,15 +231,17 @@ protected:
 
 protected slots:
   virtual void                        onDesktopActivated();
+  virtual void                        onViewManagerRemoved( SUIT_ViewManager* );
+  virtual void                        onWindowActivated( SUIT_ViewWindow* theViewWindow );
 
   void                                onNewWindow();
   void                                onModuleActivation( const QString& );
   void                                onCloseView( SUIT_ViewManager* );
 
-  void                                onStudyCreated( SUIT_Study* );
-  void                                onStudyOpened( SUIT_Study* );
-  void                                onStudySaved( SUIT_Study* );
-  void                                onStudyClosed( SUIT_Study* );
+  virtual void                        onStudyCreated( SUIT_Study* );
+  virtual void                        onStudyOpened( SUIT_Study* );
+  virtual void                        onStudySaved( SUIT_Study* );
+  virtual void                        onStudyClosed( SUIT_Study* );
 
   void                                onWCDestroyed( QObject* );
 
index e4f6279dd9ec304c315cc466f309a3ed6cb2cfba..414db57a2794bed0985a64cb0f9c200b3954cf9f 100644 (file)
@@ -43,15 +43,15 @@ public:
   virtual ~LightApp_Displayer();
 
   void Display( const QString&, const bool = true, SALOME_View* = 0 );
-  void Display( const QStringList&, const bool = true,
-                SALOME_View* = 0 );
+  virtual void Display( const QStringList&, const bool = true,
+                        SALOME_View* = 0 );
 
-  void Redisplay( const QString&, const bool = true );
+  virtual void Redisplay( const QString&, const bool = true );
 
-  void Erase( const QStringList&, const bool forced = false,
-              const bool updateViewer = true, SALOME_View* = 0);
+  virtual void Erase( const QStringList&, const bool forced = false,
+                      const bool updateViewer = true, SALOME_View* = 0);
   void Erase( const QString&, const bool forced = false, const bool updateViewer = true, SALOME_View* = 0 );
-  void EraseAll( const bool forced = false, const bool updateViewer = true, SALOME_View* = 0 ) const;
+  virtual void EraseAll( const bool forced = false, const bool updateViewer = true, SALOME_View* = 0 ) const;
 
   virtual bool IsDisplayed( const QString&, SALOME_View* = 0 ) const;
   void UpdateViewer() const;
index 41e803fabbc0aa2c230f761f19268a20ceb12ff6..2127f020835172cb37488d7693dd7b74107294d8 100644 (file)
@@ -49,6 +49,7 @@
 #include <SUIT_ShortcutMgr.h>
 #include <SUIT_Desktop.h>
 #include <SUIT_TreeModel.h>
+#include <SUIT_Session.h>
 
 #ifndef DISABLE_SALOMEOBJECT
 #include <SALOME_ListIO.hxx>
@@ -104,7 +105,8 @@ LightApp_Module::LightApp_Module( const QString& name )
   myDisplay( -1 ),
   myErase( -1 ),
   myDisplayOnly( -1 ),
-  myEraseAll( -1 )
+  myEraseAll( -1 ),
+  myIsFirstActivate( true )
 {
 }
 
@@ -243,6 +245,12 @@ bool LightApp_Module::activateModule( SUIT_Study* study )
     m->registerColumn( getApp()->objectBrowser(), EntryCol, LightApp_DataObject::EntryId );
     treeModel->setAppropriate( EntryCol, Qtx::Toggled );
   }*/
+
+  if ( myIsFirstActivate ) {
+    updateModuleVisibilityState();
+    myIsFirstActivate = false;
+  }
+  
   return res;
 }
 
@@ -285,6 +293,22 @@ bool LightApp_Module::deactivateModule( SUIT_Study* study )
   return CAM_Module::deactivateModule( study );
 }
 
+/*! Redefined to reset internal flags valid for study instance */
+void LightApp_Module::studyClosed( SUIT_Study* theStudy )
+{
+  CAM_Module::studyClosed( theStudy );
+  
+  myIsFirstActivate = true;
+  
+  LightApp_Application* app = dynamic_cast<LightApp_Application*>(application());
+  if ( app ) {
+    SUIT_DataBrowser* ob = app->objectBrowser();
+    if ( ob && ob->model() )
+      disconnect( ob->model(), SIGNAL( clicked( SUIT_DataObject*, int ) ),
+                 this, SLOT( onObjectClicked( SUIT_DataObject*, int ) ) );
+  }
+}
+
 /*!NOT IMPLEMENTED*/
 void LightApp_Module::MenuItem()
 {
@@ -756,3 +780,61 @@ bool LightApp_Module::renameObject( const QString& /*entry*/, const QString& /*n
 {
   return false;
 }
+
+/*!
+  Update visibility state for data objects
+*/
+void LightApp_Module::updateModuleVisibilityState()
+{
+  // update visibility state of objects
+  LightApp_Application* app = dynamic_cast<LightApp_Application*>(SUIT_Session::session()->activeApplication());
+  if ( !app ) return;
+  
+  SUIT_DataBrowser* ob = app->objectBrowser();
+  if ( !ob || !ob->model() ) return;
+
+  // connect to click on item
+  connect( ob->model(), SIGNAL( clicked( SUIT_DataObject*, int ) ),
+           this, SLOT( onObjectClicked( SUIT_DataObject*, int ) ), Qt::UniqueConnection );
+
+  SUIT_DataObject* rootObj = ob->root();
+  if ( !rootObj ) return;
+  
+  DataObjectList listObj = rootObj->children( true );
+  
+  SUIT_ViewModel* vmod = 0;
+  if ( SUIT_ViewManager* vman = app->activeViewManager() )
+    vmod = vman->getViewModel();
+  app->updateVisibilityState( listObj, vmod );
+}
+
+/*!
+ * \brief Virtual public slot
+ *
+ * This method is called after the object inserted into data view to update their visibility state
+ * This is default implementation
+ */
+void LightApp_Module::onObjectClicked( SUIT_DataObject* theObject, int theColumn )
+{
+  if ( !isActiveModule() ) return;
+
+  // change visibility of object
+  if ( !theObject || theColumn != SUIT_DataObject::VisibilityId ) return;
+
+  LightApp_Study* study = dynamic_cast<LightApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
+  if ( !study ) return;
+
+  LightApp_DataObject* lo = dynamic_cast<LightApp_DataObject*>( theObject );
+  if ( !lo ) return;
+  
+  // detect action index (from LightApp level)
+  int id = -1;
+  
+  if ( study->visibilityState( lo->entry() ) == Qtx::ShownState )
+    id = myErase;
+  else if ( study->visibilityState( lo->entry() ) == Qtx::HiddenState )
+    id = myDisplay;
+  
+  if ( id != -1 )
+    startOperation( id );
+}
index 49729b95e1458142cdd7473e727abc9b0d8a28f1..6572aef1d6a6de316b0cf292d8cb06af9d267bbd 100644 (file)
@@ -106,9 +106,13 @@ public:
   virtual bool                        renameAllowed( const QString& ) const;
   virtual bool                        renameObject( const QString&, const QString& );
 
+  virtual void                        updateModuleVisibilityState();
+
 public slots:
   virtual bool                        activateModule( SUIT_Study* );
   virtual bool                        deactivateModule( SUIT_Study* );
+  virtual void                        studyClosed( SUIT_Study* );
+  virtual void                        onObjectClicked( SUIT_DataObject*, int );
 
   void                                MenuItem();
 
@@ -165,6 +169,7 @@ private:
 
 protected:
   int                   myDisplay, myErase, myDisplayOnly, myEraseAll;
+  bool                  myIsFirstActivate;
 };
 
 #ifdef WIN32
index d95a793323c05aca9a895a5c01e8ba3d9761bc6d..e2d29ec6f2d3b799994a278e29026b33d7f59487 100644 (file)
@@ -28,6 +28,8 @@
 
 #include "QtxResourceMgr.h"
 
+#include <SUIT_Session.h>
+#include <SUIT_Application.h>
 #include <SUIT_MessageBox.h>
 #include <SUIT_FileDlg.h>
 
@@ -39,7 +41,7 @@
   Constructor.
 */
 LightApp_PreferencesDlg::LightApp_PreferencesDlg( LightApp_Preferences* prefs, QWidget* parent )
-: QtxDialog( parent, true, true, OK | Close | Apply ),
+: QtxDialog( parent, true, true, OK | Close | Apply | Help ),
 myPrefs( prefs ), mySaved ( false )
 {
   setWindowTitle( tr( "CAPTION" ) );
@@ -115,6 +117,9 @@ void LightApp_PreferencesDlg::reject()
 /*!Do nothing.*/
 void LightApp_PreferencesDlg::onHelp()
 {
+  SUIT_Application* app = SUIT_Session::session()->activeApplication();
+  if ( app )
+    app->onHelpContextModule( "GUI", "setting_preferences_page.html" );
 }
 
 /*!Store preferences on apply.*/
index a138c7ac1245518f89f5395c5b0611fe3bf17308..a172c10bcf92b54a7693120fdd2b1ad7deae4411 100644 (file)
 //
 #include "LightApp_PyInterp.h"
 
-#include <SUITApp_init_python.hxx>
-#include <PyConsole_Interp.h>
-
-#include <pthread.h>
-
 /*!
- * constructor : multi Python interpreter, one per SALOME study.
- * calls initialize method defined in base class, which calls virtual methods
- * initstate & initcontext redefined here.
+ * constructor : Python interpreter.
  */
 LightApp_PyInterp::LightApp_PyInterp(): PyConsole_EnhInterp()
 {
@@ -44,59 +37,16 @@ LightApp_PyInterp::~LightApp_PyInterp()
 }
  
 /*!\class LightApp_PyInterp
- * EDF-CCAR
- * When SALOME uses multi Python interpreter feature,
- * Every study has its own interpreter and thread state (_tstate = Py_NewInterpreter())
- * This is fine because every study has its own modules (sys.modules) stdout and stderr
- * BUT some Python modules must be imported only once. In multi interpreter context Python
- * modules (*.py) are imported several times.
- * The pyqt module must be imported only once because it registers classes in a C module.
- * It's quite the same with omniorb modules (internals and generated with omniidl)
- * This problem is handled with "shared modules" defined in salome_shared_modules.py
- * These "shared modules" are imported only once and only copied in all the other interpreters
- * BUT it's not the only problem. Every interpreter has its own __builtin__ module. That's fine
- * but if we have copied some modules and imported others problems may arise with operations that
- * are not allowed in restricted execution environment. So we must impose that all interpreters
- * have identical __builtin__ module.
- * That's all, for the moment ...
+ * [ABN] : there is now a single Python interpreter for the whole SALOME run.
+ * Different execution environment are provided to emulate independent
+ * "virtual" Python interpreters.
  */
 
 
-bool LightApp_PyInterp::initContext()
-{
-  /*!
-   * The GIL is assumed to be held
-   * It is the caller responsability caller to acquire the GIL
-   * It will still be held on initContext output
-   */
-  if ( !PyConsole_Interp::initContext() )
-    return false;
-  
-  //Import special module to change the import mechanism
-  PyObjWrapper m1( PyImport_ImportModule( "import_hook" ) );
-  if ( !m1 )
-  {
-    PyErr_Print();
-    return false;
-    }
-  
-  // Call init_shared_modules to initialize the shared import mechanism for modules 
-  //that must not be imported twice
-  PyObjWrapper m2( PyObject_CallMethod( m1, (char*)"init_shared_modules", (char*)"O", SUIT_PYTHON::salome_shared_modules_module ) );
-  if ( !m2 )
-  {
-    PyErr_Print();
-    return false;
-  }
-  return true;
-}
-
 /*!
   Do nothing
-  The initialization has been done in main
+  The initialization has been done in main - see SUITApp/SUITApp.cxx - main()
  */
 void LightApp_PyInterp::initPython()
 {
-  _gtstate=SUIT_PYTHON::_gtstate; // initialisation in main
-  _interp=SUIT_PYTHON::_interp;
 }
index 9d4cb760dc24b5b5997a59b07836edda4d055b7e..de8c2663666c9b9559c980d5b5558e42850ba591 100644 (file)
@@ -33,7 +33,6 @@ public:
   
 protected:
   virtual void initPython();
-  virtual bool initContext();
 };
 
 #endif //_LIGHTAPP_PYINTERP_H_
index 751f2293e400145e42cfbe937be102ee9c02fc1b..4588f9ae979190009f22608fb6714c7920bcdc0c 100644 (file)
@@ -35,6 +35,7 @@
     <!-- Language settings (resource manager)-->
     <parameter name="languages"   value="en,fr,ja"/>
     <parameter name="language"    value="en"/>
+    <parameter name="locale"      value="true"/>
     <parameter name="translators" value="%P_msg_%L.qm|%P_icons.qm|%P_images.qm"/>
   </section>
   <section name="splash" >
     <parameter name="CurveType"    value="1" />
     <parameter name="HorScaleMode" value="0" />
     <parameter name="LegendPos"    value="1" />
+    <parameter name="LegendSymbolType" value="0" />
     <parameter name="LegendFont"   value="Helvetic,12" />
     <parameter name="LegendFontColor"  value="0, 0, 0" />
     <parameter name="SelectedLegendFontColor"  value="255, 255, 255" />
index af04e4301ba4db3ca1868a2457f06aa5f4fb6459..306362bd5aad07ffd43610007a5495fcc209c468 100644 (file)
@@ -92,6 +92,11 @@ CEA/DEN, CEDRAT, EDF R&amp;D, LEG, PRINCIPIA R&amp;D, BUREAU VERITAS</translatio
     <message>
         <source>LANG_CHANGED</source>
         <translation>Application language has been changed.
+The changes will be applied on the next application session.</translation>
+    </message>
+    <message>
+        <source>LOCALE_CHANGED</source>
+        <translation>Application locale has been changed.
 The changes will be applied on the next application session.</translation>
     </message>
     <message>
@@ -590,6 +595,10 @@ The changes will be applied on the next application session.</translation>
         <source>PREF_CURRENT_LANGUAGE</source>
         <translation>Current language</translation>
     </message>
+    <message>
+        <source>PREF_CURRENT_LOCALE</source>
+        <translation>Use &quot;C&quot; locale</translation>
+    </message>
     <message>
         <source>PREF_GROUP_LOOK_AND_FEEL</source>
         <translation>Look and feel</translation>
@@ -670,6 +679,26 @@ The changes will be applied on the next application session.</translation>
         <source>PREF_GROUP_PLOT2DVIEWER</source>
         <translation>Plot 2D Viewer</translation>
     </message>
+    <message>
+        <source>PREF_GROUP_VIEWER</source>
+        <translation>Viewer</translation>
+    </message>
+    <message>
+        <source>PREF_GROUP_LEGEND</source>
+        <translation>Legend</translation>
+    </message>
+    <message>
+        <source>PREF_LEGEND_SYMBOL_TYPE</source>
+        <translation>Symbol type:</translation>
+    </message>
+    <message>
+        <source>PREF_MARKER_ABOVE_LINE</source>
+        <translation>Marker above line</translation>
+    </message>
+    <message>
+        <source>PREF_MARKER_ON_LINE</source>
+        <translation>Marker on line</translation>
+    </message>
     <message>
         <source>PREF_DEVIATION_COLOR</source>
         <translation>Deviation marker color</translation>
index 694b93bbd75b3756a9fcee23eca53e7ebcce46e5..e07ece124def1ebf94b7638c207522267086144d 100755 (executable)
@@ -596,7 +596,7 @@ Les modifications seront appliquées à la prochaine session.</translation>
     </message>
     <message>
         <source>PREF_SHOW_SPLASH</source>
-        <translation>Afficher l'écran de démarrage</translation>
+        <translation>Afficher l&apos;écran de démarrage</translation>
     </message>
     <message>
         <source>PREF_OPAQUE_RESIZE</source>
@@ -670,6 +670,26 @@ Les modifications seront appliquées à la prochaine session.</translation>
         <source>PREF_GROUP_PLOT2DVIEWER</source>
         <translation>Scène Plot2d</translation>
     </message>
+    <message>
+        <source>PREF_GROUP_VIEWER</source>
+        <translation>Scène</translation>
+    </message>
+    <message>
+        <source>PREF_GROUP_LEGEND</source>
+        <translation>Légende</translation>
+    </message>
+    <message>
+        <source>PREF_LEGEND_SYMBOL_TYPE</source>
+        <translation>Type de symbole:</translation>
+    </message>
+    <message>
+        <source>PREF_MARKER_ABOVE_LINE</source>
+        <translation>Marqueur dessus de la ligne</translation>
+    </message>
+    <message>
+        <source>PREF_MARKER_ON_LINE</source>
+        <translation>Marqueur sur la ligne</translation>
+    </message>
     <message>
         <source>PREF_DEVIATION_COLOR</source>
         <translation>Couleur des marqueurs de déviation</translation>
@@ -926,7 +946,7 @@ Le fichier n&apos;existe pas</translation>
     </message>
     <message>
         <source>XML_FILES_FILTER</source>
-        <translation type="unfinished">XML Files (*.xml)</translation>
+        <translation>Fichiers XML (*.xml)</translation>
     </message>
     <message>
         <source>CAPTION</source>
index 84a8893c043ffa2cd24b6ab9ae9c39b478016203..3253f1ea65fb2a4547bc6e7b834c221ed599b9ee 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!DOCTYPE TS>
-<TS>
+<TS version="2.0" language="ja" sourcelanguage="en">
   <context>
     <name>@default</name>
     <message>
@@ -9,14 +9,14 @@
     </message>
     <message>
       <source>ABOUT_COPYRIGHT</source>
-      <translation>Copyright (C) 2007-2014 CEA/DEN, EDF R&amp;D, OPEN CASCADE
+      <translation>Copyright (C) 2007-2013 CEA/DEN, EDF R&amp;D, OPEN CASCADE
 
 Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6,
 CEA/DEN, CEDRAT, EDF R&amp;D, LEG, PRINCIPIA R&amp;D, BUREAU VERITAS</translation>
     </message>
     <message>
       <source>ABOUT_CAPTION</source>
-      <translation>約%1</translation>
+      <translation>%1について</translation>
     </message>
     <message>
       <source>ABOUT_BASE</source>
@@ -72,7 +72,7 @@ CEA/DEN, CEDRAT, EDF R&amp;D, LEG, PRINCIPIA R&amp;D, BUREAU VERITAS</translatio
     </message>
     <message>
       <source>BROWSER_FORWARD</source>
-      <translation>前に進む</translation>
+      <translation>進む</translation>
     </message>
     <message>
       <source>BROWSER_FIND</source>
@@ -84,7 +84,7 @@ CEA/DEN, CEDRAT, EDF R&amp;D, LEG, PRINCIPIA R&amp;D, BUREAU VERITAS</translatio
     </message>
     <message>
       <source>BROWSER_FINDPREV</source>
-      <translation>前を検索(&amp;N)</translation>
+      <translation>前を検索(&amp;p)</translation>
     </message>
   </context>
   <context>
@@ -93,6 +93,11 @@ CEA/DEN, CEDRAT, EDF R&amp;D, LEG, PRINCIPIA R&amp;D, BUREAU VERITAS</translatio
       <source>LANG_CHANGED</source>
       <translation>アプリケーションの言語が変更されました。&lt;BR&gt;変更は、次のセッションに適用されます。</translation>
     </message>
+    <message>
+      <source>LOCALE_CHANGED</source>
+      <translation>アプリケーションの言語が変更されました。
+次回のセッションから有効になります。</translation>
+    </message>
     <message>
       <source>MEN_DESK_THEME</source>
       <translation>テーマ(&amp;h)</translation>
@@ -131,7 +136,7 @@ CEA/DEN, CEDRAT, EDF R&amp;D, LEG, PRINCIPIA R&amp;D, BUREAU VERITAS</translatio
     </message>
     <message>
       <source>PREF_MULTI_FILE</source>
-      <translation>è¤\87æ\95°ã\81®ã\83\95ã\82¡ã\82¤ã\83«保存</translation>
+      <translation>è¤\87æ\95°ã\83\95ã\82¡ã\82¤ã\83«ã\81®保存</translation>
     </message>
     <message>
       <source>MEN_DESK_PREFERENCES</source>
@@ -399,7 +404,7 @@ CEA/DEN, CEDRAT, EDF R&amp;D, LEG, PRINCIPIA R&amp;D, BUREAU VERITAS</translatio
     </message>
     <message>
       <source>PREF_AUTO_HIDE_SEARCH_TOOL</source>
-      <translation>自動的に隠す</translation>
+      <translation>自動非表示の有効化</translation>
     </message>
     <message>
       <source>PREF_OBJ_BROWSER_SETTINGS</source>
@@ -427,7 +432,7 @@ CEA/DEN, CEDRAT, EDF R&amp;D, LEG, PRINCIPIA R&amp;D, BUREAU VERITAS</translatio
     </message>
     <message>
       <source>PREF_MARKER_SIZE</source>
-      <translation>ã\83\9eã\83¼ã\82«ã\83¼ã\82µã\82¤ã\82º</translation>
+      <translation>ã\83\9eã\83¼ã\82«ã\83¼ã\81®ã\82µã\82¤ã\82º:</translation>
     </message>
     <message>
       <source>PREF_TAB_VIEWERS</source>
@@ -589,6 +594,10 @@ CEA/DEN, CEDRAT, EDF R&amp;D, LEG, PRINCIPIA R&amp;D, BUREAU VERITAS</translatio
       <source>PREF_CURRENT_LANGUAGE</source>
       <translation>現在の言語</translation>
     </message>
+    <message>
+      <source>PREF_CURRENT_LOCALE</source>
+      <translation>言語 "C" を使います</translation>
+    </message>
     <message>
       <source>PREF_GROUP_LOOK_AND_FEEL</source>
       <translation>外観</translation>
@@ -669,6 +678,26 @@ CEA/DEN, CEDRAT, EDF R&amp;D, LEG, PRINCIPIA R&amp;D, BUREAU VERITAS</translatio
       <source>PREF_GROUP_PLOT2DVIEWER</source>
       <translation>Plot 2D Viewer</translation>
     </message>
+    <message>
+      <source>PREF_GROUP_VIEWER</source>
+      <translation>ビューワ</translation>
+    </message>
+    <message>
+      <source>PREF_GROUP_LEGEND</source>
+      <translation>凡例</translation>
+    </message>
+    <message>
+      <source>PREF_LEGEND_SYMBOL_TYPE</source>
+      <translation>シンボルの型:</translation>
+    </message>
+    <message>
+      <source>PREF_MARKER_ABOVE_LINE</source>
+      <translation>線の上のマーカー</translation>
+    </message>
+    <message>
+      <source>PREF_MARKER_ON_LINE</source>
+      <translation>線上のマーカー</translation>
+    </message>
     <message>
       <source>PREF_DEVIATION_COLOR</source>
       <translation>偏差のマーカーの色</translation>
index 414cd530099405e60f952dd5cd655dd854fdb4bd..347f0ce0b5d0471511ff96cd43a7b9f6d37f03d6 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!DOCTYPE TS>
-<TS>
+<TS version="2.0" language="ja" sourcelanguage="en">
   <context>
     <name>LogWindow</name>
     <message>
index 23b53653a1aa39c97d7a1ec1535e7daa93c9eff0..40ee9ad4611b7746b5fe6d0a71b195eb4b0dac62 100644 (file)
-// Copyright (C) 2007-2014  CEA/DEN, EDF R&D, OPEN CASCADE\r
-//\r
-// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,\r
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS\r
-//\r
-// This library is free software; you can redistribute it and/or\r
-// modify it under the terms of the GNU Lesser General Public\r
-// License as published by the Free Software Foundation; either\r
-// version 2.1 of the License, or (at your option) any later version.\r
-//\r
-// This library is distributed in the hope that it will be useful,\r
-// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\r
-// Lesser General Public License for more details.\r
-//\r
-// You should have received a copy of the GNU Lesser General Public\r
-// License along with this library; if not, write to the Free Software\r
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA\r
-//\r
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
-//\r
-\r
-#include "OCCViewer_ClippingDlg.h"\r
-\r
-#include <QtxDoubleSpinBox.h>\r
-#include <QtxDoubleSpinSlider.h>\r
-#include <QtxIntSpinSlider.h>\r
-#include <QtxAction.h>\r
-\r
-#include "SUIT_Session.h"\r
-#include "SUIT_ViewWindow.h"\r
-#include "SUIT_ViewManager.h"\r
-#include "OCCViewer_ClipPlane.h"\r
-#include "OCCViewer_ViewWindow.h"\r
-#include "OCCViewer_ViewPort3d.h"\r
-#include "OCCViewer_ViewModel.h"\r
-#include "OCCViewer_ViewManager.h"\r
-#include "OCCViewer_ClipPlaneInteractor.h"\r
-\r
-#include <V3d_View.hxx>\r
-#include <Visual3d_View.hxx>\r
-#include <Geom_Plane.hxx>\r
-#include <Prs3d_Presentation.hxx>\r
-#include <AIS_ListIteratorOfListOfInteractive.hxx>\r
-#include <AIS_ListOfInteractive.hxx>\r
-#include <AIS_InteractiveObject.hxx>\r
-#include <AIS_InteractiveContext.hxx>\r
-#include <IntAna_IntConicQuad.hxx>\r
-#include <gp_Lin.hxx>\r
-#include <gp_Pln.hxx>\r
-#include <math.h>\r
-\r
-// QT Includes\r
-#include <QApplication>\r
-#include <QGroupBox>\r
-#include <QHBoxLayout>\r
-#include <QVBoxLayout>\r
-#include <QGridLayout>\r
-#include <QLabel>\r
-#include <QPushButton>\r
-#include <QComboBox>\r
-#include <QCheckBox>\r
-#include <QStackedLayout>\r
-#include <QSlider>\r
-#include <QMenu>\r
-\r
-/**********************************************************************************\r
- ************************        Internal functions        ************************\r
- *********************************************************************************/\r
-\r
-void getMinMaxFromContext( Handle(AIS_InteractiveContext) ic,\r
-                          double  theDefaultSize,\r
-                          double& theXMin,\r
-                          double& theYMin,\r
-                          double& theZMin,\r
-                          double& theXMax,\r
-                          double& theYMax,\r
-                          double& theZMax) {\r
-\r
-  double aXMin, aYMin, aZMin, aXMax, aYMax, aZMax;\r
-  aXMin = aYMin = aZMin = DBL_MAX;\r
-  aXMax = aYMax = aZMax = -DBL_MAX;\r
-  \r
-  bool isFound = false;\r
-  AIS_ListOfInteractive aList;\r
-  ic->DisplayedObjects( aList );\r
-  for ( AIS_ListIteratorOfListOfInteractive it( aList ); it.More(); it.Next() ) {\r
-    Handle(AIS_InteractiveObject) anObj = it.Value();\r
-    if ( !anObj.IsNull() && anObj->HasPresentation() &&\r
-         !anObj->IsKind( STANDARD_TYPE(AIS_Plane) ) ) {\r
-      Handle(Prs3d_Presentation) aPrs = anObj->Presentation();\r
-      if ( !aPrs->IsEmpty() && !aPrs->IsInfinite() ) {\r
-        isFound = true;\r
-        double xmin, ymin, zmin, xmax, ymax, zmax;\r
-        aPrs->MinMaxValues( xmin, ymin, zmin, xmax, ymax, zmax );\r
-        aXMin = qMin( aXMin, xmin );  aXMax = qMax( aXMax, xmax );\r
-        aYMin = qMin( aYMin, ymin );  aYMax = qMax( aYMax, ymax );\r
-        aZMin = qMin( aZMin, zmin );  aZMax = qMax( aZMax, zmax );\r
-      }\r
-    }\r
-  }\r
-\r
-  if(!isFound) {\r
-    if(theDefaultSize == 0.0)\r
-      theDefaultSize = 100.;\r
-    aXMin = aYMin = aZMin = -theDefaultSize;\r
-    aXMax = aYMax = aZMax = theDefaultSize;\r
-  }\r
-  theXMin = aXMin;theYMin = aYMin;theZMin = aZMin;\r
-  theXMax = aXMax;theYMax = aYMax;theZMax = aZMax;\r
-}\r
-\r
-/*!\r
-  Compute the point of bounding box and current clipping plane\r
- */\r
-void ComputeBoundsParam( const double theBounds[6],\r
-                         const double theDirection[3],\r
-                         double theMinPnt[3],\r
-                         double& theMaxBoundPrj,\r
-                         double& theMinBoundPrj )\r
-{\r
-  double aEnlargeBounds[6];\r
-\r
-  // Enlarge bounds in order to avoid conflicts of precision\r
-  for(int i = 0; i < 6; i += 2)\r
-  {\r
-    static double EPS = 1.0E-3;\r
-    double aDelta = (theBounds[i+1] - theBounds[i])*EPS;\r
-    aEnlargeBounds[i  ] = theBounds[i  ] - aDelta;\r
-    aEnlargeBounds[i+1] = theBounds[i+1] + aDelta;\r
-  }\r
-\r
-  double aBoundPoints[8][3] = { { aEnlargeBounds[0], aEnlargeBounds[2], aEnlargeBounds[4] },\r
-                                { aEnlargeBounds[1], aEnlargeBounds[2], aEnlargeBounds[4] },\r
-                                { aEnlargeBounds[0], aEnlargeBounds[3], aEnlargeBounds[4] },\r
-                                { aEnlargeBounds[1], aEnlargeBounds[3], aEnlargeBounds[4] },\r
-                                { aEnlargeBounds[0], aEnlargeBounds[2], aEnlargeBounds[5] },\r
-                                { aEnlargeBounds[1], aEnlargeBounds[2], aEnlargeBounds[5] },\r
-                                { aEnlargeBounds[0], aEnlargeBounds[3], aEnlargeBounds[5] },\r
-                                { aEnlargeBounds[1], aEnlargeBounds[3], aEnlargeBounds[5] } };\r
-\r
-  int aMaxId = 0;\r
-  theMaxBoundPrj = theDirection[0] * aBoundPoints[aMaxId][0] + theDirection[1] * aBoundPoints[aMaxId][1]\r
-                   + theDirection[2] * aBoundPoints[aMaxId][2];\r
-  theMinBoundPrj = theMaxBoundPrj;\r
-  for(int i = 1; i < 8; i++) {\r
-    double aTmp = theDirection[0] * aBoundPoints[i][0] + theDirection[1] * aBoundPoints[i][1]\r
-                  + theDirection[2] * aBoundPoints[i][2];\r
-    if(theMaxBoundPrj < aTmp) {\r
-      theMaxBoundPrj = aTmp;\r
-      aMaxId = i;\r
-    }\r
-    if(theMinBoundPrj > aTmp) {\r
-      theMinBoundPrj = aTmp;\r
-    }\r
-  }\r
-  double *aMinPnt = aBoundPoints[aMaxId];\r
-  theMinPnt[0] = aMinPnt[0];\r
-  theMinPnt[1] = aMinPnt[1];\r
-  theMinPnt[2] = aMinPnt[2];\r
-}\r
-\r
-/*!\r
-  Compute the position of current plane by distance\r
- */\r
-void DistanceToPosition( const double theBounds[6],\r
-                         const double theDirection[3],\r
-                         const double theDist,\r
-                         double thePos[3] )\r
-{\r
-  double aMaxBoundPrj, aMinBoundPrj, aMinPnt[3];\r
-  ComputeBoundsParam( theBounds, theDirection, aMinPnt, aMaxBoundPrj, aMinBoundPrj );\r
-  double aLength = (aMaxBoundPrj - aMinBoundPrj) * theDist;\r
-  thePos[0] = aMinPnt[0] - theDirection[0] * aLength;\r
-  thePos[1] = aMinPnt[1] - theDirection[1] * aLength;\r
-  thePos[2] = aMinPnt[2] - theDirection[2] * aLength;\r
-}\r
-\r
-/*!\r
-  Compute the parameters of clipping plane\r
- */\r
-bool ComputeClippingPlaneParameters( const Handle(AIS_InteractiveContext)& theIC,\r
-                                     const double theDefaultSize,\r
-                                     const double theNormal[3],\r
-                                     const double theDist,\r
-                                     double theOrigin[3] )\r
-{\r
-  double aBounds[6] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };\r
-\r
-  getMinMaxFromContext( theIC, theDefaultSize, aBounds[0], aBounds[2], aBounds[4], aBounds[1], aBounds[3], aBounds[5] );\r
-\r
-  DistanceToPosition( aBounds, theNormal, theDist, theOrigin );\r
-  return true;\r
-}\r
-\r
-/*!\r
-  \brief Converts relative plane parameters to absolute.\r
-  \param theIC [in] the interactive context.\r
-  \param theDefaultSize [in] the default trihedron size.\r
-  \param theDistance [in] the plane distance relative to minimum corner of model boundaries.\r
-  \param theDX [in] x component of plane direction.\r
-  \param theDY [in] y component of plane direction.\r
-  \param theDZ [in] z component of plane direction.\r
-  \param theX [out] x coordinate of plane origin.\r
-  \param theY [out] y coordinate of plane origin.\r
-  \param theZ [out] z coordinate of plane origin.\r
- */\r
-bool DistanceToXYZ ( const Handle(AIS_InteractiveContext)& theIC,\r
-                     const double theDefaultSize,\r
-                     const double theDistance,\r
-                     const double theDX,\r
-                     const double theDY,\r
-                     const double theDZ,\r
-                     double& theX,\r
-                     double& theY,\r
-                     double& theZ )\r
-{\r
-  double aNormal[3] = { theDX, theDY, theDZ };\r
-  double anOrigin[3] = { 0.0, 0.0, 0.0 };\r
-\r
-  bool anIsOk = ComputeClippingPlaneParameters( theIC, theDefaultSize, aNormal, theDistance, anOrigin );\r
-\r
-  if( !anIsOk )\r
-  {\r
-    return false;\r
-  }\r
-\r
-  theX = anOrigin[0];\r
-  theY = anOrigin[1];\r
-  theZ = anOrigin[2];\r
-\r
-  return true;\r
-}\r
-\r
-/*!\r
-  \brief Converts absolute position and direction to bounding box distance.\r
-  \param theIC [in] the interactive context.\r
-  \param theDefaultSize [in] the default trihedron size.\r
-  \param theX [in] x coordinate of plane origin.\r
-  \param theY [in] y coordinate of plane origin.\r
-  \param theZ [in] z coordinate of plane origin.\r
-  \param theDX [in] x component of plane direction.\r
-  \param theDY [in] y component of plane direction.\r
-  \param theDZ [in] z component of plane direction.\r
-  \param theDistance [out] the plane distance relative to minimum corner of model boundaries.\r
- */\r
-void XYZToDistance ( const Handle(AIS_InteractiveContext)& theIC,\r
-                     const double theDefaultSize,\r
-                     const double theX,\r
-                     const double theY,\r
-                     const double theZ,\r
-                     const double theDX,\r
-                     const double theDY,\r
-                     const double theDZ,\r
-                     double& theDistance )\r
-{\r
-  gp_Pnt aPlaneP( theX, theY, theZ );\r
-  gp_Dir aPlaneN( theDX, theDY, theDZ );\r
-\r
-  double aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;\r
-\r
-  getMinMaxFromContext( theIC, theDefaultSize, aXmin, aYmin, aZmin, aXmax, aYmax, aZmax );\r
-\r
-  Bnd_Box aMinMax;\r
-  aMinMax.Update( aXmin, aYmin, aZmin, aXmax, aYmax, aZmax );\r
-\r
-  gp_Trsf aRelativeTransform;\r
-  aRelativeTransform.SetTransformation( gp_Ax3(), gp_Ax3( aPlaneP, aPlaneN ) );\r
-  Bnd_Box aRelativeBounds = aMinMax.Transformed( aRelativeTransform );\r
-\r
-  aRelativeBounds.Get( aXmin, aYmin, aZmin, aXmax, aYmax, aZmax );\r
-\r
-  double aLength   = aZmax - aZmin;\r
-  double aDistance = aZmax;\r
-\r
-  double aRelativeDistance = aLength > 0.01 ? aDistance / aLength : 0.0;\r
-  aRelativeDistance = qMin( aRelativeDistance, aLength );\r
-  aRelativeDistance = qMax( aRelativeDistance, 0.0 );\r
-  theDistance = aRelativeDistance;\r
-}\r
-\r
-/*!\r
-  Compute clipping plane size base point and normal\r
- */\r
-\r
-void clipPlaneParams(OCCViewer_ClipPlane& theClipPlane, Handle(AIS_InteractiveContext) theContext,\r
-                     double& theSize, gp_Pnt& theBasePnt, gp_Dir& theNormal, double defaultSize) {\r
-  double aXMin, aYMin, aZMin, aXMax, aYMax, aZMax;\r
-  aXMin = aYMin = aZMin = DBL_MAX;\r
-  aXMax = aYMax = aZMax = -DBL_MAX;\r
-  \r
-  getMinMaxFromContext(theContext,defaultSize,aXMin, aYMin, aZMin, aXMax, aYMax, aZMax);\r
-  double aSize = 50;\r
-\r
-  double aNormalX = 0.0;\r
-  double aNormalY = 0.0;\r
-  double aNormalZ = 0.0;\r
-  theClipPlane.OrientationToXYZ( aNormalX, aNormalY, aNormalZ );\r
-  gp_Pnt aBasePnt( theClipPlane.X, theClipPlane.Y, theClipPlane.Z );\r
-  gp_Dir aNormal( aNormalX, aNormalY, aNormalZ );\r
-\r
-  // compute clipping plane size\r
-  gp_Pnt aCenter = gp_Pnt( ( aXMin + aXMax ) / 2, ( aYMin + aYMax ) / 2, ( aZMin + aZMax ) / 2 );\r
-  double aDiag = aCenter.Distance( gp_Pnt( aXMax, aYMax, aZMax ) )*2;\r
-  aSize = aDiag * 1.1;\r
-  \r
-  // compute clipping plane center ( redefine the base point )\r
-  IntAna_IntConicQuad intersector = IntAna_IntConicQuad();\r
-  \r
-  intersector.Perform( gp_Lin( aCenter, aNormal), gp_Pln( aBasePnt, aNormal), Precision::Confusion() );\r
-\r
-  if ( intersector.IsDone() && intersector.NbPoints() == 1 )\r
-    aBasePnt = intersector.Point( 1 );\r
-  \r
-  theSize = aSize;\r
-  theBasePnt = aBasePnt;\r
-  theNormal = aNormal;\r
-}\r
-\r
-\r
-/*********************************************************************************\r
- *********************      class OCCViewer_ClippingDlg      *********************\r
- *********************************************************************************/\r
-/*!\r
-  Constructor\r
-  \param view - view window\r
-  \param parent - parent widget\r
-*/\r
-OCCViewer_ClippingDlg::OCCViewer_ClippingDlg(OCCViewer_ViewWindow* parent , OCCViewer_Viewer* model)\r
-  : QDialog( parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint )\r
-{\r
-  setObjectName( "OCCViewer_ClippingDlg" );\r
-  setModal( false );\r
-\r
-  setWindowTitle( tr( "Clipping" ) );\r
-\r
-  setAttribute (Qt::WA_DeleteOnClose, true);\r
-  \r
-  QVBoxLayout* topLayout = new QVBoxLayout( this );\r
-  topLayout->setMargin( 11 ); topLayout->setSpacing( 6 );\r
-\r
-  /***************************************************************/\r
-  // Controls for selecting, creating, deleting planes\r
-  QGroupBox* GroupPlanes = new QGroupBox( tr("CLIPPING_PLANES"), this );\r
-  QHBoxLayout* GroupPlanesLayout = new QHBoxLayout( GroupPlanes );\r
-  ComboBoxPlanes = new QComboBox( GroupPlanes );\r
-  isActivePlane = new QCheckBox( tr("IS_ACTIVE_PLANE"), this );\r
-  buttonNew = new QPushButton( tr("BTN_NEW"), GroupPlanes );\r
-  buttonDelete = new QPushButton( tr("BTN_DELETE"), GroupPlanes );\r
-  buttonDisableAll = new QPushButton( tr("BTN_DISABLE_ALL"), GroupPlanes );\r
-  MenuMode = new QMenu( "MenuMode", buttonNew );\r
-  MenuMode->addAction( tr( "ABSOLUTE" ), this, SLOT( onModeAbsolute() ) );\r
-  MenuMode->addAction( tr( "RELATIVE" ), this, SLOT( onModeRelative() ) );\r
-  buttonNew->setMenu( MenuMode );\r
-\r
-  GroupPlanesLayout->addWidget( ComboBoxPlanes );\r
-  GroupPlanesLayout->addWidget( isActivePlane );\r
-  GroupPlanesLayout->addWidget( buttonNew );\r
-  GroupPlanesLayout->addWidget( buttonDelete );\r
-  GroupPlanesLayout->addWidget( buttonDisableAll );\r
-\r
-  ModeStackedLayout = new QStackedLayout();\r
-\r
-  /**********************   Mode Absolute   **********************/\r
-  /* Controls for absolute mode of clipping plane:\r
-     X, Y, Z - coordinates of the intersection of cutting plane and the three axes\r
-     Dx, Dy, Dz - components of normal to the cutting plane\r
-     Orientation - direction of cutting plane\r
-   */\r
-  const double min = -1e+7;\r
-  const double max =  1e+7;\r
-  const double step = 5;\r
-  const int precision = -7;\r
-\r
-  // Croup Point\r
-  QGroupBox* GroupAbsolutePoint = new QGroupBox( this );\r
-  GroupAbsolutePoint->setObjectName( "GroupPoint" );\r
-  GroupAbsolutePoint->setTitle( tr("BASE_POINT") );\r
-  QGridLayout* GroupPointLayout = new QGridLayout( GroupAbsolutePoint );\r
-  GroupPointLayout->setAlignment( Qt::AlignTop );\r
-  GroupPointLayout->setSpacing( 6 ); GroupPointLayout->setMargin( 11 );\r
-\r
-  TextLabelX = new QLabel( GroupAbsolutePoint );\r
-  TextLabelX->setObjectName( "TextLabelX" );\r
-  TextLabelX->setText( tr("X:") );\r
-  GroupPointLayout->addWidget( TextLabelX, 0, 0 );\r
-  \r
-  SpinBox_X = new QtxDoubleSpinBox( min, max, step, GroupAbsolutePoint );\r
-  SpinBox_X->setObjectName("SpinBox_X" );\r
-  SpinBox_X->setPrecision( precision );\r
-  GroupPointLayout->addWidget( SpinBox_X, 0, 1 );\r
-\r
-  TextLabelY = new QLabel( GroupAbsolutePoint );\r
-  TextLabelY->setObjectName( "TextLabelY" );\r
-  TextLabelY->setText( tr("Y:") );\r
-  GroupPointLayout->addWidget( TextLabelY, 0, 2 );\r
-\r
-  SpinBox_Y = new QtxDoubleSpinBox( min, max, step, GroupAbsolutePoint );\r
-  SpinBox_Y->setObjectName("SpinBox_Y" );\r
-  SpinBox_Y->setPrecision( precision );\r
-  GroupPointLayout->addWidget( SpinBox_Y, 0, 3 );\r
-\r
-  TextLabelZ = new QLabel( GroupAbsolutePoint );\r
-  TextLabelZ->setObjectName( "TextLabelZ" );\r
-  TextLabelZ->setText( tr("Z:") );\r
-  GroupPointLayout->addWidget( TextLabelZ, 0, 4 );\r
-\r
-  SpinBox_Z = new QtxDoubleSpinBox( min, max, step, GroupAbsolutePoint );\r
-  SpinBox_Z->setObjectName("SpinBox_Z" );\r
-  SpinBox_Z->setPrecision( precision );\r
-  GroupPointLayout->addWidget( SpinBox_Z, 0, 5 );\r
-\r
-  resetButton  = new QPushButton( GroupAbsolutePoint );\r
-  resetButton->setObjectName( "resetButton" );\r
-  resetButton->setText( tr( "RESET"  ) );\r
-  GroupPointLayout->addWidget( resetButton, 0, 6 );\r
-\r
-  // Group Direction\r
-  GroupAbsoluteDirection = new QGroupBox( this );\r
-  GroupAbsoluteDirection->setObjectName( "GroupDirection" );\r
-  GroupAbsoluteDirection->setTitle( tr("DIRECTION") );\r
-  QGridLayout* GroupDirectionLayout = new QGridLayout( GroupAbsoluteDirection );\r
-  GroupDirectionLayout->setAlignment( Qt::AlignTop );\r
-  GroupDirectionLayout->setSpacing( 6 );\r
-  GroupDirectionLayout->setMargin( 11 );\r
-  \r
-  TextLabelDx = new QLabel( GroupAbsoluteDirection );\r
-  TextLabelDx->setObjectName( "TextLabelDx" );\r
-  TextLabelDx->setText( tr("Dx:") );\r
-  GroupDirectionLayout->addWidget( TextLabelDx, 0, 0 );\r
-  \r
-  SpinBox_Dx = new QtxDoubleSpinBox( min, max, step, GroupAbsoluteDirection );\r
-  SpinBox_Dx->setObjectName("SpinBox_Dx" );\r
-  SpinBox_Dx->setPrecision( precision );\r
-  GroupDirectionLayout->addWidget( SpinBox_Dx, 0, 1 );\r
-\r
-  TextLabelDy = new QLabel( GroupAbsoluteDirection );\r
-  TextLabelDy->setObjectName( "TextLabelDy" );\r
-  TextLabelDy->setText( tr("Dy:") );\r
-  GroupDirectionLayout->addWidget( TextLabelDy, 0, 2 );\r
-  \r
-  SpinBox_Dy = new QtxDoubleSpinBox( min, max, step, GroupAbsoluteDirection );\r
-  SpinBox_Dy->setObjectName("SpinBox_Dy" );\r
-  SpinBox_Dy->setPrecision( precision );\r
-  GroupDirectionLayout->addWidget( SpinBox_Dy, 0, 3 );\r
-\r
-  TextLabelDz = new QLabel( GroupAbsoluteDirection );\r
-  TextLabelDz->setObjectName( "TextLabelDz" );\r
-  TextLabelDz->setText( tr("Dz:") );\r
-  GroupDirectionLayout->addWidget( TextLabelDz, 0, 4 );\r
-  \r
-  SpinBox_Dz = new QtxDoubleSpinBox( min, max, step, GroupAbsoluteDirection );\r
-  SpinBox_Dz->setObjectName("SpinBox_Dz" );\r
-  SpinBox_Dz->setPrecision( precision );\r
-  GroupDirectionLayout->addWidget( SpinBox_Dz, 0, 5 );\r
-\r
-  invertButton  = new QPushButton( GroupAbsoluteDirection );\r
-  invertButton->setObjectName( "invertButton" );\r
-  invertButton->setText( tr( "INVERT"  ) );\r
-  GroupDirectionLayout->addWidget( invertButton, 0, 6 );\r
\r
-  CBAbsoluteOrientation = new QComboBox( GroupAbsoluteDirection );\r
-  CBAbsoluteOrientation->setObjectName( "AbsoluteOrientation" );\r
-  CBAbsoluteOrientation->insertItem( CBAbsoluteOrientation->count(), tr( "CUSTOM" ) );\r
-  CBAbsoluteOrientation->insertItem( CBAbsoluteOrientation->count(), tr( "||X-Y" ) );\r
-  CBAbsoluteOrientation->insertItem( CBAbsoluteOrientation->count(), tr( "||Y-Z" ) );\r
-  CBAbsoluteOrientation->insertItem( CBAbsoluteOrientation->count(), tr( "||Z-X" ) );\r
-  GroupDirectionLayout->addWidget( CBAbsoluteOrientation, 1, 0, 1, 6 );\r
-\r
-  QVBoxLayout* ModeActiveLayout = new QVBoxLayout();\r
-  ModeActiveLayout->setMargin( 11 ); ModeActiveLayout->setSpacing( 6 );\r
-  ModeActiveLayout->addWidget( GroupAbsolutePoint );\r
-  ModeActiveLayout->addWidget( GroupAbsoluteDirection );\r
-\r
-  QWidget* ModeActiveWidget = new QWidget( this );\r
-  ModeActiveWidget->setLayout( ModeActiveLayout );\r
-\r
-  /**********************   Mode Relative   **********************/\r
-  /* Controls for relative mode of clipping plane:\r
-     Distance - Value from 0 to 1.\r
-     Specifies the distance from the minimum value in a given direction of bounding box to the current position\r
-     Rotation1, Rotation2 - turn angles of cutting plane in given directions\r
-     Orientation - direction of cutting plane\r
-   */\r
-  QGroupBox* GroupParameters = new QGroupBox( tr("PARAMETERS"), this );\r
-  QGridLayout* GroupParametersLayout = new QGridLayout( GroupParameters );\r
-  GroupParametersLayout->setMargin( 11 ); GroupParametersLayout->setSpacing( 6 );\r
-\r
-  TextLabelOrientation = new QLabel( tr("ORIENTATION"), GroupParameters);\r
-  TextLabelOrientation->setObjectName( "TextLabelOrientation" );\r
-  GroupParametersLayout->addWidget( TextLabelOrientation, 0, 0 );\r
-\r
-  CBRelativeOrientation = new QComboBox(GroupParameters);\r
-  CBRelativeOrientation->setObjectName( "RelativeOrientation" );\r
-  CBRelativeOrientation->addItem( tr("ALONG_XY") );\r
-  CBRelativeOrientation->addItem( tr("ALONG_YZ") );\r
-  CBRelativeOrientation->addItem( tr("ALONG_ZX") );\r
-  GroupParametersLayout->addWidget( CBRelativeOrientation, 0, 1 );\r
-\r
-  TextLabelDistance = new QLabel( tr("DISTANCE"), GroupParameters );\r
-  TextLabelDistance->setObjectName( "TextLabelDistance" );\r
-  GroupParametersLayout->addWidget( TextLabelDistance, 1, 0 );\r
-  \r
-  SpinSliderDistance = new QtxDoubleSpinSlider( 0., 1., 0.01, GroupParameters );\r
-  SpinSliderDistance->setObjectName( "SpinSliderDistance" );\r
-  SpinSliderDistance->setPrecision( precision );\r
-  QFont fnt = SpinSliderDistance->font(); fnt.setBold( true ); SpinSliderDistance->setFont( fnt );\r
-  GroupParametersLayout->addWidget( SpinSliderDistance, 1, 1 );\r
-\r
-  QString aUnitRot = "\xB0";\r
-\r
-  TextLabelRotation1 = new QLabel( tr("ROTATION_AROUND_X_Y2Z"), GroupParameters );\r
-  TextLabelRotation1->setObjectName( "TextLabelRotation1" );\r
-  GroupParametersLayout->addWidget( TextLabelRotation1, 2, 0 );\r
-  \r
-  SpinSliderRotation1 = new QtxIntSpinSlider( -180, 180, 1, GroupParameters );\r
-  SpinSliderRotation1->setObjectName( "SpinSliderRotation1" );\r
-  SpinSliderRotation1->setUnit( aUnitRot );\r
-  SpinSliderRotation1->setFont( fnt );\r
-  GroupParametersLayout->addWidget( SpinSliderRotation1, 2, 1 );\r
-\r
-  TextLabelRotation2 = new QLabel(tr("ROTATION_AROUND_Y_X2Z"), GroupParameters);\r
-  TextLabelRotation2->setObjectName( "TextLabelRotation2" );\r
-  TextLabelRotation2->setObjectName( "TextLabelRotation2" );\r
-  GroupParametersLayout->addWidget( TextLabelRotation2, 3, 0 );\r
-\r
-  SpinSliderRotation2 = new QtxIntSpinSlider( -180, 180, 1, GroupParameters );\r
-  SpinSliderRotation2->setObjectName( "SpinSliderRotation2" );\r
-  SpinSliderRotation2->setUnit( aUnitRot );\r
-  SpinSliderRotation2->setFont( fnt );\r
-  GroupParametersLayout->addWidget( SpinSliderRotation2, 3, 1 );\r
-\r
-  /***************************************************************/\r
-  QGroupBox* CheckBoxWidget = new QGroupBox( this );\r
-  QHBoxLayout* CheckBoxLayout = new QHBoxLayout( CheckBoxWidget );\r
-  \r
-  PreviewCheckBox = new QCheckBox( tr("PREVIEW"), CheckBoxWidget );\r
-  PreviewCheckBox->setObjectName( "PreviewCheckBox" );\r
-  PreviewCheckBox->setChecked( true );\r
-  CheckBoxLayout->addWidget( PreviewCheckBox, 0, Qt::AlignCenter );\r
-  \r
-  AutoApplyCheckBox = new QCheckBox( tr("AUTO_APPLY"), CheckBoxWidget );\r
-  AutoApplyCheckBox->setObjectName( "AutoApplyCheckBox" );\r
-  CheckBoxLayout->addWidget( AutoApplyCheckBox, 0, Qt::AlignCenter );\r
-\r
-  /***************************************************************/\r
-  QGroupBox* GroupButtons = new QGroupBox( this );\r
-  QHBoxLayout* GroupButtonsLayout = new QHBoxLayout( GroupButtons );\r
-  GroupButtonsLayout->setAlignment( Qt::AlignTop );\r
-  GroupButtonsLayout->setMargin( 11 ); GroupButtonsLayout->setSpacing( 6 );\r
-  \r
-  buttonOk = new QPushButton( GroupButtons );\r
-  buttonOk->setObjectName( "buttonOk" );\r
-  buttonOk->setText( tr( "BUT_APPLY_AND_CLOSE"  ) );\r
-  buttonOk->setAutoDefault( TRUE );\r
-  buttonOk->setDefault( TRUE );\r
-  GroupButtonsLayout->addWidget( buttonOk );\r
-\r
-  buttonApply = new QPushButton( GroupButtons );\r
-  buttonApply->setObjectName( "buttonApply" );\r
-  buttonApply->setText( tr( "BUT_APPLY"  ) );\r
-  buttonApply->setAutoDefault( TRUE );\r
-  buttonApply->setDefault( TRUE );\r
-  GroupButtonsLayout->addWidget( buttonApply );\r
-\r
-  GroupButtonsLayout->addStretch();\r
-  \r
-  buttonClose = new QPushButton( GroupButtons );\r
-  buttonClose->setObjectName( "buttonClose" );\r
-  buttonClose->setText( tr( "BUT_CLOSE"  ) );\r
-  buttonClose->setAutoDefault( TRUE );\r
-  GroupButtonsLayout->addWidget( buttonClose );\r
-\r
-  QPushButton* buttonHelp = new QPushButton( tr( "SMESH_BUT_HELP" ), GroupButtons );\r
-  buttonHelp->setAutoDefault( TRUE );\r
-  GroupButtonsLayout->addWidget( buttonHelp );\r
-\r
-  /***************************************************************/\r
-  ModeStackedLayout->addWidget( ModeActiveWidget );\r
-  ModeStackedLayout->addWidget( GroupParameters );\r
-\r
-  topLayout->addWidget( GroupPlanes );\r
-  topLayout->addLayout( ModeStackedLayout );\r
-  topLayout->addWidget( CheckBoxWidget );\r
-  topLayout->addWidget( GroupButtons );\r
-\r
-  this->setLayout( topLayout );\r
-\r
-  // Initializations\r
-  initParam();\r
-\r
-  // Signals and slots connections\r
-  connect( ComboBoxPlanes, SIGNAL( activated( int ) ), this, SLOT( onSelectPlane( int ) ) );\r
-  connect( isActivePlane,  SIGNAL ( toggled ( bool ) ),  this, SLOT( onValueChanged() ) );\r
-  connect( buttonNew, SIGNAL( clicked() ), buttonNew, SLOT( showMenu() ) );\r
-  connect( buttonDelete, SIGNAL( clicked() ), this, SLOT( ClickOnDelete() ) );\r
-  connect( buttonDisableAll, SIGNAL( clicked() ), this, SLOT( ClickOnDisableAll() ) );\r
-\r
-  connect( resetButton,  SIGNAL (clicked() ), this, SLOT( onReset() ) );\r
-  connect( invertButton, SIGNAL (clicked() ), this, SLOT( onInvert() ) ) ;\r
-  connect( SpinBox_X,  SIGNAL ( valueChanged( double ) ),  this, SLOT( onValueChanged() ) );\r
-  connect( SpinBox_Y,  SIGNAL ( valueChanged( double ) ),  this, SLOT( onValueChanged() ) );\r
-  connect( SpinBox_Z,  SIGNAL ( valueChanged( double ) ),  this, SLOT( onValueChanged() ) );\r
-  connect( SpinBox_Dx, SIGNAL ( valueChanged( double ) ),  this, SLOT( onValueChanged() ) );\r
-  connect( SpinBox_Dy, SIGNAL ( valueChanged( double ) ),  this, SLOT( onValueChanged() ) );\r
-  connect( SpinBox_Dz, SIGNAL ( valueChanged( double ) ),  this, SLOT( onValueChanged() ) );\r
-  connect( CBAbsoluteOrientation, SIGNAL ( activated ( int ) ), this, SLOT( onOrientationAbsoluteChanged( int ) ) ) ;\r
-\r
-  connect( CBRelativeOrientation, SIGNAL( activated( int ) ), this, SLOT( onOrientationRelativeChanged( int ) ) );\r
-  connect( SpinSliderDistance, SIGNAL( valueChanged( double ) ),  this, SLOT( onValueChanged() ) );\r
-  connect( SpinSliderRotation1, SIGNAL( valueChanged( int ) ), this, SLOT( onValueChanged() ) );\r
-  connect( SpinSliderRotation2, SIGNAL( valueChanged( int ) ), this, SLOT( onValueChanged() ) );\r
-\r
-  connect( PreviewCheckBox, SIGNAL ( toggled ( bool ) ), this, SLOT( onPreview( bool ) ) ) ;\r
-  connect( AutoApplyCheckBox, SIGNAL ( toggled( bool ) ), this, SLOT( onAutoApply( bool ) ) );\r
-  \r
-  connect( buttonClose, SIGNAL( clicked() ), this, SLOT( ClickOnClose() ) ) ;\r
-  connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );\r
-  connect( buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );\r
-  connect( buttonHelp, SIGNAL( clicked() ), this, SLOT( ClickOnHelp() ) );\r
-\r
-  myBusy = false;\r
-  myIsSelectPlane = false;\r
-  myIsPlaneCreation = false;\r
-  myIsUpdatingControls = false;\r
-  myModel = model;\r
-\r
-  myModel->getViewer3d()->InitActiveViews();\r
-\r
-  OCCViewer_ViewManager* aViewMgr = (OCCViewer_ViewManager*) myModel->getViewManager();\r
-  myInteractor = new OCCViewer_ClipPlaneInteractor( aViewMgr, this );\r
-  connect( myInteractor, SIGNAL( planeClicked( const Handle_AIS_Plane& ) ), SLOT( onPlaneClicked( const Handle_AIS_Plane& ) ) );\r
-  connect( myInteractor, SIGNAL( planeDragged( const Handle_AIS_Plane& ) ), SLOT( onPlaneDragged( const Handle_AIS_Plane& ) ) );\r
-\r
-  myLocalPlanes = myModel->getClipPlanes();\r
-  synchronize();\r
-}\r
-\r
-/*!\r
-  Destructor\r
-  Destroys the object and frees any allocated resources\r
-*/\r
-OCCViewer_ClippingDlg::~OCCViewer_ClippingDlg()\r
-{\r
-  myLocalPlanes.clear();\r
-}\r
-\r
-/*!\r
-  Custom handling of close event: erases preview\r
-*/\r
-void OCCViewer_ClippingDlg::closeEvent( QCloseEvent* e )\r
-{\r
-  erasePreview();\r
-  QDialog::closeEvent( e );\r
-  OCCViewer_ViewWindow* v = qobject_cast<OCCViewer_ViewWindow*>(parent());\r
-  if(v)\r
-    v->onClipping(false);\r
-}\r
-\r
-/*!\r
-  Custom handling of show event: displays preview\r
-*/\r
-void OCCViewer_ClippingDlg::showEvent( QShowEvent* e )\r
-{\r
-  QDialog::showEvent( e );\r
-  onPreview( PreviewCheckBox->isChecked() );\r
-}\r
-\r
-/*!\r
-  Custom handling of hide event: erases preview\r
-*/\r
-void OCCViewer_ClippingDlg::hideEvent( QHideEvent* e )\r
-{\r
-  erasePreview();\r
-  QDialog::hideEvent( e );\r
-  OCCViewer_ViewWindow* v = qobject_cast<OCCViewer_ViewWindow*>(parent());\r
-  if(v)\r
-    v->onClipping(false);\r
-\r
-}\r
-\r
-/*!\r
-  Initialization of initial values of widgets\r
-*/\r
-void OCCViewer_ClippingDlg::initParam()\r
-{\r
-  SpinBox_X->setValue( 0.0 );\r
-  SpinBox_Y->setValue( 0.0 );\r
-  SpinBox_Z->setValue( 0.0 );\r
-\r
-  SpinBox_Dx->setValue( 1.0 );\r
-  SpinBox_Dy->setValue( 1.0 );\r
-  SpinBox_Dz->setValue( 1.0 );\r
-\r
-  CBAbsoluteOrientation->setCurrentIndex(0);\r
-\r
-  SpinSliderDistance->setValue( 0.5 );\r
-  SpinSliderRotation1->setValue( 0 );\r
-  SpinSliderRotation2->setValue( 0 );\r
-  CBRelativeOrientation->setCurrentIndex( 0 );\r
-\r
-  isActivePlane->setChecked( true );\r
-}\r
-\r
-/*!\r
-  Set plane parameters from widgets.\r
-*/\r
-void OCCViewer_ClippingDlg::setPlaneParam( OCCViewer_ClipPlane& thePlane )\r
-{\r
-  OCCViewer_ClipPlane::PlaneMode aMode = currentPlaneMode();\r
-\r
-  thePlane.Mode = aMode;\r
-\r
-  if ( aMode == OCCViewer_ClipPlane::Absolute )\r
-  {\r
-    if( qFuzzyIsNull( SpinBox_Dx->value() ) && \r
-        qFuzzyIsNull( SpinBox_Dy->value() ) && \r
-        qFuzzyIsNull( SpinBox_Dz->value() ) ) {\r
-      return;\r
-    }\r
-  }\r
-\r
-  thePlane.OrientationType = (aMode == OCCViewer_ClipPlane::Absolute)\r
-    ? CBAbsoluteOrientation->currentIndex()\r
-    : CBRelativeOrientation->currentIndex();\r
-\r
-  // Get XYZ, DXYZ\r
-  if ( aMode == OCCViewer_ClipPlane::Absolute )\r
-  {\r
-    if ( thePlane.OrientationType == OCCViewer_ClipPlane::AbsoluteCustom )\r
-    {\r
-      thePlane.AbsoluteOrientation.Dx = SpinBox_Dx->value();\r
-      thePlane.AbsoluteOrientation.Dy = SpinBox_Dy->value();\r
-      thePlane.AbsoluteOrientation.Dz = SpinBox_Dz->value();\r
-    }\r
-    else\r
-    {\r
-      thePlane.AbsoluteOrientation.IsInvert = SpinBox_Dx->value() < 0.0\r
-                                           || SpinBox_Dy->value() < 0.0\r
-                                           || SpinBox_Dz->value() < 0.0;\r
-    }\r
-\r
-    thePlane.X = SpinBox_X->value();\r
-    thePlane.Y = SpinBox_Y->value();\r
-    thePlane.Z = SpinBox_Z->value();\r
-  }\r
-  else\r
-  {\r
-    thePlane.RelativeOrientation.Rotation1 = SpinSliderRotation1->value();\r
-    thePlane.RelativeOrientation.Rotation2 = SpinSliderRotation2->value();\r
-\r
-    double aPlaneDx = 0.0;\r
-    double aPlaneDy = 0.0;\r
-    double aPlaneDz = 0.0;\r
-    double aX = 0.0;\r
-    double aY = 0.0;\r
-    double aZ = 0.0;\r
-\r
-    OCCViewer_ClipPlane::RelativeToDXYZ( thePlane.OrientationType,\r
-                                         thePlane.RelativeOrientation.Rotation1,\r
-                                         thePlane.RelativeOrientation.Rotation2,\r
-                                         aPlaneDx, aPlaneDy, aPlaneDz );\r
-\r
-    DistanceToXYZ( myModel->getAISContext(),\r
-                   myModel->trihedronSize(),\r
-                   SpinSliderDistance->value(),\r
-                   aPlaneDx, aPlaneDy, aPlaneDz,\r
-                   aX, aY, aZ );\r
-\r
-    thePlane.X = aX;\r
-    thePlane.Y = aY;\r
-    thePlane.Z = aZ;\r
-  }\r
-\r
-  thePlane.IsOn = isActivePlane->isChecked();\r
-}\r
-\r
-/*!\r
-  Synchronize dialog's widgets with data\r
-*/\r
-void OCCViewer_ClippingDlg::synchronize()\r
-{\r
-  ComboBoxPlanes->clear();\r
-  int aNbPlanesAbsolute = myLocalPlanes.size();\r
-\r
-  QString aName;\r
-  for(int i = 1; i<=aNbPlanesAbsolute; i++ ) {\r
-    aName = QString("Plane %1").arg(i);\r
-    ComboBoxPlanes->addItem( aName );\r
-  }\r
-\r
-  int aPos = ComboBoxPlanes->count() - 1;\r
-  ComboBoxPlanes->setCurrentIndex( aPos );\r
-\r
-  bool anIsControlsEnable = ( aPos >= 0 );\r
-  if ( anIsControlsEnable ) {\r
-    onSelectPlane( aPos );\r
-  }\r
-  else {\r
-    ComboBoxPlanes->addItem( tr( "NO_PLANES" ) );\r
-    initParam();\r
-  }\r
-  if ( currentPlaneMode() == OCCViewer_ClipPlane::Absolute )\r
-  {\r
-    SpinBox_X->setEnabled( anIsControlsEnable );\r
-    SpinBox_Y->setEnabled( anIsControlsEnable );\r
-    SpinBox_Z->setEnabled( anIsControlsEnable );\r
-    SpinBox_Dx->setEnabled( anIsControlsEnable );\r
-    SpinBox_Dy->setEnabled( anIsControlsEnable );\r
-    SpinBox_Dz->setEnabled( anIsControlsEnable );\r
-    CBAbsoluteOrientation->setEnabled( anIsControlsEnable );\r
-    invertButton->setEnabled( anIsControlsEnable );\r
-    resetButton->setEnabled( anIsControlsEnable );\r
-  }\r
-  else if ( currentPlaneMode() == OCCViewer_ClipPlane::Relative )\r
-  {\r
-    CBRelativeOrientation->setEnabled( anIsControlsEnable );\r
-    SpinSliderDistance->setEnabled( anIsControlsEnable );\r
-    SpinSliderRotation1->setEnabled( anIsControlsEnable );\r
-    SpinSliderRotation2->setEnabled( anIsControlsEnable );\r
-    isActivePlane->setEnabled( anIsControlsEnable );\r
-  }\r
-  isActivePlane->setEnabled( anIsControlsEnable );\r
-}\r
-\r
-/*!\r
-  Displays preview of clipping plane\r
-*/\r
-void OCCViewer_ClippingDlg::displayPreview()\r
-{\r
-  if ( myBusy || !isValid() || !myModel)\r
-    return;\r
-\r
-  Handle(AIS_InteractiveContext) ic = myModel->getAISContext();\r
-  \r
-  int aCurPlaneIndex = ComboBoxPlanes->currentIndex();\r
-\r
-  for ( int i=0; i < clipPlanesCount(); i++ ) {\r
-    OCCViewer_ClipPlane& aClipPlane = getClipPlane(i);\r
-    if ( aClipPlane.IsOn ) {\r
-      Handle(AIS_Plane) myPreviewPlane;\r
-      double aSize;\r
-      gp_Pnt aBasePnt;\r
-      gp_Dir aNormal;\r
-      clipPlaneParams(aClipPlane, ic, aSize, aBasePnt, aNormal, myModel->trihedronSize());\r
-      myPreviewPlane = new AIS_Plane( new Geom_Plane( aBasePnt, aNormal ), aBasePnt );\r
-      myPreviewPlane->SetTypeOfSensitivity( Select3D_TOS_INTERIOR );\r
-      myPreviewPlane->SetSize( aSize, aSize );\r
-      ic->SetWidth( myPreviewPlane, 10, false );\r
-      ic->SetMaterial( myPreviewPlane, Graphic3d_NOM_PLASTIC, false );\r
-      ic->SetTransparency( myPreviewPlane, 0.5, false );\r
-      Quantity_Color c = (aCurPlaneIndex == i) ? Quantity_Color( 255. / 255., 70. / 255., 0. / 255., Quantity_TOC_RGB ) : Quantity_Color( 85 / 255., 85 / 255., 255 / 255., Quantity_TOC_RGB );\r
-      ic->SetColor( myPreviewPlane, c , false );\r
-      ic->Display( myPreviewPlane, 1, 0, false );\r
-      myPreviewPlaneVector.push_back( myPreviewPlane );\r
-    }\r
-  }\r
-  myModel->update();\r
-\r
-  double aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;\r
-  getMinMaxFromContext( ic, myModel->trihedronSize(), aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);\r
-  gp_Pnt aRotationCenter( (aXmax + aXmin) * 0.5,\r
-                          (aYmax + aYmin) * 0.5,\r
-                          (aZmax + aZmin) * 0.5 );\r
-  Bnd_Box aMinMax;\r
-  aMinMax.Update( aXmin, aYmin, aZmin, aXmax, aYmax, aZmax );\r
-\r
-  myInteractor->setPlanes( myPreviewPlaneVector );\r
-  myInteractor->setRotationCenter( aRotationCenter );\r
-  myInteractor->setMinMax( aMinMax );\r
-  myInteractor->setEnabled( true );\r
-}\r
-\r
-void OCCViewer_ClippingDlg::updatePreview() {\r
-  int aCurPlaneIndex = ComboBoxPlanes->currentIndex();\r
-  int count = clipPlanesCount();\r
-  if ( myBusy || \r
-       !isValid() || \r
-       myIsPlaneCreation ||\r
-       !myModel || \r
-       count == 0 || \r
-       (aCurPlaneIndex +1 > count) ||\r
-       !PreviewCheckBox->isChecked())\r
-    return;\r
-  \r
-  Handle(AIS_InteractiveContext) ic = myModel->getAISContext();\r
-  \r
-  OCCViewer_ClipPlane& aClipPlane = getClipPlane(aCurPlaneIndex);\r
-  Handle(AIS_Plane) myPreviewPlane;\r
-\r
-  if (aClipPlane.IsOn) {\r
-    double aSize;\r
-    gp_Pnt aBasePnt;\r
-    gp_Dir aNormal;\r
-    clipPlaneParams(aClipPlane, ic, aSize, aBasePnt, aNormal, myModel->trihedronSize());\r
-    if(myPreviewPlaneVector.size() < clipPlanesCount()) {\r
-      myPreviewPlaneVector.resize(clipPlanesCount());\r
-    }\r
-    myPreviewPlane = myPreviewPlaneVector[aCurPlaneIndex];\r
-    if(myPreviewPlane.IsNull()) {\r
-      //Plane was not created\r
-      myPreviewPlane = new AIS_Plane( new Geom_Plane( aBasePnt, aNormal ), aBasePnt );\r
-      myPreviewPlane->SetTypeOfSensitivity( Select3D_TOS_INTERIOR );\r
-      myPreviewPlane->SetSize( aSize, aSize );\r
-      ic->Display( myPreviewPlane, 1, 0, false );\r
-      ic->SetWidth( myPreviewPlane, 10, false );\r
-      ic->SetMaterial( myPreviewPlane, Graphic3d_NOM_PLASTIC, false );\r
-      ic->SetTransparency( myPreviewPlane, 0.5, false );\r
-      myPreviewPlaneVector[aCurPlaneIndex] = myPreviewPlane;\r
-    } else {      \r
-      myPreviewPlane->SetComponent( new Geom_Plane( aBasePnt, aNormal ) );\r
-      myPreviewPlane->SetCenter( aBasePnt );\r
-      myPreviewPlane->SetSize( aSize, aSize ); \r
-    }\r
-\r
-    ic->SetColor( myPreviewPlane, Quantity_Color( 255. / 255., 70. / 255., 0. / 255., Quantity_TOC_RGB ), false );\r
-    ic->Update( myPreviewPlane, Standard_False );\r
-  } else {\r
-    if(myPreviewPlaneVector.size() > aCurPlaneIndex ) {\r
-      myPreviewPlane = myPreviewPlaneVector[aCurPlaneIndex];\r
-      if(ic->IsDisplayed(myPreviewPlane)) {\r
-       ic->Erase( myPreviewPlane, false );\r
-       ic->Remove( myPreviewPlane, false );\r
-      }\r
-      myPreviewPlaneVector[aCurPlaneIndex].Nullify();\r
-    }\r
-  }\r
-  for(int i = 0; i < myPreviewPlaneVector.size(); i++) {\r
-    if( i == aCurPlaneIndex ) continue;\r
-    if(!myPreviewPlaneVector[i].IsNull())\r
-      ic->SetColor( myPreviewPlaneVector[i], Quantity_Color( 85 / 255., 85 / 255., 255 / 255., Quantity_TOC_RGB ), false );\r
-  }\r
-  myModel->update();\r
-\r
-  double aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;\r
-  getMinMaxFromContext( ic, myModel->trihedronSize(), aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);\r
-  gp_Pnt aRotationCenter( (aXmax + aXmin) * 0.5,\r
-                          (aYmax + aYmin) * 0.5,\r
-                          (aZmax + aZmin) * 0.5 );\r
-  Bnd_Box aMinMax;\r
-  aMinMax.Update( aXmin, aYmin, aZmin, aXmax, aYmax, aZmax );\r
-\r
-  myInteractor->setPlanes( myPreviewPlaneVector );\r
-  myInteractor->setRotationCenter( aRotationCenter );\r
-  myInteractor->setMinMax( aMinMax );\r
-}\r
-\r
-/*!\r
-  Erases preview of clipping plane\r
-*/\r
-void OCCViewer_ClippingDlg::erasePreview()\r
-{\r
-  if ( !myModel )\r
-    return;\r
-\r
-  Handle(AIS_InteractiveContext) ic = myModel->getAISContext();\r
-\r
-  for ( int i=0; i < myPreviewPlaneVector.size(); i++ ) {\r
-  Handle(AIS_Plane) myPreviewPlane = myPreviewPlaneVector[i];\r
-    if ( !myPreviewPlane.IsNull() && ic->IsDisplayed( myPreviewPlane ) ) {\r
-      ic->Erase( myPreviewPlane, false );\r
-      ic->Remove( myPreviewPlane, false );\r
-      myPreviewPlane.Nullify();\r
-    }\r
-  }\r
-  myPreviewPlaneVector.clear();\r
-  myModel->update();\r
-  myInteractor->setEnabled( false );\r
-}\r
-\r
-/*!\r
-  Return true if plane parameters are valid\r
-*/\r
-bool OCCViewer_ClippingDlg::isValid()\r
-{\r
-  return ( SpinBox_Dx->value() !=0 || SpinBox_Dy->value() !=0 || SpinBox_Dz->value() !=0 );\r
-}\r
-\r
-/*!\r
-  Update view after changes\r
-*/\r
-void OCCViewer_ClippingDlg::updateClipping()\r
-{\r
-  if (PreviewCheckBox->isChecked() || AutoApplyCheckBox->isChecked())\r
-  {\r
-    if (AutoApplyCheckBox->isChecked()) {\r
-      onApply();\r
-    }\r
-    \r
-    if (!PreviewCheckBox->isChecked())\r
-      myModel->update();\r
-    else \r
-      updatePreview();\r
-  }\r
-}\r
-\r
-/*!\r
-  Updates state of user controls.\r
-*/\r
-void OCCViewer_ClippingDlg::updateControls()\r
-{\r
-  if ( clipPlanesCount() == 0 )\r
-  {\r
-    initParam();\r
-    return;\r
-  }\r
-\r
-  int aPlaneIdx = ComboBoxPlanes->currentIndex();\r
-\r
-  OCCViewer_ClipPlane& aPlane = getClipPlane( aPlaneIdx );\r
-\r
-  double aPlaneDx  = 0.0;\r
-  double aPlaneDy  = 0.0;\r
-  double aPlaneDz  = 0.0;\r
-  double aDistance = 0.0;\r
-  aPlane.OrientationToXYZ( aPlaneDx, aPlaneDy, aPlaneDz );\r
-\r
-  if ( aPlane.Mode == OCCViewer_ClipPlane::Absolute )\r
-  {\r
-    ModeStackedLayout->setCurrentIndex( 0 );\r
-\r
-    // Set plane parameters in the dialog\r
-    SpinBox_X->setValue( aPlane.X );\r
-    SpinBox_Y->setValue( aPlane.Y );\r
-    SpinBox_Z->setValue( aPlane.Z );\r
-    SpinBox_Dx->setValue( aPlaneDx );\r
-    SpinBox_Dy->setValue( aPlaneDy );\r
-    SpinBox_Dz->setValue( aPlaneDz );\r
-    CBAbsoluteOrientation->setCurrentIndex( aPlane.OrientationType );\r
-    onOrientationAbsoluteChanged( aPlane.OrientationType );\r
-  }\r
-  else if( aPlane.Mode == OCCViewer_ClipPlane::Relative )\r
-  {\r
-    ModeStackedLayout->setCurrentIndex( 1 );\r
-\r
-    // Set plane parameters in the dialog\r
-    SpinSliderRotation1->setValue( int( aPlane.RelativeOrientation.Rotation1 ) );\r
-    SpinSliderRotation2->setValue( int( aPlane.RelativeOrientation.Rotation2 ) );\r
-\r
-    XYZToDistance( myModel->getAISContext(),\r
-                   myModel->trihedronSize(),\r
-                   aPlane.X, aPlane.Y, aPlane.Z,\r
-                   aPlaneDx, aPlaneDy, aPlaneDz,\r
-                   aDistance );\r
-\r
-    SpinSliderDistance->setValue( aDistance );\r
-\r
-    CBRelativeOrientation->setCurrentIndex( aPlane.OrientationType );\r
-    onOrientationRelativeChanged( aPlane.OrientationType );\r
-  }\r
-\r
-  isActivePlane->setChecked( aPlane.IsOn );\r
-}\r
-\r
-/*!\r
-  SLOT on new button click: create a new clipping plane\r
-*/\r
-void OCCViewer_ClippingDlg::ClickOnNew()\r
-{\r
-  OCCViewer_ClipPlane aClipPlane;\r
-\r
-  // init controls state\r
-  myIsUpdatingControls = true;\r
-  initParam();\r
-  myIsUpdatingControls = false;\r
-\r
-  // init plane according to the state of controls\r
-  setPlaneParam( aClipPlane );\r
-\r
-  // add plane\r
-  myLocalPlanes.push_back( aClipPlane );\r
-  synchronize();\r
-}\r
-\r
-/*!\r
-  SLOT on delete button click: Delete selected clipping plane\r
-*/\r
-void OCCViewer_ClippingDlg::ClickOnDelete()\r
-{\r
-  int aPlaneIndex = ComboBoxPlanes->currentIndex();\r
-  if ( (clipPlanesCount() == 0) || (aPlaneIndex+1 > clipPlanesCount()))\r
-    return;\r
-\r
-  myLocalPlanes.erase(myLocalPlanes.begin() + aPlaneIndex);\r
-\r
-  Handle(AIS_InteractiveContext) ic = myModel->getAISContext();\r
-\r
-  if(aPlaneIndex+1 <= myPreviewPlaneVector.size()) {\r
-    Handle(AIS_Plane) myPreviewPlane = myPreviewPlaneVector[aPlaneIndex];\r
-    if ( !myPreviewPlane.IsNull() && ic->IsDisplayed( myPreviewPlane ) ) {\r
-      ic->Erase( myPreviewPlane, false );\r
-      ic->Remove( myPreviewPlane, false );\r
-    }\r
-    myPreviewPlaneVector.erase(myPreviewPlaneVector.begin() + aPlaneIndex);\r
-  }\r
-  synchronize();\r
-  if (AutoApplyCheckBox->isChecked()) {\r
-    onApply();\r
-  }\r
-  myModel->update();\r
-}\r
-\r
-/*!\r
-  SLOT on disable all button click: Restore initial state of viewer,\r
-  erase all clipping planes\r
-*/\r
-void OCCViewer_ClippingDlg::ClickOnDisableAll()\r
-{\r
-  AutoApplyCheckBox->setChecked (false);\r
-  int aClipPlanesCount = clipPlanesCount();\r
-  for ( int anIndex = 0; anIndex < aClipPlanesCount; anIndex++)\r
-  {\r
-    OCCViewer_ClipPlane& aPlane = getClipPlane(anIndex);\r
-    aPlane.IsOn = false;\r
-  }\r
-  erasePreview();\r
-  isActivePlane->setChecked(false);\r
-  myModel->setClipPlanes(myLocalPlanes);\r
-  myModel->update();\r
-}\r
-\r
-/*!\r
-  SLOT on ok button click: sets cutting plane and closes dialog\r
-*/\r
-void OCCViewer_ClippingDlg::ClickOnOk()\r
-{\r
-  onApply();\r
-  ClickOnClose();\r
-}\r
-\r
-/*!\r
-  SLOT on Apply button click: sets cutting plane and update viewer\r
-*/\r
-void OCCViewer_ClippingDlg::ClickOnApply()\r
-{\r
-  onApply();\r
-  myModel->update();\r
-}\r
-\r
-/*!\r
-  SLOT on close button click: erases preview and rejects dialog\r
-*/\r
-void OCCViewer_ClippingDlg::ClickOnClose()\r
-{\r
-  erasePreview();\r
-  OCCViewer_ViewWindow* v = qobject_cast<OCCViewer_ViewWindow*>(parent());\r
-  if(v)\r
-    v->onClipping(false);\r
-}\r
-\r
-/*!\r
-  SLOT on help button click: opens a help page\r
-*/\r
-void OCCViewer_ClippingDlg::ClickOnHelp()\r
-{\r
-  SUIT_Application* app = SUIT_Session::session()->activeApplication();\r
-  if ( app )\r
-    app->onHelpContextModule( "GUI", "occ_3d_viewer_page.html", "clipping_planes" );\r
-}\r
-\r
-/*!\r
-  Set absolute mode of clipping plane\r
-*/\r
-void OCCViewer_ClippingDlg::onModeAbsolute()\r
-{\r
-  myIsPlaneCreation = true;\r
-  ModeStackedLayout->setCurrentIndex(0);\r
-  ClickOnNew();\r
-  myIsPlaneCreation = false;\r
-  updateClipping();\r
-}\r
-\r
-/*!\r
-  Set relative mode of clipping plane\r
-*/\r
-void OCCViewer_ClippingDlg::onModeRelative()\r
-{\r
-  myIsPlaneCreation = true;\r
-  ModeStackedLayout->setCurrentIndex(1);\r
-  ClickOnNew();\r
-  myIsPlaneCreation = false;\r
-  SetCurrentPlaneParam();\r
-  updateClipping();\r
-}\r
-\r
-/*!\r
-  SLOT: called on value of clipping plane changed\r
-*/\r
-void OCCViewer_ClippingDlg::onValueChanged()\r
-{\r
-  if ( myIsUpdatingControls )\r
-  {\r
-    return;\r
-  }\r
-\r
-  SetCurrentPlaneParam();\r
-\r
-  if ( myIsSelectPlane )\r
-  {\r
-    return;\r
-  }\r
-\r
-  updateClipping();\r
-}\r
-\r
-/*!\r
-  Set current parameters of selected plane\r
-*/\r
-void OCCViewer_ClippingDlg::onSelectPlane ( int theIndex )\r
-{\r
-  if ( clipPlanesCount() == 0 )\r
-  {\r
-    return;\r
-  }\r
-\r
-  OCCViewer_ClipPlane& aClipPlane = getClipPlane( theIndex );\r
-\r
-  myIsSelectPlane = true;\r
-  updateControls();\r
-  ComboBoxPlanes->setCurrentIndex( theIndex );\r
-  myIsSelectPlane = false;\r
-}\r
-\r
-/*!\r
-  Restore parameters of selected plane\r
-*/\r
-void OCCViewer_ClippingDlg::SetCurrentPlaneParam()\r
-{\r
-  if ( clipPlanesCount() == 0 || myIsSelectPlane || myBusy )\r
-  {\r
-    return;\r
-  }\r
-\r
-  int aCurPlaneIndex = ComboBoxPlanes->currentIndex();\r
-\r
-  OCCViewer_ClipPlane& aPlane = getClipPlane( aCurPlaneIndex );\r
-\r
-  setPlaneParam( aPlane );\r
-}\r
-\r
-/*!\r
-  SLOT on reset button click: sets default values\r
-*/\r
-void OCCViewer_ClippingDlg::onReset()\r
-{\r
-  myBusy = true;\r
-  SpinBox_X->setValue(0);\r
-  SpinBox_Y->setValue(0);\r
-  SpinBox_Z->setValue(0);\r
-  myBusy = false;\r
-\r
-  updateClipping();\r
-}\r
-\r
-/*!\r
-  SLOT on invert button click: inverts normal of cutting plane\r
-*/\r
-void OCCViewer_ClippingDlg::onInvert()\r
-{\r
-  double Dx = SpinBox_Dx->value();\r
-  double Dy = SpinBox_Dy->value();\r
-  double Dz = SpinBox_Dz->value();\r
-\r
-  myBusy = true;\r
-  SpinBox_Dx->setValue( -Dx );\r
-  SpinBox_Dy->setValue( -Dy );\r
-  SpinBox_Dz->setValue( -Dz );\r
-  myBusy = false;\r
-\r
-  if ( clipPlanesCount() != 0 )\r
-  {\r
-    int aCurPlaneIndex = ComboBoxPlanes->currentIndex();\r
-    OCCViewer_ClipPlane& aPlane = getClipPlane( aCurPlaneIndex );\r
-    aPlane.AbsoluteOrientation.IsInvert = !aPlane.AbsoluteOrientation.IsInvert;\r
-  }\r
-  updateClipping();\r
-}\r
-\r
-/*!\r
-  SLOT: called on orientation of clipping plane in absolute mode changed\r
-*/\r
-void OCCViewer_ClippingDlg::onOrientationAbsoluteChanged( int mode )\r
-{\r
-  bool isUserMode = (mode==0);\r
-\r
-  TextLabelX->setEnabled( isUserMode );\r
-  TextLabelY->setEnabled( isUserMode );\r
-  TextLabelZ->setEnabled( isUserMode );\r
-\r
-  SpinBox_X->setEnabled( isUserMode );\r
-  SpinBox_Y->setEnabled( isUserMode );\r
-  SpinBox_Z->setEnabled( isUserMode );\r
-\r
-  TextLabelDx->setEnabled( isUserMode );\r
-  TextLabelDy->setEnabled( isUserMode );\r
-  TextLabelDz->setEnabled( isUserMode );\r
-\r
-  SpinBox_Dx->setEnabled( isUserMode );\r
-  SpinBox_Dy->setEnabled( isUserMode );\r
-  SpinBox_Dz->setEnabled( isUserMode );\r
-\r
-  if ( !isUserMode ) {\r
-\r
-    double aDx = 0, aDy = 0, aDz = 0;\r
-\r
-    if ( mode == 1 )\r
-    {\r
-      aDz = 1;\r
-      TextLabelZ->setEnabled( true );\r
-      SpinBox_Z->setEnabled( true );\r
-      SpinBox_Z->setFocus();\r
-    }\r
-    else if ( mode == 2 )\r
-    {\r
-      aDx = 1;\r
-      TextLabelX->setEnabled( true );\r
-      SpinBox_X->setEnabled( true );\r
-      SpinBox_X->setFocus();\r
-    }\r
-    else if ( mode == 3 )\r
-    {\r
-      aDy = 1;\r
-      TextLabelY->setEnabled( true );\r
-      SpinBox_Y->setEnabled( true );\r
-      SpinBox_Y->setFocus();\r
-    }\r
-    \r
-    int aCurPlaneIndex = ComboBoxPlanes->currentIndex();\r
-    OCCViewer_ClipPlane& aPlane = getClipPlane( aCurPlaneIndex );\r
-    if ( aPlane.AbsoluteOrientation.IsInvert == true )\r
-    {\r
-      aDx = -aDx;\r
-      aDy = -aDy;\r
-      aDz = -aDz;\r
-    }\r
-    \r
-    myBusy = true;\r
-    SpinBox_Dx->setValue( aDx );\r
-    SpinBox_Dy->setValue( aDy );\r
-    SpinBox_Dz->setValue( aDz );\r
-    myBusy = false;\r
-  }\r
-\r
-  if ( !myIsUpdatingControls )\r
-  {\r
-    SetCurrentPlaneParam();\r
-    updateClipping();\r
-  }\r
-}\r
-\r
-/*!\r
-  SLOT: called on orientation of clipping plane in relative mode changed\r
-*/\r
-void OCCViewer_ClippingDlg::onOrientationRelativeChanged (int theItem)\r
-{\r
-  if ( clipPlanesCount() == 0 )\r
-    return;\r
-  \r
-  if ( theItem == 0 ) {\r
-    TextLabelRotation1->setText( tr( "ROTATION_AROUND_X_Y2Z" ) );\r
-    TextLabelRotation2->setText( tr( "ROTATION_AROUND_Y_X2Z" ) );\r
-  }\r
-  else if ( theItem == 1 ) {\r
-    TextLabelRotation1->setText( tr( "ROTATION_AROUND_Y_Z2X" ) );\r
-    TextLabelRotation2->setText( tr( "ROTATION_AROUND_Z_Y2X" ) );\r
-  }\r
-  else if ( theItem == 2 ) {\r
-    TextLabelRotation1->setText( tr( "ROTATION_AROUND_Z_X2Y" ) );\r
-    TextLabelRotation2->setText( tr( "ROTATION_AROUND_X_Z2Y" ) );\r
-  }\r
-\r
-  if ( !myIsUpdatingControls )\r
-  {\r
-    if( (QComboBox*)sender() == CBRelativeOrientation )\r
-    {\r
-      SetCurrentPlaneParam();\r
-    }\r
-\r
-    updateClipping();\r
-  }\r
-}\r
-\r
-/*!\r
-  SLOT: called on preview check box toggled\r
-*/\r
-void OCCViewer_ClippingDlg::onPreview( bool on )\r
-{\r
-  erasePreview();\r
-  if ( on ) \r
-    displayPreview();\r
-}\r
-\r
-/*!\r
-  SLOT: called on Auto Apply check box toggled\r
-*/\r
-void OCCViewer_ClippingDlg::onAutoApply( bool toggled )\r
-{\r
-  if ( toggled ) {\r
-    onApply();\r
-    myModel->update();\r
-  }  \r
-}\r
-\r
-/*!\r
-  SLOT on Apply button click: sets cutting plane\r
-*/\r
-void OCCViewer_ClippingDlg::onApply()\r
-{\r
-  if ( myBusy )\r
-    return;\r
-  myIsSelectPlane = true;\r
-\r
-  qApp->processEvents();\r
-  QApplication::setOverrideCursor( Qt::WaitCursor );\r
-  qApp->processEvents();\r
-\r
-  myModel->setClipPlanes(myLocalPlanes);\r
-\r
-  QApplication::restoreOverrideCursor();\r
-  myIsSelectPlane = false;\r
-}\r
-\r
-/*!\r
-  SLOT: Called when clip plane is clicked in viewer.\r
-*/\r
-void OCCViewer_ClippingDlg::onPlaneClicked( const Handle(AIS_Plane)& thePlane )\r
-{\r
-  for ( int aPlaneIt = 0; aPlaneIt < myPreviewPlaneVector.size(); aPlaneIt++ )\r
-  {\r
-    Handle(AIS_Plane)& aPlane = myPreviewPlaneVector.at( aPlaneIt );\r
-    if ( aPlane != thePlane )\r
-    {\r
-      continue;\r
-    }\r
-\r
-    ComboBoxPlanes->setCurrentIndex( aPlaneIt );\r
-\r
-    break;\r
-  }\r
-}\r
-\r
-/*!\r
-  SLOT: Called when clip plane is changed by dragging in viewer.\r
-*/\r
-void OCCViewer_ClippingDlg::onPlaneDragged( const Handle(AIS_Plane)& thePlane )\r
-{\r
-  for ( int aPlaneIt = 0; aPlaneIt < myPreviewPlaneVector.size(); aPlaneIt++ )\r
-  {\r
-    Handle(AIS_Plane)& aPlane = myPreviewPlaneVector.at( aPlaneIt );\r
-    if ( aPlane != thePlane )\r
-    {\r
-      continue;\r
-    }\r
-\r
-    OCCViewer_ClipPlane& aClipPlane = getClipPlane( aPlaneIt );\r
-\r
-    gp_Pln aPln = thePlane->Component()->Pln();\r
-    const gp_Pnt& aPlaneP = aPln.Location();\r
-    const gp_Dir& aPlaneN = aPln.Axis().Direction();\r
-\r
-    aClipPlane.X  = aPlaneP.X();\r
-    aClipPlane.Y  = aPlaneP.Y();\r
-    aClipPlane.Z  = aPlaneP.Z();\r
-\r
-    if ( aClipPlane.Mode == OCCViewer_ClipPlane::Absolute )\r
-    {\r
-      if ( aClipPlane.OrientationType == OCCViewer_ClipPlane::AbsoluteCustom )\r
-      {\r
-        aClipPlane.AbsoluteOrientation.Dx = aPlaneN.X();\r
-        aClipPlane.AbsoluteOrientation.Dy = aPlaneN.Y();\r
-        aClipPlane.AbsoluteOrientation.Dz = aPlaneN.Z();\r
-      }\r
-    }\r
-    else\r
-    {\r
-      OCCViewer_ClipPlane::DXYZToRelative( aPlaneN.X(), aPlaneN.Y(), aPlaneN.Z(),\r
-                                           aClipPlane.OrientationType,\r
-                                           aClipPlane.RelativeOrientation.Rotation1,\r
-                                           aClipPlane.RelativeOrientation.Rotation2 );\r
-    }\r
-\r
-    myIsUpdatingControls = true;\r
-    updateControls();\r
-    myIsUpdatingControls = false;\r
-\r
-    if ( AutoApplyCheckBox->isChecked() )\r
-    {\r
-      onApply();\r
-    }\r
-\r
-    break;\r
-  }\r
-}\r
-\r
-OCCViewer_ClipPlane& OCCViewer_ClippingDlg::getClipPlane( int theIdx )\r
-{\r
-  return myLocalPlanes[theIdx];\r
-}\r
-\r
-int OCCViewer_ClippingDlg::clipPlanesCount()\r
-{\r
-  return myLocalPlanes.size();\r
-}\r
-\r
+// Copyright (C) 2007-2014  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, or (at your option) any later version.
+//
+// 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 "OCCViewer_ClippingDlg.h"
+
+#include <QtxDoubleSpinBox.h>
+#include <QtxDoubleSpinSlider.h>
+#include <QtxIntSpinSlider.h>
+#include <QtxAction.h>
+
+#include "SUIT_Session.h"
+#include "SUIT_ViewWindow.h"
+#include "SUIT_ViewManager.h"
+#include "OCCViewer_ClipPlane.h"
+#include "OCCViewer_ViewWindow.h"
+#include "OCCViewer_ViewPort3d.h"
+#include "OCCViewer_ViewModel.h"
+#include "OCCViewer_ViewManager.h"
+#include "OCCViewer_ClipPlaneInteractor.h"
+
+#include <V3d_View.hxx>
+#include <Visual3d_View.hxx>
+#include <Geom_Plane.hxx>
+#include <Prs3d_Presentation.hxx>
+#include <AIS_ListIteratorOfListOfInteractive.hxx>
+#include <AIS_ListOfInteractive.hxx>
+#include <AIS_InteractiveObject.hxx>
+#include <AIS_InteractiveContext.hxx>
+#include <IntAna_IntConicQuad.hxx>
+#include <gp_Lin.hxx>
+#include <gp_Pln.hxx>
+#include <math.h>
+
+// QT Includes
+#include <QApplication>
+#include <QGroupBox>
+#include <QHBoxLayout>
+#include <QVBoxLayout>
+#include <QGridLayout>
+#include <QLabel>
+#include <QPushButton>
+#include <QComboBox>
+#include <QCheckBox>
+#include <QStackedLayout>
+#include <QSlider>
+#include <QMenu>
+
+/**********************************************************************************
+ ************************        Internal functions        ************************
+ *********************************************************************************/
+
+void getMinMaxFromContext( Handle(AIS_InteractiveContext) ic,
+                          double  theDefaultSize,
+                          double& theXMin,
+                          double& theYMin,
+                          double& theZMin,
+                          double& theXMax,
+                          double& theYMax,
+                          double& theZMax) {
+
+  double aXMin, aYMin, aZMin, aXMax, aYMax, aZMax;
+  aXMin = aYMin = aZMin = DBL_MAX;
+  aXMax = aYMax = aZMax = -DBL_MAX;
+  
+  bool isFound = false;
+  AIS_ListOfInteractive aList;
+  ic->DisplayedObjects( aList );
+  for ( AIS_ListIteratorOfListOfInteractive it( aList ); it.More(); it.Next() ) {
+    Handle(AIS_InteractiveObject) anObj = it.Value();
+    if ( !anObj.IsNull() && anObj->HasPresentation() &&
+         !anObj->IsKind( STANDARD_TYPE(AIS_Plane) ) ) {
+      Handle(Prs3d_Presentation) aPrs = anObj->Presentation();
+      if ( !aPrs->IsEmpty() && !aPrs->IsInfinite() ) {
+        isFound = true;
+        double xmin, ymin, zmin, xmax, ymax, zmax;
+        aPrs->MinMaxValues( xmin, ymin, zmin, xmax, ymax, zmax );
+        aXMin = qMin( aXMin, xmin );  aXMax = qMax( aXMax, xmax );
+        aYMin = qMin( aYMin, ymin );  aYMax = qMax( aYMax, ymax );
+        aZMin = qMin( aZMin, zmin );  aZMax = qMax( aZMax, zmax );
+      }
+    }
+  }
+
+  if(!isFound) {
+    if(theDefaultSize == 0.0)
+      theDefaultSize = 100.;
+    aXMin = aYMin = aZMin = -theDefaultSize;
+    aXMax = aYMax = aZMax = theDefaultSize;
+  }
+  theXMin = aXMin;theYMin = aYMin;theZMin = aZMin;
+  theXMax = aXMax;theYMax = aYMax;theZMax = aZMax;
+}
+
+/*!
+  Compute the point of bounding box and current clipping plane
+ */
+void ComputeBoundsParam( const double theBounds[6],
+                         const double theDirection[3],
+                         double theMinPnt[3],
+                         double& theMaxBoundPrj,
+                         double& theMinBoundPrj )
+{
+  double aEnlargeBounds[6];
+
+  // Enlarge bounds in order to avoid conflicts of precision
+  for(int i = 0; i < 6; i += 2)
+  {
+    static double EPS = 1.0E-3;
+    double aDelta = (theBounds[i+1] - theBounds[i])*EPS;
+    aEnlargeBounds[i  ] = theBounds[i  ] - aDelta;
+    aEnlargeBounds[i+1] = theBounds[i+1] + aDelta;
+  }
+
+  double aBoundPoints[8][3] = { { aEnlargeBounds[0], aEnlargeBounds[2], aEnlargeBounds[4] },
+                                { aEnlargeBounds[1], aEnlargeBounds[2], aEnlargeBounds[4] },
+                                { aEnlargeBounds[0], aEnlargeBounds[3], aEnlargeBounds[4] },
+                                { aEnlargeBounds[1], aEnlargeBounds[3], aEnlargeBounds[4] },
+                                { aEnlargeBounds[0], aEnlargeBounds[2], aEnlargeBounds[5] },
+                                { aEnlargeBounds[1], aEnlargeBounds[2], aEnlargeBounds[5] },
+                                { aEnlargeBounds[0], aEnlargeBounds[3], aEnlargeBounds[5] },
+                                { aEnlargeBounds[1], aEnlargeBounds[3], aEnlargeBounds[5] } };
+
+  int aMaxId = 0;
+  theMaxBoundPrj = theDirection[0] * aBoundPoints[aMaxId][0] + theDirection[1] * aBoundPoints[aMaxId][1]
+                   + theDirection[2] * aBoundPoints[aMaxId][2];
+  theMinBoundPrj = theMaxBoundPrj;
+  for(int i = 1; i < 8; i++) {
+    double aTmp = theDirection[0] * aBoundPoints[i][0] + theDirection[1] * aBoundPoints[i][1]
+                  + theDirection[2] * aBoundPoints[i][2];
+    if(theMaxBoundPrj < aTmp) {
+      theMaxBoundPrj = aTmp;
+      aMaxId = i;
+    }
+    if(theMinBoundPrj > aTmp) {
+      theMinBoundPrj = aTmp;
+    }
+  }
+  double *aMinPnt = aBoundPoints[aMaxId];
+  theMinPnt[0] = aMinPnt[0];
+  theMinPnt[1] = aMinPnt[1];
+  theMinPnt[2] = aMinPnt[2];
+}
+
+/*!
+  Compute the position of current plane by distance
+ */
+void DistanceToPosition( const double theBounds[6],
+                         const double theDirection[3],
+                         const double theDist,
+                         double thePos[3] )
+{
+  double aMaxBoundPrj, aMinBoundPrj, aMinPnt[3];
+  ComputeBoundsParam( theBounds, theDirection, aMinPnt, aMaxBoundPrj, aMinBoundPrj );
+  double aLength = (aMaxBoundPrj - aMinBoundPrj) * theDist;
+  thePos[0] = aMinPnt[0] - theDirection[0] * aLength;
+  thePos[1] = aMinPnt[1] - theDirection[1] * aLength;
+  thePos[2] = aMinPnt[2] - theDirection[2] * aLength;
+}
+
+/*!
+  Compute the parameters of clipping plane
+ */
+bool ComputeClippingPlaneParameters( const Handle(AIS_InteractiveContext)& theIC,
+                                     const double theDefaultSize,
+                                     const double theNormal[3],
+                                     const double theDist,
+                                     double theOrigin[3] )
+{
+  double aBounds[6] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
+
+  getMinMaxFromContext( theIC, theDefaultSize, aBounds[0], aBounds[2], aBounds[4], aBounds[1], aBounds[3], aBounds[5] );
+
+  DistanceToPosition( aBounds, theNormal, theDist, theOrigin );
+  return true;
+}
+
+/*!
+  \brief Converts relative plane parameters to absolute.
+  \param theIC [in] the interactive context.
+  \param theDefaultSize [in] the default trihedron size.
+  \param theDistance [in] the plane distance relative to minimum corner of model boundaries.
+  \param theDX [in] x component of plane direction.
+  \param theDY [in] y component of plane direction.
+  \param theDZ [in] z component of plane direction.
+  \param theX [out] x coordinate of plane origin.
+  \param theY [out] y coordinate of plane origin.
+  \param theZ [out] z coordinate of plane origin.
+ */
+bool DistanceToXYZ ( const Handle(AIS_InteractiveContext)& theIC,
+                     const double theDefaultSize,
+                     const double theDistance,
+                     const double theDX,
+                     const double theDY,
+                     const double theDZ,
+                     double& theX,
+                     double& theY,
+                     double& theZ )
+{
+  double aNormal[3] = { theDX, theDY, theDZ };
+  double anOrigin[3] = { 0.0, 0.0, 0.0 };
+
+  bool anIsOk = ComputeClippingPlaneParameters( theIC, theDefaultSize, aNormal, theDistance, anOrigin );
+
+  if( !anIsOk )
+  {
+    return false;
+  }
+
+  theX = anOrigin[0];
+  theY = anOrigin[1];
+  theZ = anOrigin[2];
+
+  return true;
+}
+
+/*!
+  \brief Converts absolute position and direction to bounding box distance.
+  \param theIC [in] the interactive context.
+  \param theDefaultSize [in] the default trihedron size.
+  \param theX [in] x coordinate of plane origin.
+  \param theY [in] y coordinate of plane origin.
+  \param theZ [in] z coordinate of plane origin.
+  \param theDX [in] x component of plane direction.
+  \param theDY [in] y component of plane direction.
+  \param theDZ [in] z component of plane direction.
+  \param theDistance [out] the plane distance relative to minimum corner of model boundaries.
+ */
+void XYZToDistance ( const Handle(AIS_InteractiveContext)& theIC,
+                     const double theDefaultSize,
+                     const double theX,
+                     const double theY,
+                     const double theZ,
+                     const double theDX,
+                     const double theDY,
+                     const double theDZ,
+                     double& theDistance )
+{
+  gp_Pnt aPlaneP( theX, theY, theZ );
+  gp_Dir aPlaneN( theDX, theDY, theDZ );
+
+  double aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
+
+  getMinMaxFromContext( theIC, theDefaultSize, aXmin, aYmin, aZmin, aXmax, aYmax, aZmax );
+
+  Bnd_Box aMinMax;
+  aMinMax.Update( aXmin, aYmin, aZmin, aXmax, aYmax, aZmax );
+
+  gp_Trsf aRelativeTransform;
+  aRelativeTransform.SetTransformation( gp_Ax3(), gp_Ax3( aPlaneP, aPlaneN ) );
+  Bnd_Box aRelativeBounds = aMinMax.Transformed( aRelativeTransform );
+
+  aRelativeBounds.Get( aXmin, aYmin, aZmin, aXmax, aYmax, aZmax );
+
+  double aLength   = aZmax - aZmin;
+  double aDistance = aZmax;
+
+  double aRelativeDistance = aLength > 0.01 ? aDistance / aLength : 0.0;
+  aRelativeDistance = qMin( aRelativeDistance, aLength );
+  aRelativeDistance = qMax( aRelativeDistance, 0.0 );
+  theDistance = aRelativeDistance;
+}
+
+/*!
+  Compute clipping plane size base point and normal
+ */
+
+void clipPlaneParams(OCCViewer_ClipPlane& theClipPlane, Handle(AIS_InteractiveContext) theContext,
+                     double& theSize, gp_Pnt& theBasePnt, gp_Dir& theNormal, double defaultSize) {
+  double aXMin, aYMin, aZMin, aXMax, aYMax, aZMax;
+  aXMin = aYMin = aZMin = DBL_MAX;
+  aXMax = aYMax = aZMax = -DBL_MAX;
+  
+  getMinMaxFromContext(theContext,defaultSize,aXMin, aYMin, aZMin, aXMax, aYMax, aZMax);
+  double aSize = 50;
+
+  double aNormalX = 0.0;
+  double aNormalY = 0.0;
+  double aNormalZ = 0.0;
+  theClipPlane.OrientationToXYZ( aNormalX, aNormalY, aNormalZ );
+  gp_Pnt aBasePnt( theClipPlane.X, theClipPlane.Y, theClipPlane.Z );
+  gp_Dir aNormal( aNormalX, aNormalY, aNormalZ );
+
+  // compute clipping plane size
+  gp_Pnt aCenter = gp_Pnt( ( aXMin + aXMax ) / 2, ( aYMin + aYMax ) / 2, ( aZMin + aZMax ) / 2 );
+  double aDiag = aCenter.Distance( gp_Pnt( aXMax, aYMax, aZMax ) )*2;
+  aSize = aDiag * 1.1;
+  
+  // compute clipping plane center ( redefine the base point )
+  IntAna_IntConicQuad intersector = IntAna_IntConicQuad();
+  
+  intersector.Perform( gp_Lin( aCenter, aNormal), gp_Pln( aBasePnt, aNormal), Precision::Confusion() );
+
+  if ( intersector.IsDone() && intersector.NbPoints() == 1 )
+    aBasePnt = intersector.Point( 1 );
+  
+  theSize = aSize;
+  theBasePnt = aBasePnt;
+  theNormal = aNormal;
+}
+
+
+/*********************************************************************************
+ *********************      class OCCViewer_ClippingDlg      *********************
+ *********************************************************************************/
+/*!
+  Constructor
+  \param view - view window
+  \param parent - parent widget
+*/
+OCCViewer_ClippingDlg::OCCViewer_ClippingDlg(OCCViewer_ViewWindow* parent , OCCViewer_Viewer* model)
+  : QDialog( parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint )
+{
+  setObjectName( "OCCViewer_ClippingDlg" );
+  setModal( false );
+
+  setWindowTitle( tr( "Clipping" ) );
+
+  setAttribute (Qt::WA_DeleteOnClose, true);
+  
+  QVBoxLayout* topLayout = new QVBoxLayout( this );
+  topLayout->setMargin( 11 ); topLayout->setSpacing( 6 );
+
+  /***************************************************************/
+  // Controls for selecting, creating, deleting planes
+  QGroupBox* GroupPlanes = new QGroupBox( tr("CLIPPING_PLANES"), this );
+  QHBoxLayout* GroupPlanesLayout = new QHBoxLayout( GroupPlanes );
+  ComboBoxPlanes = new QComboBox( GroupPlanes );
+  isActivePlane = new QCheckBox( tr("IS_ACTIVE_PLANE"), this );
+  buttonNew = new QPushButton( tr("BTN_NEW"), GroupPlanes );
+  buttonDelete = new QPushButton( tr("BTN_DELETE"), GroupPlanes );
+  buttonDisableAll = new QPushButton( tr("BTN_DISABLE_ALL"), GroupPlanes );
+  MenuMode = new QMenu( "MenuMode", buttonNew );
+  MenuMode->addAction( tr( "ABSOLUTE" ), this, SLOT( onModeAbsolute() ) );
+  MenuMode->addAction( tr( "RELATIVE" ), this, SLOT( onModeRelative() ) );
+  buttonNew->setMenu( MenuMode );
+
+  GroupPlanesLayout->addWidget( ComboBoxPlanes );
+  GroupPlanesLayout->addWidget( isActivePlane );
+  GroupPlanesLayout->addWidget( buttonNew );
+  GroupPlanesLayout->addWidget( buttonDelete );
+  GroupPlanesLayout->addWidget( buttonDisableAll );
+
+  ModeStackedLayout = new QStackedLayout();
+
+  /**********************   Mode Absolute   **********************/
+  /* Controls for absolute mode of clipping plane:
+     X, Y, Z - coordinates of the intersection of cutting plane and the three axes
+     Dx, Dy, Dz - components of normal to the cutting plane
+     Orientation - direction of cutting plane
+   */
+  const double min = -1e+7;
+  const double max =  1e+7;
+  const double step = 5;
+  const int precision = -7;
+
+  // Croup Point
+  QGroupBox* GroupAbsolutePoint = new QGroupBox( this );
+  GroupAbsolutePoint->setObjectName( "GroupPoint" );
+  GroupAbsolutePoint->setTitle( tr("BASE_POINT") );
+  QGridLayout* GroupPointLayout = new QGridLayout( GroupAbsolutePoint );
+  GroupPointLayout->setAlignment( Qt::AlignTop );
+  GroupPointLayout->setSpacing( 6 ); GroupPointLayout->setMargin( 11 );
+
+  TextLabelX = new QLabel( GroupAbsolutePoint );
+  TextLabelX->setObjectName( "TextLabelX" );
+  TextLabelX->setText( tr("X:") );
+  GroupPointLayout->addWidget( TextLabelX, 0, 0 );
+  
+  SpinBox_X = new QtxDoubleSpinBox( min, max, step, GroupAbsolutePoint );
+  SpinBox_X->setObjectName("SpinBox_X" );
+  SpinBox_X->setPrecision( precision );
+  GroupPointLayout->addWidget( SpinBox_X, 0, 1 );
+
+  TextLabelY = new QLabel( GroupAbsolutePoint );
+  TextLabelY->setObjectName( "TextLabelY" );
+  TextLabelY->setText( tr("Y:") );
+  GroupPointLayout->addWidget( TextLabelY, 0, 2 );
+
+  SpinBox_Y = new QtxDoubleSpinBox( min, max, step, GroupAbsolutePoint );
+  SpinBox_Y->setObjectName("SpinBox_Y" );
+  SpinBox_Y->setPrecision( precision );
+  GroupPointLayout->addWidget( SpinBox_Y, 0, 3 );
+
+  TextLabelZ = new QLabel( GroupAbsolutePoint );
+  TextLabelZ->setObjectName( "TextLabelZ" );
+  TextLabelZ->setText( tr("Z:") );
+  GroupPointLayout->addWidget( TextLabelZ, 0, 4 );
+
+  SpinBox_Z = new QtxDoubleSpinBox( min, max, step, GroupAbsolutePoint );
+  SpinBox_Z->setObjectName("SpinBox_Z" );
+  SpinBox_Z->setPrecision( precision );
+  GroupPointLayout->addWidget( SpinBox_Z, 0, 5 );
+
+  resetButton  = new QPushButton( GroupAbsolutePoint );
+  resetButton->setObjectName( "resetButton" );
+  resetButton->setText( tr( "RESET"  ) );
+  GroupPointLayout->addWidget( resetButton, 0, 6 );
+
+  // Group Direction
+  GroupAbsoluteDirection = new QGroupBox( this );
+  GroupAbsoluteDirection->setObjectName( "GroupDirection" );
+  GroupAbsoluteDirection->setTitle( tr("DIRECTION") );
+  QGridLayout* GroupDirectionLayout = new QGridLayout( GroupAbsoluteDirection );
+  GroupDirectionLayout->setAlignment( Qt::AlignTop );
+  GroupDirectionLayout->setSpacing( 6 );
+  GroupDirectionLayout->setMargin( 11 );
+  
+  TextLabelDx = new QLabel( GroupAbsoluteDirection );
+  TextLabelDx->setObjectName( "TextLabelDx" );
+  TextLabelDx->setText( tr("Dx:") );
+  GroupDirectionLayout->addWidget( TextLabelDx, 0, 0 );
+  
+  SpinBox_Dx = new QtxDoubleSpinBox( min, max, step, GroupAbsoluteDirection );
+  SpinBox_Dx->setObjectName("SpinBox_Dx" );
+  SpinBox_Dx->setPrecision( precision );
+  GroupDirectionLayout->addWidget( SpinBox_Dx, 0, 1 );
+
+  TextLabelDy = new QLabel( GroupAbsoluteDirection );
+  TextLabelDy->setObjectName( "TextLabelDy" );
+  TextLabelDy->setText( tr("Dy:") );
+  GroupDirectionLayout->addWidget( TextLabelDy, 0, 2 );
+  
+  SpinBox_Dy = new QtxDoubleSpinBox( min, max, step, GroupAbsoluteDirection );
+  SpinBox_Dy->setObjectName("SpinBox_Dy" );
+  SpinBox_Dy->setPrecision( precision );
+  GroupDirectionLayout->addWidget( SpinBox_Dy, 0, 3 );
+
+  TextLabelDz = new QLabel( GroupAbsoluteDirection );
+  TextLabelDz->setObjectName( "TextLabelDz" );
+  TextLabelDz->setText( tr("Dz:") );
+  GroupDirectionLayout->addWidget( TextLabelDz, 0, 4 );
+  
+  SpinBox_Dz = new QtxDoubleSpinBox( min, max, step, GroupAbsoluteDirection );
+  SpinBox_Dz->setObjectName("SpinBox_Dz" );
+  SpinBox_Dz->setPrecision( precision );
+  GroupDirectionLayout->addWidget( SpinBox_Dz, 0, 5 );
+
+  invertButton  = new QPushButton( GroupAbsoluteDirection );
+  invertButton->setObjectName( "invertButton" );
+  invertButton->setText( tr( "INVERT"  ) );
+  GroupDirectionLayout->addWidget( invertButton, 0, 6 );
+  CBAbsoluteOrientation = new QComboBox( GroupAbsoluteDirection );
+  CBAbsoluteOrientation->setObjectName( "AbsoluteOrientation" );
+  CBAbsoluteOrientation->insertItem( CBAbsoluteOrientation->count(), tr( "CUSTOM" ) );
+  CBAbsoluteOrientation->insertItem( CBAbsoluteOrientation->count(), tr( "||X-Y" ) );
+  CBAbsoluteOrientation->insertItem( CBAbsoluteOrientation->count(), tr( "||Y-Z" ) );
+  CBAbsoluteOrientation->insertItem( CBAbsoluteOrientation->count(), tr( "||Z-X" ) );
+  GroupDirectionLayout->addWidget( CBAbsoluteOrientation, 1, 0, 1, 6 );
+
+  QVBoxLayout* ModeActiveLayout = new QVBoxLayout();
+  ModeActiveLayout->setMargin( 11 ); ModeActiveLayout->setSpacing( 6 );
+  ModeActiveLayout->addWidget( GroupAbsolutePoint );
+  ModeActiveLayout->addWidget( GroupAbsoluteDirection );
+
+  QWidget* ModeActiveWidget = new QWidget( this );
+  ModeActiveWidget->setLayout( ModeActiveLayout );
+
+  /**********************   Mode Relative   **********************/
+  /* Controls for relative mode of clipping plane:
+     Distance - Value from 0 to 1.
+     Specifies the distance from the minimum value in a given direction of bounding box to the current position
+     Rotation1, Rotation2 - turn angles of cutting plane in given directions
+     Orientation - direction of cutting plane
+   */
+  QGroupBox* GroupParameters = new QGroupBox( tr("PARAMETERS"), this );
+  QGridLayout* GroupParametersLayout = new QGridLayout( GroupParameters );
+  GroupParametersLayout->setMargin( 11 ); GroupParametersLayout->setSpacing( 6 );
+
+  TextLabelOrientation = new QLabel( tr("ORIENTATION"), GroupParameters);
+  TextLabelOrientation->setObjectName( "TextLabelOrientation" );
+  GroupParametersLayout->addWidget( TextLabelOrientation, 0, 0 );
+
+  CBRelativeOrientation = new QComboBox(GroupParameters);
+  CBRelativeOrientation->setObjectName( "RelativeOrientation" );
+  CBRelativeOrientation->addItem( tr("ALONG_XY") );
+  CBRelativeOrientation->addItem( tr("ALONG_YZ") );
+  CBRelativeOrientation->addItem( tr("ALONG_ZX") );
+  GroupParametersLayout->addWidget( CBRelativeOrientation, 0, 1 );
+
+  TextLabelDistance = new QLabel( tr("DISTANCE"), GroupParameters );
+  TextLabelDistance->setObjectName( "TextLabelDistance" );
+  GroupParametersLayout->addWidget( TextLabelDistance, 1, 0 );
+  
+  SpinSliderDistance = new QtxDoubleSpinSlider( 0., 1., 0.01, GroupParameters );
+  SpinSliderDistance->setObjectName( "SpinSliderDistance" );
+  SpinSliderDistance->setPrecision( precision );
+  QFont fnt = SpinSliderDistance->font(); fnt.setBold( true ); SpinSliderDistance->setFont( fnt );
+  GroupParametersLayout->addWidget( SpinSliderDistance, 1, 1 );
+
+  QString aUnitRot = "\xB0";
+
+  TextLabelRotation1 = new QLabel( tr("ROTATION_AROUND_X_Y2Z"), GroupParameters );
+  TextLabelRotation1->setObjectName( "TextLabelRotation1" );
+  GroupParametersLayout->addWidget( TextLabelRotation1, 2, 0 );
+  
+  SpinSliderRotation1 = new QtxIntSpinSlider( -180, 180, 1, GroupParameters );
+  SpinSliderRotation1->setObjectName( "SpinSliderRotation1" );
+  SpinSliderRotation1->setUnit( aUnitRot );
+  SpinSliderRotation1->setFont( fnt );
+  GroupParametersLayout->addWidget( SpinSliderRotation1, 2, 1 );
+
+  TextLabelRotation2 = new QLabel(tr("ROTATION_AROUND_Y_X2Z"), GroupParameters);
+  TextLabelRotation2->setObjectName( "TextLabelRotation2" );
+  TextLabelRotation2->setObjectName( "TextLabelRotation2" );
+  GroupParametersLayout->addWidget( TextLabelRotation2, 3, 0 );
+
+  SpinSliderRotation2 = new QtxIntSpinSlider( -180, 180, 1, GroupParameters );
+  SpinSliderRotation2->setObjectName( "SpinSliderRotation2" );
+  SpinSliderRotation2->setUnit( aUnitRot );
+  SpinSliderRotation2->setFont( fnt );
+  GroupParametersLayout->addWidget( SpinSliderRotation2, 3, 1 );
+
+  /***************************************************************/
+  QGroupBox* CheckBoxWidget = new QGroupBox( this );
+  QHBoxLayout* CheckBoxLayout = new QHBoxLayout( CheckBoxWidget );
+  
+  PreviewCheckBox = new QCheckBox( tr("PREVIEW"), CheckBoxWidget );
+  PreviewCheckBox->setObjectName( "PreviewCheckBox" );
+  PreviewCheckBox->setChecked( true );
+  CheckBoxLayout->addWidget( PreviewCheckBox, 0, Qt::AlignCenter );
+  
+  AutoApplyCheckBox = new QCheckBox( tr("AUTO_APPLY"), CheckBoxWidget );
+  AutoApplyCheckBox->setObjectName( "AutoApplyCheckBox" );
+  CheckBoxLayout->addWidget( AutoApplyCheckBox, 0, Qt::AlignCenter );
+
+  /***************************************************************/
+  QGroupBox* GroupButtons = new QGroupBox( this );
+  QHBoxLayout* GroupButtonsLayout = new QHBoxLayout( GroupButtons );
+  GroupButtonsLayout->setAlignment( Qt::AlignTop );
+  GroupButtonsLayout->setMargin( 11 ); GroupButtonsLayout->setSpacing( 6 );
+  
+  buttonOk = new QPushButton( GroupButtons );
+  buttonOk->setObjectName( "buttonOk" );
+  buttonOk->setText( tr( "BUT_APPLY_AND_CLOSE"  ) );
+  buttonOk->setAutoDefault( TRUE );
+  buttonOk->setDefault( TRUE );
+  GroupButtonsLayout->addWidget( buttonOk );
+
+  buttonApply = new QPushButton( GroupButtons );
+  buttonApply->setObjectName( "buttonApply" );
+  buttonApply->setText( tr( "BUT_APPLY"  ) );
+  buttonApply->setAutoDefault( TRUE );
+  buttonApply->setDefault( TRUE );
+  GroupButtonsLayout->addWidget( buttonApply );
+
+  GroupButtonsLayout->addStretch();
+  
+  buttonClose = new QPushButton( GroupButtons );
+  buttonClose->setObjectName( "buttonClose" );
+  buttonClose->setText( tr( "BUT_CLOSE"  ) );
+  buttonClose->setAutoDefault( TRUE );
+  GroupButtonsLayout->addWidget( buttonClose );
+
+  QPushButton* buttonHelp = new QPushButton( tr( "SMESH_BUT_HELP" ), GroupButtons );
+  buttonHelp->setAutoDefault( TRUE );
+  GroupButtonsLayout->addWidget( buttonHelp );
+
+  /***************************************************************/
+  ModeStackedLayout->addWidget( ModeActiveWidget );
+  ModeStackedLayout->addWidget( GroupParameters );
+
+  topLayout->addWidget( GroupPlanes );
+  topLayout->addLayout( ModeStackedLayout );
+  topLayout->addWidget( CheckBoxWidget );
+  topLayout->addWidget( GroupButtons );
+
+  this->setLayout( topLayout );
+
+  // Initializations
+  initParam();
+
+  // Signals and slots connections
+  connect( ComboBoxPlanes, SIGNAL( activated( int ) ), this, SLOT( onSelectPlane( int ) ) );
+  connect( isActivePlane,  SIGNAL ( toggled ( bool ) ),  this, SLOT( onValueChanged() ) );
+  connect( buttonNew, SIGNAL( clicked() ), buttonNew, SLOT( showMenu() ) );
+  connect( buttonDelete, SIGNAL( clicked() ), this, SLOT( ClickOnDelete() ) );
+  connect( buttonDisableAll, SIGNAL( clicked() ), this, SLOT( ClickOnDisableAll() ) );
+
+  connect( resetButton,  SIGNAL (clicked() ), this, SLOT( onReset() ) );
+  connect( invertButton, SIGNAL (clicked() ), this, SLOT( onInvert() ) ) ;
+  connect( SpinBox_X,  SIGNAL ( valueChanged( double ) ),  this, SLOT( onValueChanged() ) );
+  connect( SpinBox_Y,  SIGNAL ( valueChanged( double ) ),  this, SLOT( onValueChanged() ) );
+  connect( SpinBox_Z,  SIGNAL ( valueChanged( double ) ),  this, SLOT( onValueChanged() ) );
+  connect( SpinBox_Dx, SIGNAL ( valueChanged( double ) ),  this, SLOT( onValueChanged() ) );
+  connect( SpinBox_Dy, SIGNAL ( valueChanged( double ) ),  this, SLOT( onValueChanged() ) );
+  connect( SpinBox_Dz, SIGNAL ( valueChanged( double ) ),  this, SLOT( onValueChanged() ) );
+  connect( CBAbsoluteOrientation, SIGNAL ( activated ( int ) ), this, SLOT( onOrientationAbsoluteChanged( int ) ) ) ;
+
+  connect( CBRelativeOrientation, SIGNAL( activated( int ) ), this, SLOT( onOrientationRelativeChanged( int ) ) );
+  connect( SpinSliderDistance, SIGNAL( valueChanged( double ) ),  this, SLOT( onValueChanged() ) );
+  connect( SpinSliderRotation1, SIGNAL( valueChanged( int ) ), this, SLOT( onValueChanged() ) );
+  connect( SpinSliderRotation2, SIGNAL( valueChanged( int ) ), this, SLOT( onValueChanged() ) );
+
+  connect( PreviewCheckBox, SIGNAL ( toggled ( bool ) ), this, SLOT( onPreview( bool ) ) ) ;
+  connect( AutoApplyCheckBox, SIGNAL ( toggled( bool ) ), this, SLOT( onAutoApply( bool ) ) );
+  
+  connect( buttonClose, SIGNAL( clicked() ), this, SLOT( ClickOnClose() ) ) ;
+  connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
+  connect( buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
+  connect( buttonHelp, SIGNAL( clicked() ), this, SLOT( ClickOnHelp() ) );
+
+  myBusy = false;
+  myIsSelectPlane = false;
+  myIsPlaneCreation = false;
+  myIsUpdatingControls = false;
+  myModel = model;
+
+  myModel->getViewer3d()->InitActiveViews();
+
+  OCCViewer_ViewManager* aViewMgr = (OCCViewer_ViewManager*) myModel->getViewManager();
+  myInteractor = new OCCViewer_ClipPlaneInteractor( aViewMgr, this );
+  connect( myInteractor, SIGNAL( planeClicked( const Handle_AIS_Plane& ) ), SLOT( onPlaneClicked( const Handle_AIS_Plane& ) ) );
+  connect( myInteractor, SIGNAL( planeDragged( const Handle_AIS_Plane& ) ), SLOT( onPlaneDragged( const Handle_AIS_Plane& ) ) );
+
+  myLocalPlanes = myModel->getClipPlanes();
+  synchronize();
+}
+
+/*!
+  Destructor
+  Destroys the object and frees any allocated resources
+*/
+OCCViewer_ClippingDlg::~OCCViewer_ClippingDlg()
+{
+  myLocalPlanes.clear();
+}
+
+/*!
+  Custom handling of close event: erases preview
+*/
+void OCCViewer_ClippingDlg::closeEvent( QCloseEvent* e )
+{
+  erasePreview();
+  QDialog::closeEvent( e );
+  OCCViewer_ViewWindow* v = qobject_cast<OCCViewer_ViewWindow*>(parent());
+  if(v)
+    v->onClipping(false);
+}
+
+/*!
+  Custom handling of show event: displays preview
+*/
+void OCCViewer_ClippingDlg::showEvent( QShowEvent* e )
+{
+  QDialog::showEvent( e );
+  onPreview( PreviewCheckBox->isChecked() );
+}
+
+/*!
+  Custom handling of hide event: erases preview
+*/
+void OCCViewer_ClippingDlg::hideEvent( QHideEvent* e )
+{
+  erasePreview();
+  QDialog::hideEvent( e );
+  OCCViewer_ViewWindow* v = qobject_cast<OCCViewer_ViewWindow*>(parent());
+  if(v)
+    v->onClipping(false);
+
+}
+
+/*!
+  Initialization of initial values of widgets
+*/
+void OCCViewer_ClippingDlg::initParam()
+{
+  SpinBox_X->setValue( 0.0 );
+  SpinBox_Y->setValue( 0.0 );
+  SpinBox_Z->setValue( 0.0 );
+
+  SpinBox_Dx->setValue( 1.0 );
+  SpinBox_Dy->setValue( 1.0 );
+  SpinBox_Dz->setValue( 1.0 );
+
+  CBAbsoluteOrientation->setCurrentIndex(0);
+
+  SpinSliderDistance->setValue( 0.5 );
+  SpinSliderRotation1->setValue( 0 );
+  SpinSliderRotation2->setValue( 0 );
+  CBRelativeOrientation->setCurrentIndex( 0 );
+
+  isActivePlane->setChecked( true );
+}
+
+/*!
+  Set plane parameters from widgets.
+*/
+void OCCViewer_ClippingDlg::setPlaneParam( OCCViewer_ClipPlane& thePlane )
+{
+  OCCViewer_ClipPlane::PlaneMode aMode = currentPlaneMode();
+
+  thePlane.Mode = aMode;
+
+  if ( aMode == OCCViewer_ClipPlane::Absolute )
+  {
+    if( qFuzzyIsNull( SpinBox_Dx->value() ) && 
+        qFuzzyIsNull( SpinBox_Dy->value() ) && 
+        qFuzzyIsNull( SpinBox_Dz->value() ) ) {
+      return;
+    }
+  }
+
+  thePlane.OrientationType = (aMode == OCCViewer_ClipPlane::Absolute)
+    ? CBAbsoluteOrientation->currentIndex()
+    : CBRelativeOrientation->currentIndex();
+
+  // Get XYZ, DXYZ
+  if ( aMode == OCCViewer_ClipPlane::Absolute )
+  {
+    if ( thePlane.OrientationType == OCCViewer_ClipPlane::AbsoluteCustom )
+    {
+      thePlane.AbsoluteOrientation.Dx = SpinBox_Dx->value();
+      thePlane.AbsoluteOrientation.Dy = SpinBox_Dy->value();
+      thePlane.AbsoluteOrientation.Dz = SpinBox_Dz->value();
+    }
+    else
+    {
+      thePlane.AbsoluteOrientation.IsInvert = SpinBox_Dx->value() < 0.0
+                                           || SpinBox_Dy->value() < 0.0
+                                           || SpinBox_Dz->value() < 0.0;
+    }
+
+    thePlane.X = SpinBox_X->value();
+    thePlane.Y = SpinBox_Y->value();
+    thePlane.Z = SpinBox_Z->value();
+  }
+  else
+  {
+    thePlane.RelativeOrientation.Rotation1 = SpinSliderRotation1->value();
+    thePlane.RelativeOrientation.Rotation2 = SpinSliderRotation2->value();
+
+    double aPlaneDx = 0.0;
+    double aPlaneDy = 0.0;
+    double aPlaneDz = 0.0;
+    double aX = 0.0;
+    double aY = 0.0;
+    double aZ = 0.0;
+
+    OCCViewer_ClipPlane::RelativeToDXYZ( thePlane.OrientationType,
+                                         thePlane.RelativeOrientation.Rotation1,
+                                         thePlane.RelativeOrientation.Rotation2,
+                                         aPlaneDx, aPlaneDy, aPlaneDz );
+
+    DistanceToXYZ( myModel->getAISContext(),
+                   myModel->trihedronSize(),
+                   SpinSliderDistance->value(),
+                   aPlaneDx, aPlaneDy, aPlaneDz,
+                   aX, aY, aZ );
+
+    thePlane.X = aX;
+    thePlane.Y = aY;
+    thePlane.Z = aZ;
+  }
+
+  thePlane.IsOn = isActivePlane->isChecked();
+}
+
+/*!
+  Synchronize dialog's widgets with data
+*/
+void OCCViewer_ClippingDlg::synchronize()
+{
+  ComboBoxPlanes->clear();
+  int aNbPlanesAbsolute = myLocalPlanes.size();
+
+  QString aName;
+  for(int i = 1; i<=aNbPlanesAbsolute; i++ ) {
+    aName = QString("Plane %1").arg(i);
+    ComboBoxPlanes->addItem( aName );
+  }
+
+  int aPos = ComboBoxPlanes->count() - 1;
+  ComboBoxPlanes->setCurrentIndex( aPos );
+
+  bool anIsControlsEnable = ( aPos >= 0 );
+  if ( anIsControlsEnable ) {
+    onSelectPlane( aPos );
+  }
+  else {
+    ComboBoxPlanes->addItem( tr( "NO_PLANES" ) );
+    initParam();
+  }
+  if ( currentPlaneMode() == OCCViewer_ClipPlane::Absolute )
+  {
+    SpinBox_X->setEnabled( anIsControlsEnable );
+    SpinBox_Y->setEnabled( anIsControlsEnable );
+    SpinBox_Z->setEnabled( anIsControlsEnable );
+    SpinBox_Dx->setEnabled( anIsControlsEnable );
+    SpinBox_Dy->setEnabled( anIsControlsEnable );
+    SpinBox_Dz->setEnabled( anIsControlsEnable );
+    CBAbsoluteOrientation->setEnabled( anIsControlsEnable );
+    invertButton->setEnabled( anIsControlsEnable );
+    resetButton->setEnabled( anIsControlsEnable );
+  }
+  else if ( currentPlaneMode() == OCCViewer_ClipPlane::Relative )
+  {
+    CBRelativeOrientation->setEnabled( anIsControlsEnable );
+    SpinSliderDistance->setEnabled( anIsControlsEnable );
+    SpinSliderRotation1->setEnabled( anIsControlsEnable );
+    SpinSliderRotation2->setEnabled( anIsControlsEnable );
+    isActivePlane->setEnabled( anIsControlsEnable );
+  }
+  isActivePlane->setEnabled( anIsControlsEnable );
+}
+
+/*!
+  Displays preview of clipping plane
+*/
+void OCCViewer_ClippingDlg::displayPreview()
+{
+  if ( myBusy || !isValid() || !myModel)
+    return;
+
+  Handle(AIS_InteractiveContext) ic = myModel->getAISContext();
+  
+  int aCurPlaneIndex = ComboBoxPlanes->currentIndex();
+
+  for ( int i=0; i < clipPlanesCount(); i++ ) {
+    OCCViewer_ClipPlane& aClipPlane = getClipPlane(i);
+    if ( aClipPlane.IsOn ) {
+      Handle(AIS_Plane) myPreviewPlane;
+      double aSize;
+      gp_Pnt aBasePnt;
+      gp_Dir aNormal;
+      clipPlaneParams(aClipPlane, ic, aSize, aBasePnt, aNormal, myModel->trihedronSize());
+      myPreviewPlane = new AIS_Plane( new Geom_Plane( aBasePnt, aNormal ), aBasePnt );
+      myPreviewPlane->SetTypeOfSensitivity( Select3D_TOS_INTERIOR );
+      myPreviewPlane->SetSize( aSize, aSize );
+      ic->SetWidth( myPreviewPlane, 10, false );
+      ic->SetMaterial( myPreviewPlane, Graphic3d_NOM_PLASTIC, false );
+      ic->SetTransparency( myPreviewPlane, 0.5, false );
+      Quantity_Color c = (aCurPlaneIndex == i) ? Quantity_Color( 255. / 255., 70. / 255., 0. / 255., Quantity_TOC_RGB ) : Quantity_Color( 85 / 255., 85 / 255., 255 / 255., Quantity_TOC_RGB );
+      ic->SetColor( myPreviewPlane, c , false );
+      ic->Display( myPreviewPlane, 1, 0, false );
+      myPreviewPlaneVector.push_back( myPreviewPlane );
+    }
+  }
+  myModel->update();
+
+  double aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
+  getMinMaxFromContext( ic, myModel->trihedronSize(), aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
+  gp_Pnt aRotationCenter( (aXmax + aXmin) * 0.5,
+                          (aYmax + aYmin) * 0.5,
+                          (aZmax + aZmin) * 0.5 );
+  Bnd_Box aMinMax;
+  aMinMax.Update( aXmin, aYmin, aZmin, aXmax, aYmax, aZmax );
+
+  myInteractor->setPlanes( myPreviewPlaneVector );
+  myInteractor->setRotationCenter( aRotationCenter );
+  myInteractor->setMinMax( aMinMax );
+  myInteractor->setEnabled( true );
+}
+
+void OCCViewer_ClippingDlg::updatePreview() {
+  int aCurPlaneIndex = ComboBoxPlanes->currentIndex();
+  int count = clipPlanesCount();
+  if ( myBusy || 
+       !isValid() || 
+       myIsPlaneCreation ||
+       !myModel || 
+       count == 0 || 
+       (aCurPlaneIndex +1 > count) ||
+       !PreviewCheckBox->isChecked())
+    return;
+  
+  Handle(AIS_InteractiveContext) ic = myModel->getAISContext();
+  
+  OCCViewer_ClipPlane& aClipPlane = getClipPlane(aCurPlaneIndex);
+  Handle(AIS_Plane) myPreviewPlane;
+
+  if (aClipPlane.IsOn) {
+    double aSize;
+    gp_Pnt aBasePnt;
+    gp_Dir aNormal;
+    clipPlaneParams(aClipPlane, ic, aSize, aBasePnt, aNormal, myModel->trihedronSize());
+    if(myPreviewPlaneVector.size() < clipPlanesCount()) {
+      myPreviewPlaneVector.resize(clipPlanesCount());
+    }
+    myPreviewPlane = myPreviewPlaneVector[aCurPlaneIndex];
+    if(myPreviewPlane.IsNull()) {
+      //Plane was not created
+      myPreviewPlane = new AIS_Plane( new Geom_Plane( aBasePnt, aNormal ), aBasePnt );
+      myPreviewPlane->SetTypeOfSensitivity( Select3D_TOS_INTERIOR );
+      myPreviewPlane->SetSize( aSize, aSize );
+      ic->Display( myPreviewPlane, 1, 0, false );
+      ic->SetWidth( myPreviewPlane, 10, false );
+      ic->SetMaterial( myPreviewPlane, Graphic3d_NOM_PLASTIC, false );
+      ic->SetTransparency( myPreviewPlane, 0.5, false );
+      myPreviewPlaneVector[aCurPlaneIndex] = myPreviewPlane;
+    } else {      
+      myPreviewPlane->SetComponent( new Geom_Plane( aBasePnt, aNormal ) );
+      myPreviewPlane->SetCenter( aBasePnt );
+      myPreviewPlane->SetSize( aSize, aSize ); 
+    }
+
+    ic->SetColor( myPreviewPlane, Quantity_Color( 255. / 255., 70. / 255., 0. / 255., Quantity_TOC_RGB ), false );
+    ic->Update( myPreviewPlane, Standard_False );
+  } else {
+    if(myPreviewPlaneVector.size() > aCurPlaneIndex ) {
+      myPreviewPlane = myPreviewPlaneVector[aCurPlaneIndex];
+      if(ic->IsDisplayed(myPreviewPlane)) {
+       ic->Erase( myPreviewPlane, false );
+       ic->Remove( myPreviewPlane, false );
+      }
+      myPreviewPlaneVector[aCurPlaneIndex].Nullify();
+    }
+  }
+  for(int i = 0; i < myPreviewPlaneVector.size(); i++) {
+    if( i == aCurPlaneIndex ) continue;
+    if(!myPreviewPlaneVector[i].IsNull())
+      ic->SetColor( myPreviewPlaneVector[i], Quantity_Color( 85 / 255., 85 / 255., 255 / 255., Quantity_TOC_RGB ), false );
+  }
+  myModel->update();
+
+  double aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
+  getMinMaxFromContext( ic, myModel->trihedronSize(), aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
+  gp_Pnt aRotationCenter( (aXmax + aXmin) * 0.5,
+                          (aYmax + aYmin) * 0.5,
+                          (aZmax + aZmin) * 0.5 );
+  Bnd_Box aMinMax;
+  aMinMax.Update( aXmin, aYmin, aZmin, aXmax, aYmax, aZmax );
+
+  myInteractor->setPlanes( myPreviewPlaneVector );
+  myInteractor->setRotationCenter( aRotationCenter );
+  myInteractor->setMinMax( aMinMax );
+}
+
+/*!
+  Erases preview of clipping plane
+*/
+void OCCViewer_ClippingDlg::erasePreview()
+{
+  if ( !myModel )
+    return;
+
+  Handle(AIS_InteractiveContext) ic = myModel->getAISContext();
+
+  for ( int i=0; i < myPreviewPlaneVector.size(); i++ ) {
+  Handle(AIS_Plane) myPreviewPlane = myPreviewPlaneVector[i];
+    if ( !myPreviewPlane.IsNull() && ic->IsDisplayed( myPreviewPlane ) ) {
+      ic->Erase( myPreviewPlane, false );
+      ic->Remove( myPreviewPlane, false );
+      myPreviewPlane.Nullify();
+    }
+  }
+  myPreviewPlaneVector.clear();
+  myModel->update();
+  myInteractor->setEnabled( false );
+}
+
+/*!
+  Return true if plane parameters are valid
+*/
+bool OCCViewer_ClippingDlg::isValid()
+{
+  return ( SpinBox_Dx->value() !=0 || SpinBox_Dy->value() !=0 || SpinBox_Dz->value() !=0 );
+}
+
+/*!
+  Update view after changes
+*/
+void OCCViewer_ClippingDlg::updateClipping()
+{
+  if (PreviewCheckBox->isChecked() || AutoApplyCheckBox->isChecked())
+  {
+    if (AutoApplyCheckBox->isChecked()) {
+      onApply();
+    }
+    
+    if (!PreviewCheckBox->isChecked())
+      myModel->update();
+    else 
+      updatePreview();
+  }
+}
+
+/*!
+  Updates state of user controls.
+*/
+void OCCViewer_ClippingDlg::updateControls()
+{
+  if ( clipPlanesCount() == 0 )
+  {
+    initParam();
+    return;
+  }
+
+  int aPlaneIdx = ComboBoxPlanes->currentIndex();
+
+  OCCViewer_ClipPlane& aPlane = getClipPlane( aPlaneIdx );
+
+  double aPlaneDx  = 0.0;
+  double aPlaneDy  = 0.0;
+  double aPlaneDz  = 0.0;
+  double aDistance = 0.0;
+  aPlane.OrientationToXYZ( aPlaneDx, aPlaneDy, aPlaneDz );
+
+  if ( aPlane.Mode == OCCViewer_ClipPlane::Absolute )
+  {
+    ModeStackedLayout->setCurrentIndex( 0 );
+
+    // Set plane parameters in the dialog
+    SpinBox_X->setValue( aPlane.X );
+    SpinBox_Y->setValue( aPlane.Y );
+    SpinBox_Z->setValue( aPlane.Z );
+    SpinBox_Dx->setValue( aPlaneDx );
+    SpinBox_Dy->setValue( aPlaneDy );
+    SpinBox_Dz->setValue( aPlaneDz );
+    CBAbsoluteOrientation->setCurrentIndex( aPlane.OrientationType );
+    onOrientationAbsoluteChanged( aPlane.OrientationType );
+  }
+  else if( aPlane.Mode == OCCViewer_ClipPlane::Relative )
+  {
+    ModeStackedLayout->setCurrentIndex( 1 );
+
+    // Set plane parameters in the dialog
+    SpinSliderRotation1->setValue( int( aPlane.RelativeOrientation.Rotation1 ) );
+    SpinSliderRotation2->setValue( int( aPlane.RelativeOrientation.Rotation2 ) );
+
+    XYZToDistance( myModel->getAISContext(),
+                   myModel->trihedronSize(),
+                   aPlane.X, aPlane.Y, aPlane.Z,
+                   aPlaneDx, aPlaneDy, aPlaneDz,
+                   aDistance );
+
+    SpinSliderDistance->setValue( aDistance );
+
+    CBRelativeOrientation->setCurrentIndex( aPlane.OrientationType );
+    onOrientationRelativeChanged( aPlane.OrientationType );
+  }
+
+  isActivePlane->setChecked( aPlane.IsOn );
+}
+
+/*!
+  SLOT on new button click: create a new clipping plane
+*/
+void OCCViewer_ClippingDlg::ClickOnNew()
+{
+  OCCViewer_ClipPlane aClipPlane;
+
+  // init controls state
+  myIsUpdatingControls = true;
+  initParam();
+  myIsUpdatingControls = false;
+
+  // init plane according to the state of controls
+  setPlaneParam( aClipPlane );
+
+  // add plane
+  myLocalPlanes.push_back( aClipPlane );
+  synchronize();
+}
+
+/*!
+  SLOT on delete button click: Delete selected clipping plane
+*/
+void OCCViewer_ClippingDlg::ClickOnDelete()
+{
+  int aPlaneIndex = ComboBoxPlanes->currentIndex();
+  if ( (clipPlanesCount() == 0) || (aPlaneIndex+1 > clipPlanesCount()))
+    return;
+
+  myLocalPlanes.erase(myLocalPlanes.begin() + aPlaneIndex);
+
+  Handle(AIS_InteractiveContext) ic = myModel->getAISContext();
+
+  if(aPlaneIndex+1 <= myPreviewPlaneVector.size()) {
+    Handle(AIS_Plane) myPreviewPlane = myPreviewPlaneVector[aPlaneIndex];
+    if ( !myPreviewPlane.IsNull() && ic->IsDisplayed( myPreviewPlane ) ) {
+      ic->Erase( myPreviewPlane, false );
+      ic->Remove( myPreviewPlane, false );
+    }
+    myPreviewPlaneVector.erase(myPreviewPlaneVector.begin() + aPlaneIndex);
+  }
+  synchronize();
+  if (AutoApplyCheckBox->isChecked()) {
+    onApply();
+  }
+  myModel->update();
+}
+
+/*!
+  SLOT on disable all button click: Restore initial state of viewer,
+  erase all clipping planes
+*/
+void OCCViewer_ClippingDlg::ClickOnDisableAll()
+{
+  AutoApplyCheckBox->setChecked (false);
+  int aClipPlanesCount = clipPlanesCount();
+  for ( int anIndex = 0; anIndex < aClipPlanesCount; anIndex++)
+  {
+    OCCViewer_ClipPlane& aPlane = getClipPlane(anIndex);
+    aPlane.IsOn = false;
+  }
+  erasePreview();
+  isActivePlane->setChecked(false);
+  myModel->setClipPlanes(myLocalPlanes);
+  myModel->update();
+}
+
+/*!
+  SLOT on ok button click: sets cutting plane and closes dialog
+*/
+void OCCViewer_ClippingDlg::ClickOnOk()
+{
+  onApply();
+  ClickOnClose();
+}
+
+/*!
+  SLOT on Apply button click: sets cutting plane and update viewer
+*/
+void OCCViewer_ClippingDlg::ClickOnApply()
+{
+  onApply();
+  myModel->update();
+}
+
+/*!
+  SLOT on close button click: erases preview and rejects dialog
+*/
+void OCCViewer_ClippingDlg::ClickOnClose()
+{
+  erasePreview();
+  OCCViewer_ViewWindow* v = qobject_cast<OCCViewer_ViewWindow*>(parent());
+  if(v)
+    v->onClipping(false);
+}
+
+/*!
+  SLOT on help button click: opens a help page
+*/
+void OCCViewer_ClippingDlg::ClickOnHelp()
+{
+  SUIT_Application* app = SUIT_Session::session()->activeApplication();
+  if ( app )
+    app->onHelpContextModule( "GUI", "occ_3d_viewer_page.html", "clipping_planes" );
+}
+
+/*!
+  Set absolute mode of clipping plane
+*/
+void OCCViewer_ClippingDlg::onModeAbsolute()
+{
+  myIsPlaneCreation = true;
+  ModeStackedLayout->setCurrentIndex(0);
+  ClickOnNew();
+  myIsPlaneCreation = false;
+  updateClipping();
+}
+
+/*!
+  Set relative mode of clipping plane
+*/
+void OCCViewer_ClippingDlg::onModeRelative()
+{
+  myIsPlaneCreation = true;
+  ModeStackedLayout->setCurrentIndex(1);
+  ClickOnNew();
+  myIsPlaneCreation = false;
+  SetCurrentPlaneParam();
+  updateClipping();
+}
+
+/*!
+  SLOT: called on value of clipping plane changed
+*/
+void OCCViewer_ClippingDlg::onValueChanged()
+{
+  if ( myIsUpdatingControls )
+  {
+    return;
+  }
+
+  SetCurrentPlaneParam();
+
+  if ( myIsSelectPlane )
+  {
+    return;
+  }
+
+  updateClipping();
+}
+
+/*!
+  Set current parameters of selected plane
+*/
+void OCCViewer_ClippingDlg::onSelectPlane ( int theIndex )
+{
+  if ( clipPlanesCount() == 0 )
+  {
+    return;
+  }
+
+  OCCViewer_ClipPlane& aClipPlane = getClipPlane( theIndex );
+
+  myIsSelectPlane = true;
+  updateControls();
+  ComboBoxPlanes->setCurrentIndex( theIndex );
+  myIsSelectPlane = false;
+}
+
+/*!
+  Restore parameters of selected plane
+*/
+void OCCViewer_ClippingDlg::SetCurrentPlaneParam()
+{
+  if ( clipPlanesCount() == 0 || myIsSelectPlane || myBusy )
+  {
+    return;
+  }
+
+  int aCurPlaneIndex = ComboBoxPlanes->currentIndex();
+
+  OCCViewer_ClipPlane& aPlane = getClipPlane( aCurPlaneIndex );
+
+  setPlaneParam( aPlane );
+}
+
+/*!
+  SLOT on reset button click: sets default values
+*/
+void OCCViewer_ClippingDlg::onReset()
+{
+  myBusy = true;
+  SpinBox_X->setValue(0);
+  SpinBox_Y->setValue(0);
+  SpinBox_Z->setValue(0);
+  myBusy = false;
+
+  updateClipping();
+}
+
+/*!
+  SLOT on invert button click: inverts normal of cutting plane
+*/
+void OCCViewer_ClippingDlg::onInvert()
+{
+  double Dx = SpinBox_Dx->value();
+  double Dy = SpinBox_Dy->value();
+  double Dz = SpinBox_Dz->value();
+
+  myBusy = true;
+  SpinBox_Dx->setValue( -Dx );
+  SpinBox_Dy->setValue( -Dy );
+  SpinBox_Dz->setValue( -Dz );
+  myBusy = false;
+
+  if ( clipPlanesCount() != 0 )
+  {
+    int aCurPlaneIndex = ComboBoxPlanes->currentIndex();
+    OCCViewer_ClipPlane& aPlane = getClipPlane( aCurPlaneIndex );
+    aPlane.AbsoluteOrientation.IsInvert = !aPlane.AbsoluteOrientation.IsInvert;
+  }
+  updateClipping();
+}
+
+/*!
+  SLOT: called on orientation of clipping plane in absolute mode changed
+*/
+void OCCViewer_ClippingDlg::onOrientationAbsoluteChanged( int mode )
+{
+  bool isUserMode = (mode==0);
+
+  TextLabelX->setEnabled( isUserMode );
+  TextLabelY->setEnabled( isUserMode );
+  TextLabelZ->setEnabled( isUserMode );
+
+  SpinBox_X->setEnabled( isUserMode );
+  SpinBox_Y->setEnabled( isUserMode );
+  SpinBox_Z->setEnabled( isUserMode );
+
+  TextLabelDx->setEnabled( isUserMode );
+  TextLabelDy->setEnabled( isUserMode );
+  TextLabelDz->setEnabled( isUserMode );
+
+  SpinBox_Dx->setEnabled( isUserMode );
+  SpinBox_Dy->setEnabled( isUserMode );
+  SpinBox_Dz->setEnabled( isUserMode );
+
+  if ( !isUserMode ) {
+
+    double aDx = 0, aDy = 0, aDz = 0;
+
+    if ( mode == 1 )
+    {
+      aDz = 1;
+      TextLabelZ->setEnabled( true );
+      SpinBox_Z->setEnabled( true );
+      SpinBox_Z->setFocus();
+    }
+    else if ( mode == 2 )
+    {
+      aDx = 1;
+      TextLabelX->setEnabled( true );
+      SpinBox_X->setEnabled( true );
+      SpinBox_X->setFocus();
+    }
+    else if ( mode == 3 )
+    {
+      aDy = 1;
+      TextLabelY->setEnabled( true );
+      SpinBox_Y->setEnabled( true );
+      SpinBox_Y->setFocus();
+    }
+    
+    int aCurPlaneIndex = ComboBoxPlanes->currentIndex();
+    OCCViewer_ClipPlane& aPlane = getClipPlane( aCurPlaneIndex );
+    if ( aPlane.AbsoluteOrientation.IsInvert == true )
+    {
+      aDx = -aDx;
+      aDy = -aDy;
+      aDz = -aDz;
+    }
+    
+    myBusy = true;
+    SpinBox_Dx->setValue( aDx );
+    SpinBox_Dy->setValue( aDy );
+    SpinBox_Dz->setValue( aDz );
+    myBusy = false;
+  }
+
+  if ( !myIsUpdatingControls )
+  {
+    SetCurrentPlaneParam();
+    updateClipping();
+  }
+}
+
+/*!
+  SLOT: called on orientation of clipping plane in relative mode changed
+*/
+void OCCViewer_ClippingDlg::onOrientationRelativeChanged (int theItem)
+{
+  if ( clipPlanesCount() == 0 )
+    return;
+  
+  if ( theItem == 0 ) {
+    TextLabelRotation1->setText( tr( "ROTATION_AROUND_X_Y2Z" ) );
+    TextLabelRotation2->setText( tr( "ROTATION_AROUND_Y_X2Z" ) );
+  }
+  else if ( theItem == 1 ) {
+    TextLabelRotation1->setText( tr( "ROTATION_AROUND_Y_Z2X" ) );
+    TextLabelRotation2->setText( tr( "ROTATION_AROUND_Z_Y2X" ) );
+  }
+  else if ( theItem == 2 ) {
+    TextLabelRotation1->setText( tr( "ROTATION_AROUND_Z_X2Y" ) );
+    TextLabelRotation2->setText( tr( "ROTATION_AROUND_X_Z2Y" ) );
+  }
+
+  if ( !myIsUpdatingControls )
+  {
+    if( (QComboBox*)sender() == CBRelativeOrientation )
+    {
+      SetCurrentPlaneParam();
+    }
+
+    updateClipping();
+  }
+}
+
+/*!
+  SLOT: called on preview check box toggled
+*/
+void OCCViewer_ClippingDlg::onPreview( bool on )
+{
+  erasePreview();
+  if ( on ) 
+    displayPreview();
+}
+
+/*!
+  SLOT: called on Auto Apply check box toggled
+*/
+void OCCViewer_ClippingDlg::onAutoApply( bool toggled )
+{
+  if ( toggled ) {
+    onApply();
+    myModel->update();
+  }  
+}
+
+/*!
+  SLOT on Apply button click: sets cutting plane
+*/
+void OCCViewer_ClippingDlg::onApply()
+{
+  if ( myBusy )
+    return;
+  myIsSelectPlane = true;
+
+  qApp->processEvents();
+  QApplication::setOverrideCursor( Qt::WaitCursor );
+  qApp->processEvents();
+
+  myModel->setClipPlanes(myLocalPlanes);
+
+  QApplication::restoreOverrideCursor();
+  myIsSelectPlane = false;
+}
+
+/*!
+  SLOT: Called when clip plane is clicked in viewer.
+*/
+void OCCViewer_ClippingDlg::onPlaneClicked( const Handle(AIS_Plane)& thePlane )
+{
+  for ( int aPlaneIt = 0; aPlaneIt < myPreviewPlaneVector.size(); aPlaneIt++ )
+  {
+    Handle(AIS_Plane)& aPlane = myPreviewPlaneVector.at( aPlaneIt );
+    if ( aPlane != thePlane )
+    {
+      continue;
+    }
+
+    ComboBoxPlanes->setCurrentIndex( aPlaneIt );
+
+    break;
+  }
+}
+
+/*!
+  SLOT: Called when clip plane is changed by dragging in viewer.
+*/
+void OCCViewer_ClippingDlg::onPlaneDragged( const Handle(AIS_Plane)& thePlane )
+{
+  for ( int aPlaneIt = 0; aPlaneIt < myPreviewPlaneVector.size(); aPlaneIt++ )
+  {
+    Handle(AIS_Plane)& aPlane = myPreviewPlaneVector.at( aPlaneIt );
+    if ( aPlane != thePlane )
+    {
+      continue;
+    }
+
+    OCCViewer_ClipPlane& aClipPlane = getClipPlane( aPlaneIt );
+
+    gp_Pln aPln = thePlane->Component()->Pln();
+    const gp_Pnt& aPlaneP = aPln.Location();
+    const gp_Dir& aPlaneN = aPln.Axis().Direction();
+
+    aClipPlane.X  = aPlaneP.X();
+    aClipPlane.Y  = aPlaneP.Y();
+    aClipPlane.Z  = aPlaneP.Z();
+
+    if ( aClipPlane.Mode == OCCViewer_ClipPlane::Absolute )
+    {
+      if ( aClipPlane.OrientationType == OCCViewer_ClipPlane::AbsoluteCustom )
+      {
+        aClipPlane.AbsoluteOrientation.Dx = aPlaneN.X();
+        aClipPlane.AbsoluteOrientation.Dy = aPlaneN.Y();
+        aClipPlane.AbsoluteOrientation.Dz = aPlaneN.Z();
+      }
+    }
+    else
+    {
+      OCCViewer_ClipPlane::DXYZToRelative( aPlaneN.X(), aPlaneN.Y(), aPlaneN.Z(),
+                                           aClipPlane.OrientationType,
+                                           aClipPlane.RelativeOrientation.Rotation1,
+                                           aClipPlane.RelativeOrientation.Rotation2 );
+    }
+
+    myIsUpdatingControls = true;
+    updateControls();
+    myIsUpdatingControls = false;
+
+    if ( AutoApplyCheckBox->isChecked() )
+    {
+      onApply();
+    }
+
+    break;
+  }
+}
+
+OCCViewer_ClipPlane& OCCViewer_ClippingDlg::getClipPlane( int theIdx )
+{
+  return myLocalPlanes[theIdx];
+}
+
+int OCCViewer_ClippingDlg::clipPlanesCount()
+{
+  return myLocalPlanes.size();
+}
+
 OCCViewer_ClipPlane::PlaneMode OCCViewer_ClippingDlg::currentPlaneMode() const
 {
   return ModeStackedLayout->currentIndex() == 0
index cf6d3dd8d39cfc50765c374265ea82a984a6e0eb..cc20fd47394a9f9160a871aae4e57df86719a88a 100644 (file)
@@ -423,6 +423,17 @@ Qtx::BackgroundData OCCViewer_ViewFrame::background() const
   return getView(MAIN_VIEW)->background(); 
 }
 
+void OCCViewer_ViewFrame::showStaticTrihedron( bool on )
+{
+  if ( myPopupRequestedView )
+    myPopupRequestedView->showStaticTrihedron( on ); 
+  else {
+    foreach ( OCCViewer_ViewWindow* aView, myViews ) {
+      aView->showStaticTrihedron( on ); 
+    }
+  }
+}
+
 QImage OCCViewer_ViewFrame::dumpView()
 {
   foreach (OCCViewer_ViewWindow* aView, myViews) {
index 5c1b952973c1b4b3623c49f7b850117ac364472b..0f10e19f0f8090743d61846b05d2c32b2072bf18 100644 (file)
@@ -89,7 +89,9 @@ public:
   virtual Qtx::BackgroundData background() const;
   virtual void                setBackground( const Qtx::BackgroundData& );
 
-  virtual void   setDropDownButtons( bool );
+  virtual void showStaticTrihedron( bool );
+
+  virtual void setDropDownButtons( bool );
 
   virtual SUIT_CameraProperties cameraProperties();
 
index 1eb2ec85e31e17035d8df4596065c38a1a58a5e4..366d3bb0cc53954d530318213857a9872fda4120 100755 (executable)
@@ -153,11 +153,6 @@ OCCViewer_Viewer::OCCViewer_Viewer( bool DisplayTrihedron)
   // selection
   mySelectionEnabled = true;
   myMultiSelectionEnabled = true;
-  
-  
-  SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
-  if(resMgr)
-    myShowStaticTrihedron = resMgr->booleanValue( "3DViewer", "show_static_trihedron", true );
 }
 
 /*!
@@ -225,6 +220,9 @@ void OCCViewer_Viewer::initView( OCCViewer_ViewWindow* view )
     if ( vp3d )
     {
       vp3d->getView()->SetSurfaceDetail(V3d_TEX_ALL);
+      // connect signal from viewport
+      connect(vp3d, SIGNAL(vpClosed(OCCViewer_ViewPort3d*)), this, SLOT(onViewClosed(OCCViewer_ViewPort3d*)));
+      connect(vp3d, SIGNAL(vpMapped(OCCViewer_ViewPort3d*)), this, SLOT(onViewMapped(OCCViewer_ViewPort3d*)));
     }
   }
 }
@@ -243,9 +241,7 @@ SUIT_ViewWindow* OCCViewer_Viewer::createView( SUIT_Desktop* theDesktop )
   initView( vw );
   // set default background for view window
   vw->setBackground( background(0) ); // 0 means MAIN_VIEW (other views are not yet created here)
-  // connect signal from viewport
-  connect(view->getViewPort(), SIGNAL(vpClosed()), this, SLOT(onViewClosed()));
-  connect(view->getViewPort(), SIGNAL(vpMapped()), this, SLOT(onViewMapped()));
+
   return view;
 }
 
@@ -393,7 +389,7 @@ void OCCViewer_Viewer::onKeyPress(SUIT_ViewWindow* theWindow, QKeyEvent* theEven
   emit selectionChanged();
 }
 
-void OCCViewer_Viewer::onViewClosed()
+void OCCViewer_Viewer::onViewClosed(OCCViewer_ViewPort3d*)
 {
   Standard_Integer aViewsNb = 0;
   for ( myV3dViewer->InitActiveViews(); myV3dViewer->MoreActiveViews(); myV3dViewer->NextActiveViews())
@@ -404,9 +400,13 @@ void OCCViewer_Viewer::onViewClosed()
   }
 }
 
-void OCCViewer_Viewer::onViewMapped()
+void OCCViewer_Viewer::onViewMapped(OCCViewer_ViewPort3d* viewPort)
 {
   setTrihedronShown( true );
+  bool showStaticTrihedron = true;
+  SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
+  if ( resMgr ) showStaticTrihedron = resMgr->booleanValue( "3DViewer", "show_static_trihedron", true );
+  viewPort->showStaticTrihedron( showStaticTrihedron );
 }
 
 int OCCViewer_Viewer::getTopLayerId()
@@ -899,7 +899,7 @@ void OCCViewer_Viewer::isos( int& u, int& v ) const
  */
 OCCViewer_ViewWindow* OCCViewer_Viewer::createSubWindow()
 {
-  return new OCCViewer_ViewWindow( 0,  this);
+  return new OCCViewer_ViewWindow(0,  this);
 }
 
 // obsolete  
@@ -933,18 +933,10 @@ void OCCViewer_Viewer::setBackground( int theViewId, const Qtx::BackgroundData&
 /*!
   Set the show static trihedron flag
 */
-void OCCViewer_Viewer::setStaticTrihedronDisplayed(const bool on) {
-  if(myShowStaticTrihedron != on) {
-    OCCViewer_ViewWindow* aView = (OCCViewer_ViewWindow*)(myViewManager->getActiveView());
-    if(!aView)
-      return;
-
-    OCCViewer_ViewPort3d* vp3d = aView->getViewPort();
-    if(vp3d) {
-      myShowStaticTrihedron = on;
-      vp3d->updateStaticTriedronVisibility();
-    }
-  }
+void OCCViewer_Viewer::setStaticTrihedronDisplayed(const bool on)
+{
+  OCCViewer_ViewWindow* aView = (OCCViewer_ViewWindow*)(myViewManager->getActiveView());
+  if ( aView ) aView->showStaticTrihedron( on );
 }
 
 /*!
@@ -966,18 +958,7 @@ bool OCCViewer_Viewer::computeTrihedronSize( double& theNewSize, double& theSize
   if ( view3d.IsNull() )
     return false;
 
-  double Xmin = 0, Ymin = 0, Zmin = 0, Xmax = 0, Ymax = 0, Zmax = 0;
-  double aMaxSide;
-
-  view3d->View()->MinMaxValues( Xmin, Ymin, Zmin, Xmax, Ymax, Zmax );
-
-  if ( Xmin == RealFirst() || Ymin == RealFirst() || Zmin == RealFirst() ||
-       Xmax == RealLast()  || Ymax == RealLast()  || Zmax == RealLast() )
-    return false;
-
-  aMaxSide = Xmax - Xmin;
-  if ( aMaxSide < Ymax -Ymin ) aMaxSide = Ymax -Ymin;
-  if ( aMaxSide < Zmax -Zmin ) aMaxSide = Zmax -Zmin;
+  double aMaxSide = computeSceneSize( view3d );
 
   // IPAL21687
   // The boundary box of the view may be initialized but nullified
@@ -991,8 +972,29 @@ bool OCCViewer_Viewer::computeTrihedronSize( double& theNewSize, double& theSize
   theSize = getTrihedron()->Size();
   theNewSize = aMaxSide*aSizeInPercents / 100.0;
 
-  return fabs( theNewSize - theSize ) > theSize * EPS ||
-         fabs( theNewSize - theSize) > theNewSize * EPS;
+  return fabs( theNewSize - theSize ) > theSize    * EPS ||
+         fabs( theNewSize - theSize ) > theNewSize * EPS;
+}
+
+/*!
+ * Compute scene size
+ */
+double OCCViewer_Viewer::computeSceneSize(const Handle(V3d_View)& view3d) const
+{
+  double aMaxSide = 0;
+  double Xmin = 0, Ymin = 0, Zmin = 0, Xmax = 0, Ymax = 0, Zmax = 0;
+
+  view3d->View()->MinMaxValues( Xmin, Ymin, Zmin, Xmax, Ymax, Zmax );
+
+  if ( Xmin != RealFirst() && Ymin != RealFirst() && Zmin != RealFirst() &&
+       Xmax != RealLast()  && Ymax != RealLast()  && Zmax != RealLast() )
+  {
+    aMaxSide = Xmax - Xmin;
+    if ( aMaxSide < Ymax -Ymin ) aMaxSide = Ymax -Ymin;
+    if ( aMaxSide < Zmax -Zmin ) aMaxSide = Zmax -Zmin;
+  }
+
+  return aMaxSide;
 }
 
 /*! 
index d289dd408f23ecd47fd22f1feb92785f518fe80e..5e2e955b38192864e1c8435dddc3266ddb8b44d4 100755 (executable)
@@ -46,6 +46,7 @@ class SUIT_ViewWindow;
 class SUIT_Desktop;
 class OCCViewer_ClippingDlg;
 class OCCViewer_ViewWindow;
+class OCCViewer_ViewPort3d;
 
 class AIS_ListOfInteractive;
 
@@ -114,8 +115,9 @@ public:
   
   bool                            trihedronRelative() const {return myIsRelative; }
 
-  // a utility function, used by SALOME_View_s methods
+  // a utility functions, used by SALOME_View_s methods
   bool                            computeTrihedronSize( double& theNewSize, double& theSize );
+  virtual double                  computeSceneSize(const Handle(V3d_View)&) const;
 
   void                            updateTrihedron();
   
@@ -151,7 +153,6 @@ public:
 
   int                             getSelectionCount() const { return (!myAISContext.IsNull())? myAISContext->NbSelected():0; }
 
-  bool                            isStaticTrihedronDisplayed() { return myShowStaticTrihedron; }
   void                            setStaticTrihedronDisplayed(const bool on);
 
   /* Clip planes management */
@@ -186,8 +187,8 @@ protected slots:
   virtual void onMouseMove(SUIT_ViewWindow*, QMouseEvent*);
   virtual void onMouseRelease(SUIT_ViewWindow*, QMouseEvent*);
   virtual void onKeyPress(SUIT_ViewWindow*, QKeyEvent*);
-  virtual void onViewClosed();
-  virtual void onViewMapped();
+  virtual void onViewClosed(OCCViewer_ViewPort3d*);
+  virtual void onViewMapped(OCCViewer_ViewPort3d*);
 
   void onDumpView();
   void onChangeBackground();
@@ -216,8 +217,6 @@ protected:
   //QColor                          myBgColor;
   QPoint                          myStartPnt, myEndPnt, myCurPnt;
 
-  bool                            myShowStaticTrihedron;
-
   double                          myTrihedronSize;
 
   QVector<Qtx::BackgroundData>    myBackgrounds;
index 3f546a855b9a2eef241d2355c185b85273e522e9..110076d130317b883b1b8da214efd33904cf9065 100755 (executable)
@@ -96,7 +96,7 @@ OCCViewer_ViewPort3d::OCCViewer_ViewPort3d( QWidget* parent, const Handle( V3d_V
 */
 OCCViewer_ViewPort3d::~OCCViewer_ViewPort3d()
 {
-  emit vpClosed();
+  emit vpClosed(this);
   Handle(V3d_View) aView = activeView();
   if (!aView.IsNull())
     aView->Remove();
@@ -134,17 +134,7 @@ bool OCCViewer_ViewPort3d::mapView( const Handle(V3d_View)& view )
       view->View()->Deactivate();
   }
 
-  /* create static trihedron (16551: EDF PAL 501) */
-  OCCViewer_ViewWindow* aVW = dynamic_cast<OCCViewer_ViewWindow*>( parentWidget()->parentWidget()->parentWidget() );
-  if ( aVW ) {
-    OCCViewer_Viewer* aViewModel = dynamic_cast<OCCViewer_Viewer*>( aVW->getViewManager()->getViewModel() );
-    if ( aViewModel && aViewModel->isStaticTrihedronDisplayed() ){
-      view->ZBufferTriedronSetup();
-      view->TriedronDisplay( Aspect_TOTP_LEFT_LOWER, Quantity_NOC_WHITE, 0.05, V3d_ZBUFFER );
-    }
-  }
-
-  emit( vpMapped() );
+  emit( vpMapped(this) );
 
   return true;
 }
@@ -812,18 +802,16 @@ bool OCCViewer_ViewPort3d::synchronize( OCCViewer_ViewPort* view )
 /*
  * Show/Hide static triedron
  */
-void OCCViewer_ViewPort3d::updateStaticTriedronVisibility() {
-  OCCViewer_ViewWindow* aVW = dynamic_cast<OCCViewer_ViewWindow*>( parentWidget()->parentWidget()->parentWidget() );
-  if ( aVW ) {
-    OCCViewer_Viewer* aViewModel = dynamic_cast<OCCViewer_Viewer*>( aVW->getViewManager()->getViewModel() );
-    Handle(V3d_View) aView = activeView();
-    if ( aViewModel ){
-      if(aViewModel->isStaticTrihedronDisplayed()) {
-       aView->TriedronDisplay( Aspect_TOTP_LEFT_LOWER, Quantity_NOC_WHITE, 0.05, V3d_ZBUFFER );
-      } else {
-       aView->TriedronErase();
-      }
-      aView->Update();
-    }
+void OCCViewer_ViewPort3d::showStaticTrihedron( bool on )
+{
+  Handle(V3d_View) aView = activeView();
+  if ( !aView ) return;
+  
+  if ( on ) {
+    aView->ZBufferTriedronSetup();
+    aView->TriedronDisplay( Aspect_TOTP_LEFT_LOWER, Quantity_NOC_WHITE, 0.05, V3d_ZBUFFER );
+  } else {
+    aView->TriedronErase();
   }
+  aView->Update();
 }
index cd8b1c9e1c945603967a4f1af48ef0fb92d294d9..9cc4b3de68139b49fc471730a40f937c4134ef9d 100755 (executable)
@@ -63,8 +63,6 @@ public:
   virtual int           getBgImgHeight(){return myBgImgHeight; };
   virtual int           getBgImgWidth() {return myBgImgWidth;  };
 
-  virtual void          updateStaticTriedronVisibility();
-
 //   void         setActive( V3d_TypeOfView );
   virtual bool          syncronize( const OCCViewer_ViewPort3d* );
 
@@ -94,10 +92,12 @@ public:
   void                  setAdvancedZoomingEnabled( const bool theState ) { myIsAdvancedZoomingEnabled = theState; }
   bool                  isAdvancedZoomingEnabled() const { return myIsAdvancedZoomingEnabled; }
 
+  void                  showStaticTrihedron( bool );
+
 signals:
   void                  vpChangeBackground( const Qtx::BackgroundData& );
-  void                  vpClosed();
-  void                  vpMapped();
+  void                  vpClosed(OCCViewer_ViewPort3d*);
+  void                  vpMapped(OCCViewer_ViewPort3d*);
 
 public slots:
   virtual bool          synchronize( OCCViewer_ViewPort* );
index 8b965a462cdeb38bb275197a9b64eb656737bda9..ed1d3c1dbec0275b88cd84086b872940b26797b8 100755 (executable)
-// Copyright (C) 2007-2014  CEA/DEN, EDF R&D, OPEN CASCADE\r
-//\r
-// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,\r
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS\r
-//\r
-// This library is free software; you can redistribute it and/or\r
-// modify it under the terms of the GNU Lesser General Public\r
-// License as published by the Free Software Foundation; either\r
-// version 2.1 of the License, or (at your option) any later version.\r
-//\r
-// This library is distributed in the hope that it will be useful,\r
-// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\r
-// Lesser General Public License for more details.\r
-//\r
-// You should have received a copy of the GNU Lesser General Public\r
-// License along with this library; if not, write to the Free Software\r
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA\r
-//\r
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
-//\r
-\r
-// File   : OCCViewer_ViewWindow.cxx\r
-// Author :\r
-\r
-#include "OCCViewer_ViewWindow.h"\r
-#include "OCCViewer_ViewModel.h"\r
-#include "OCCViewer_ViewPort3d.h"\r
-#include "OCCViewer_ViewManager.h"\r
-#include "OCCViewer_ViewSketcher.h"\r
-#include "OCCViewer_CreateRestoreViewDlg.h"\r
-#include "OCCViewer_ClipPlane.h"\r
-#include "OCCViewer_SetRotationPointDlg.h"\r
-#include "OCCViewer_AxialScaleDlg.h"\r
-#include "OCCViewer_CubeAxesDlg.h"\r
-#include "OCCViewer_ClippingDlg.h"\r
-\r
-#include <Basics_OCCTVersion.hxx>\r
-\r
-#include <SUIT_Desktop.h>\r
-#include <SUIT_Session.h>\r
-#include <SUIT_ViewManager.h>\r
-#include <SUIT_Tools.h>\r
-#include <SUIT_ResourceMgr.h>\r
-#include <SUIT_MessageBox.h>\r
-#include <SUIT_Application.h>\r
-\r
-#include <QtxActionToolMgr.h>\r
-#include <QtxMultiAction.h>\r
-#include <QtxRubberBand.h>\r
-\r
-#include <OpenGLUtils_FrameBuffer.h>\r
-\r
-#include <QPainter>\r
-#include <QTime>\r
-#include <QImage>\r
-#include <QKeyEvent>\r
-#include <QMouseEvent>\r
-#include <QApplication>\r
-#include <QMenu>\r
-\r
-#include <AIS_ListOfInteractive.hxx>\r
-#include <AIS_ListIteratorOfListOfInteractive.hxx>\r
-#include <AIS_Shape.hxx>\r
-\r
-#include <BRep_Tool.hxx>\r
-#include <BRepBndLib.hxx>\r
-#include <BRepGProp.hxx>\r
-#include <GProp_GProps.hxx>\r
-#include <TopoDS.hxx>\r
-\r
-#include <Graphic3d_MapIteratorOfMapOfStructure.hxx>\r
-#include <Graphic3d_MapOfStructure.hxx>\r
-#include <Graphic3d_Structure.hxx>\r
-#include <Graphic3d_ExportFormat.hxx>\r
-\r
-#include <Visual3d_View.hxx>\r
-#include <V3d_Plane.hxx>\r
-#include <V3d_Light.hxx>\r
-\r
-#include <gp_Dir.hxx>\r
-#include <gp_Pln.hxx>\r
-#include <gp_GTrsf.hxx>\r
-#include <TColgp_Array1OfPnt2d.hxx>\r
-\r
-#if OCC_VERSION_LARGE > 0x06060000 \r
-#include <Graphic3d_SequenceOfHClipPlane.hxx>\r
-#include <Graphic3d_ClipPlane.hxx>\r
-\r
-#endif\r
-\r
-#include <Standard_Version.hxx>\r
-\r
-#include "utilities.h"\r
-\r
-// // OpenCV includes\r
-// #include <cv.h>\r
-// #include <highgui.h>\r
-\r
-static QEvent* l_mbPressEvent = 0;\r
-\r
-#ifdef WIN32\r
-# include <QWindowsStyle>\r
-#endif\r
-\r
-#include <GL/gl.h>\r
-\r
-const char* imageZoomCursor[] = {\r
-"32 32 3 1",\r
-". c None",\r
-"a c #000000",\r
-"# c #ffffff",\r
-"................................",\r
-"................................",\r
-".#######........................",\r
-"..aaaaaaa.......................",\r
-"................................",\r
-".............#####..............",\r
-"...........##.aaaa##............",\r
-"..........#.aa.....a#...........",\r
-".........#.a.........#..........",\r
-".........#a..........#a.........",\r
-"........#.a...........#.........",\r
-"........#a............#a........",\r
-"........#a............#a........",\r
-"........#a............#a........",\r
-"........#a............#a........",\r
-".........#...........#.a........",\r
-".........#a..........#a.........",\r
-".........##.........#.a.........",\r
-"........#####.....##.a..........",\r
-".......###aaa#####.aa...........",\r
-"......###aa...aaaaa.......#.....",\r
-".....###aa................#a....",\r
-"....###aa.................#a....",\r
-"...###aa...............#######..",\r
-"....#aa.................aa#aaaa.",\r
-".....a....................#a....",\r
-"..........................#a....",\r
-"...........................a....",\r
-"................................",\r
-"................................",\r
-"................................",\r
-"................................"};\r
-\r
-const char* imageRotateCursor[] = {\r
-"32 32 3 1",\r
-". c None",\r
-"a c #000000",\r
-"# c #ffffff",\r
-"................................",\r
-"................................",\r
-"................................",\r
-"................................",\r
-"........#.......................",\r
-".......#.a......................",\r
-"......#######...................",\r
-".......#aaaaa#####..............",\r
-"........#..##.a#aa##........##..",\r
-".........a#.aa..#..a#.....##.aa.",\r
-".........#.a.....#...#..##.aa...",\r
-".........#a.......#..###.aa.....",\r
-"........#.a.......#a..#aa.......",\r
-"........#a.........#..#a........",\r
-"........#a.........#a.#a........",\r
-"........#a.........#a.#a........",\r
-"........#a.........#a.#a........",\r
-".........#.........#a#.a........",\r
-"........##a........#a#a.........",\r
-"......##.a#.......#.#.a.........",\r
-"....##.aa..##.....##.a..........",\r
-"..##.aa.....a#####.aa...........",\r
-"...aa.........aaa#a.............",\r
-"................#.a.............",\r
-"...............#.a..............",\r
-"..............#.a...............",\r
-"...............a................",\r
-"................................",\r
-"................................",\r
-"................................",\r
-"................................",\r
-"................................"};\r
-\r
-const char* imageCrossCursor[] = {\r
-  "32 32 3 1",\r
-  ". c None",\r
-  "a c #000000",\r
-  "# c #ffffff",\r
-  "................................",\r
-  "................................",\r
-  "................................",\r
-  "................................",\r
-  "................................",\r
-  "................................",\r
-  "................................",\r
-  "...............#................",\r
-  "...............#a...............",\r
-  "...............#a...............",\r
-  "...............#a...............",\r
-  "...............#a...............",\r
-  "...............#a...............",\r
-  "...............#a...............",\r
-  "...............#a...............",\r
-  ".......#################........",\r
-  "........aaaaaaa#aaaaaaaaa.......",\r
-  "...............#a...............",\r
-  "...............#a...............",\r
-  "...............#a...............",\r
-  "...............#a...............",\r
-  "...............#a...............",\r
-  "...............#a...............",\r
-  "...............#a...............",\r
-  "................a...............",\r
-  "................................",\r
-  "................................",\r
-  "................................",\r
-  "................................",\r
-  "................................",\r
-  "................................",\r
-  "................................"};\r
-\r
-\r
-/*!\r
-  \brief Constructor\r
-  \param theDesktop main window of application\r
-  \param theModel OCC 3D viewer\r
-*/\r
-OCCViewer_ViewWindow::OCCViewer_ViewWindow( SUIT_Desktop*     theDesktop,\r
-                                            OCCViewer_Viewer* theModel )\r
-: SUIT_ViewWindow( theDesktop )\r
-{\r
-  myModel = theModel;\r
-  myRestoreFlag = 0;\r
-  myEnableDrawMode = false;\r
-  myDrawRect=false;\r
-  updateEnabledDrawMode();\r
-  myScalingDlg = 0;\r
-  mySetRotationPointDlg = 0;\r
-  myRectBand = 0;\r
-  \r
-  IsSketcherStyle = false;\r
-  myIsKeyFree = false;\r
-\r
-  mypSketcher = 0;\r
-  myCurSketch = -1;\r
-  my2dMode = No2dMode;\r
-\r
-  myInteractionStyle = SUIT_ViewModel::STANDARD;\r
-  myPreselectionEnabled = true;\r
-  mySelectionEnabled = true;\r
-\r
-\r
-  clearViewAspects();\r
-  \r
-}\r
-\r
-/*!\r
-  \brief Destructor.\r
-*/\r
-OCCViewer_ViewWindow::~OCCViewer_ViewWindow()\r
-{\r
-  endDrawRect();\r
-  qDeleteAll( mySketchers );\r
-}\r
-\r
-/*!\r
-  \brief Internal initialization.\r
-*/\r
-void OCCViewer_ViewWindow::initLayout()\r
-{\r
-  myViewPort = new OCCViewer_ViewPort3d( this, myModel->getViewer3d(), V3d_ORTHOGRAPHIC );\r
-  myViewPort->installEventFilter(this);\r
-  setCentralWidget(myViewPort);\r
-  myOperation = NOTHING;\r
-\r
-  myCurrPointType = GRAVITY;\r
-  myPrevPointType = GRAVITY;\r
-  mySelectedPoint = gp_Pnt(0.,0.,0.);\r
-  myRotationPointSelection = false;\r
-\r
-  setTransformRequested ( NOTHING );\r
-  setTransformInProcess ( false );\r
-\r
-  createActions();\r
-  createToolBar();\r
-\r
-  switch (my2dMode) {\r
-  case XYPlane:\r
-    onTopView();\r
-    break;\r
-  case XZPlane:\r
-    onLeftView();\r
-    break;\r
-  case YZPlane:\r
-    onFrontView();\r
-    break;\r
-  }\r
-\r
-  // Graduated axes dialog\r
-  QtxAction* anAction = dynamic_cast<QtxAction*>( toolMgr()->action( GraduatedAxesId ) );\r
-  myCubeAxesDlg = new OCCViewer_CubeAxesDlg( anAction, this, "OCCViewer_CubeAxesDlg" );\r
-  myCubeAxesDlg->initialize();\r
-  \r
-  connect( myViewPort, SIGNAL( vpTransformed( OCCViewer_ViewPort* ) ), this, SLOT( emitViewModified() ) );\r
-}\r
-\r
-OCCViewer_ViewWindow* OCCViewer_ViewWindow::getView( const int mode ) const\r
-{\r
-  return mode == get2dMode() ? const_cast<OCCViewer_ViewWindow*>( this ) : 0;\r
-}\r
-\r
-/*!\r
-  \brief Detect viewer operation according the the mouse button pressed\r
-  and key modifiers used.\r
-  \param theEvent mouse event\r
-  \return type of the operation\r
-*/\r
-OCCViewer_ViewWindow::OperationType\r
-OCCViewer_ViewWindow::getButtonState( QMouseEvent* theEvent, int theInteractionStyle )\r
-{\r
-  OperationType aOp = NOTHING;\r
-  SUIT_ViewModel::InteractionStyle aStyle = (SUIT_ViewModel::InteractionStyle)theInteractionStyle;\r
-  if( (theEvent->modifiers() == SUIT_ViewModel::myStateMap[aStyle][SUIT_ViewModel::ZOOM]) &&\r
-      (theEvent->buttons() == SUIT_ViewModel::myButtonMap[aStyle][SUIT_ViewModel::ZOOM]) )\r
-    aOp = ZOOMVIEW;\r
-  else if( (theEvent->modifiers() == SUIT_ViewModel::myStateMap[aStyle][SUIT_ViewModel::PAN]) &&\r
-           (theEvent->buttons() == SUIT_ViewModel::myButtonMap[aStyle][SUIT_ViewModel::PAN]) )\r
-    aOp = PANVIEW;\r
-  else if( (theEvent->modifiers()  == SUIT_ViewModel::myStateMap[aStyle][SUIT_ViewModel::ROTATE]) &&\r
-           (theEvent->buttons() == SUIT_ViewModel::myButtonMap[aStyle][SUIT_ViewModel::ROTATE]) &&\r
-           (my2dMode == No2dMode))\r
-    aOp = ROTATE;\r
-\r
-  return aOp;\r
-}\r
-\r
-/*!\r
-  \brief Customize event handling\r
-  \param watched event receiver object\r
-  \param e event\r
-  \return \c true if the event processing should be stopped\r
-*/\r
-bool OCCViewer_ViewWindow::eventFilter( QObject* watched, QEvent* e )\r
-{\r
-  if ( watched == myViewPort ) {\r
-    int aType = e->type();\r
-    switch(aType) {\r
-    case QEvent::MouseButtonPress:\r
-      vpMousePressEvent((QMouseEvent*) e);\r
-      return true;\r
-\r
-    case QEvent::MouseButtonRelease:\r
-      vpMouseReleaseEvent((QMouseEvent*) e);\r
-      return true;\r
-\r
-    case QEvent::MouseMove:\r
-      vpMouseMoveEvent((QMouseEvent*) e);\r
-      return true;\r
-\r
-    case QEvent::MouseButtonDblClick:\r
-      emit mouseDoubleClicked(this, (QMouseEvent*)e);\r
-      return true;\r
-\r
-    case QEvent::Wheel:\r
-      {\r
-        QWheelEvent* aEvent = (QWheelEvent*) e;\r
-  myViewPort->startZoomAtPoint( aEvent->x(), aEvent->y() );\r
-  double delta = (double)( aEvent->delta() ) / ( 15 * 8 );\r
-  int x  = aEvent->x();\r
-  int y  = aEvent->y();\r
-  int x1 = (int)( aEvent->x() + width()*delta/100 );\r
-  int y1 = (int)( aEvent->y() + height()*delta/100 );\r
-  myViewPort->zoom( x, y, x1, y1 );\r
-      }\r
-      return true;\r
-\r
-    case QEvent::ContextMenu:\r
-      {\r
-        QContextMenuEvent * aEvent = (QContextMenuEvent*)e;\r
-        if ( aEvent->reason() != QContextMenuEvent::Mouse )\r
-          emit contextMenuRequested( aEvent );\r
-      }\r
-      return true;\r
-\r
-    case QEvent::KeyPress:\r
-      emit keyPressed(this, (QKeyEvent*) e);\r
-      return true;\r
-\r
-    default:\r
-      break;\r
-    }\r
-  }\r
-  return SUIT_ViewWindow::eventFilter(watched, e);\r
-}\r
-\r
-/*!\r
-  \brief Update state of enable draw mode state.\r
-*/\r
-void OCCViewer_ViewWindow::updateEnabledDrawMode()\r
-{\r
-  if ( myModel )\r
-    myEnableDrawMode = myModel->isSelectionEnabled() && myModel->isMultiSelectionEnabled();\r
-}\r
-\r
-/*!\r
-  \brief Handle mouse press event\r
-  \param theEvent mouse event\r
-*/\r
-void OCCViewer_ViewWindow::vpMousePressEvent( QMouseEvent* theEvent )\r
-{\r
-  myStartX = theEvent->x();\r
-  myStartY = theEvent->y();\r
-  int anInteractionStyle = interactionStyle();\r
-\r
-  // in "key free" interaction style zoom operation is activated by two buttons (simultaneously pressed),\r
-  // which are assigned for pan and rotate - these operations are activated immediately after pressing \r
-  // of the first button, so it is necessary to switch to zoom when the second button is pressed\r
-  bool aSwitchToZoom = false;\r
-  if ( anInteractionStyle == SUIT_ViewModel::KEY_FREE && \r
-       ( myOperation == PANVIEW || myOperation == ROTATE ) ) {\r
-    aSwitchToZoom = getButtonState( theEvent, anInteractionStyle ) == ZOOMVIEW;\r
-  }\r
-\r
-  switch ( myOperation ) {\r
-  case WINDOWFIT:\r
-    if ( theEvent->button() == Qt::LeftButton )\r
-      emit vpTransformationStarted ( WINDOWFIT );\r
-    break;\r
-\r
-  case PANGLOBAL:\r
-    if ( theEvent->button() == Qt::LeftButton )\r
-      emit vpTransformationStarted ( PANGLOBAL );\r
-    break;\r
-\r
-  case ZOOMVIEW:\r
-    if ( theEvent->button() == Qt::LeftButton ) {\r
-      myViewPort->startZoomAtPoint( myStartX, myStartY );\r
-      emit vpTransformationStarted ( ZOOMVIEW );\r
-    }\r
-    break;\r
-\r
-  case PANVIEW:\r
-    if ( aSwitchToZoom ) {\r
-      myViewPort->startZoomAtPoint( myStartX, myStartY );\r
-      activateZoom();\r
-    }\r
-    else if ( theEvent->button() == Qt::LeftButton )\r
-      emit vpTransformationStarted ( PANVIEW );\r
-    break;\r
-\r
-  case ROTATE:\r
-    if ( aSwitchToZoom ) {\r
-      myViewPort->startZoomAtPoint( myStartX, myStartY );\r
-      activateZoom();\r
-    }\r
-    else if ( theEvent->button() == Qt::LeftButton ) {\r
-      myViewPort->startRotation(myStartX, myStartY, myCurrPointType, mySelectedPoint);\r
-      emit vpTransformationStarted ( ROTATE );\r
-    }\r
-    break;\r
-\r
-  default:\r
-  /*  Try to activate a transformation */\r
-    OperationType aState;\r
-    if ( interactionStyle() == SUIT_ViewModel::STANDARD )\r
-      aState = getButtonState(theEvent, anInteractionStyle);\r
-    else {\r
-      aState = OCCViewer_ViewWindow::NOTHING;\r
-      myIsKeyFree = true;\r
-    }\r
-    switch ( aState ) {\r
-    case ZOOMVIEW:\r
-      myViewPort->startZoomAtPoint( myStartX, myStartY );\r
-      activateZoom();\r
-      break;\r
-    case PANVIEW:\r
-      activatePanning();\r
-      break;\r
-    case ROTATE:\r
-      activateRotation();\r
-      myViewPort->startRotation(myStartX, myStartY, myCurrPointType, mySelectedPoint);\r
-      break;\r
-    default:\r
-      if ( myRotationPointSelection )\r
-      {\r
-        if ( theEvent->button() == Qt::LeftButton )\r
-        {\r
-          Handle(AIS_InteractiveContext) ic = myModel->getAISContext();\r
-          ic->Select();\r
-          for ( ic->InitSelected(); ic->MoreSelected(); ic->NextSelected() )\r
-          {\r
-            TopoDS_Shape aShape = ic->SelectedShape();\r
-            GProp_GProps aSystem;\r
-            gp_Pnt aPnt;\r
-            if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX )\r
-            {\r
-              aPnt = BRep_Tool::Pnt( TopoDS::Vertex( aShape ) );\r
-            }\r
-            else if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_EDGE )\r
-            {\r
-              BRepGProp::LinearProperties( aShape, aSystem );\r
-              aPnt = aSystem.CentreOfMass();\r
-            }\r
-            else if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_FACE )\r
-            {\r
-              BRepGProp::SurfaceProperties( aShape, aSystem );\r
-              aPnt = aSystem.CentreOfMass();\r
-            }\r
-            else if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_SOLID )\r
-            {\r
-              BRepGProp::VolumeProperties( aShape, aSystem );\r
-              aPnt = aSystem.CentreOfMass();\r
-            }\r
-            else\r
-            {\r
-              myCurrPointType = myPrevPointType;\r
-              break;\r
-            }\r
-\r
-            if ( mySetRotationPointDlg )\r
-            {\r
-              myRotationPointSelection = false;\r
-              mySetRotationPointDlg->setCoords(aPnt.X(), aPnt.Y(), aPnt.Z());\r
-            }\r
-          }\r
-          if ( ic->NbSelected() == 0 ) myCurrPointType = myPrevPointType;\r
-          if ( mySetRotationPointDlg ) mySetRotationPointDlg->toggleChange();\r
-          ic->CloseAllContexts();\r
-          myOperation = NOTHING;\r
-          myViewPort->setCursor( myCursor );\r
-          myCursorIsHand = false;\r
-          myRotationPointSelection = false;\r
-        }\r
-      }\r
-      else\r
-        emit mousePressed(this, theEvent);\r
-      break;\r
-    }\r
-    /* notify that we start a transformation */\r
-    if ( transformRequested() )\r
-            emit vpTransformationStarted ( myOperation );\r
-  }\r
-  if ( transformRequested() )\r
-    setTransformInProcess( true );\r
-\r
-  /* we may need it for sketching... */\r
-  if ( l_mbPressEvent )\r
-    delete l_mbPressEvent;\r
-  l_mbPressEvent = new QMouseEvent( *theEvent );\r
-}\r
-\r
-\r
-/*!\r
-  \brief Start zooming operation.\r
-\r
-  Sets the corresponding cursor for the widget.\r
-*/\r
-void OCCViewer_ViewWindow::activateZoom()\r
-{\r
-  if ( !transformRequested() && !myCursorIsHand )\r
-    myCursor = cursor();                /* save old cursor */\r
-\r
-  if ( myOperation != ZOOMVIEW ) {\r
-    QPixmap zoomPixmap (imageZoomCursor);\r
-    QCursor zoomCursor (zoomPixmap);\r
-    if( setTransformRequested ( ZOOMVIEW ) )\r
-      myViewPort->setCursor( zoomCursor );\r
-  }\r
-}\r
-\r
-\r
-/*!\r
-  \brief Start panning operation.\r
-\r
-  Sets the corresponding cursor for the widget.\r
-*/\r
-void OCCViewer_ViewWindow::activatePanning()\r
-{\r
-  if ( !transformRequested() && !myCursorIsHand )\r
-    myCursor = cursor();                // save old cursor\r
-\r
-  if ( myOperation != PANVIEW ) {\r
-    QCursor panCursor (Qt::SizeAllCursor);\r
-    if( setTransformRequested ( PANVIEW ) )\r
-      myViewPort->setCursor( panCursor );\r
-  }\r
-}\r
-\r
-/*!\r
-  \brief Start rotation operation\r
-\r
-  Sets the corresponding cursor for the widget.\r
-*/\r
-void OCCViewer_ViewWindow::activateRotation()\r
-{\r
-  if ( !transformRequested() && !myCursorIsHand )\r
-    myCursor = cursor();                // save old cursor\r
-\r
-  if ( myOperation != ROTATE ) {\r
-    QPixmap rotatePixmap (imageRotateCursor);\r
-    QCursor rotCursor (rotatePixmap);\r
-    if( setTransformRequested ( ROTATE ) )\r
-      myViewPort->setCursor( rotCursor );\r
-  }\r
-}\r
-\r
-/*!\r
-  \brief Compute the gravity center.\r
-  \param theX used to return X coordinate of the gravity center\r
-  \param theY used to return Y coordinate of the gravity center\r
-  \param theZ used to return Z coordinate of the gravity center\r
-  \return \c true if the gravity center is computed\r
-*/\r
-bool OCCViewer_ViewWindow::computeGravityCenter( double& theX, double& theY, double& theZ )\r
-{\r
-  Handle(V3d_View) aView3d = myViewPort->getView();\r
-\r
-  // Project boundaries points and add to avergae gravity\r
-  // the ones which lie within the screen limits\r
-  Standard_Real aScreenLimits[4] = { 0.0, 0.0, 0.0, 0.0 };\r
-\r
-#if OCC_VERSION_LARGE > 0x06070100\r
-  // NDC space screen limits\r
-  aScreenLimits[0] = -1.0;\r
-  aScreenLimits[1] =  1.0;\r
-  aScreenLimits[2] = -1.0;\r
-  aScreenLimits[3] =  1.0;\r
-#else\r
-  aView3d->View()->ViewMapping().WindowLimit( aScreenLimits[0],\r
-                                              aScreenLimits[1],\r
-                                              aScreenLimits[2],\r
-                                              aScreenLimits[3] );\r
-#endif\r
-\r
-  Standard_Integer aPointsNb = 0;\r
-\r
-  Standard_Real aXmin = 0.0;\r
-  Standard_Real aYmin = 0.0;\r
-  Standard_Real aZmin = 0.0;\r
-  Standard_Real aXmax = 0.0;\r
-  Standard_Real aYmax = 0.0;\r
-  Standard_Real aZmax = 0.0;\r
-\r
-  Graphic3d_MapOfStructure aSetOfStructures;\r
-  aView3d->View()->DisplayedStructures( aSetOfStructures );\r
-  Graphic3d_MapIteratorOfMapOfStructure aStructureIt( aSetOfStructures );\r
-\r
-  for( ; aStructureIt.More(); aStructureIt.Next() ) {\r
-    const Handle(Graphic3d_Structure)& aStructure = aStructureIt.Key();\r
-    if ( aStructure->IsEmpty() ) {\r
-      continue;\r
-    }\r
-\r
-    aStructure->MinMaxValues( aXmin, aYmin, aZmin, aXmax, aYmax, aZmax );\r
-\r
-    // Infinite structures are skipped\r
-    Standard_Real aLIM = ShortRealLast() - 1.0;\r
-    if ( Abs( aXmin ) > aLIM || Abs( aYmin ) > aLIM || Abs( aZmin ) > aLIM\r
-      || Abs( aXmax ) > aLIM || Abs( aYmax ) > aLIM || Abs( aZmax ) > aLIM ) {\r
-      continue;\r
-    }\r
-\r
+// Copyright (C) 2007-2014  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, or (at your option) any later version.
+//
+// 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   : OCCViewer_ViewWindow.cxx
+// Author :
+
+#include "OCCViewer_ViewWindow.h"
+#include "OCCViewer_ViewModel.h"
+#include "OCCViewer_ViewPort3d.h"
+#include "OCCViewer_ViewManager.h"
+#include "OCCViewer_ViewSketcher.h"
+#include "OCCViewer_CreateRestoreViewDlg.h"
+#include "OCCViewer_ClipPlane.h"
+#include "OCCViewer_SetRotationPointDlg.h"
+#include "OCCViewer_AxialScaleDlg.h"
+#include "OCCViewer_CubeAxesDlg.h"
+#include "OCCViewer_ClippingDlg.h"
+
+#include <Basics_OCCTVersion.hxx>
+
+#include <SUIT_Desktop.h>
+#include <SUIT_Session.h>
+#include <SUIT_ViewManager.h>
+#include <SUIT_Tools.h>
+#include <SUIT_ResourceMgr.h>
+#include <SUIT_MessageBox.h>
+#include <SUIT_Application.h>
+
+#include <QtxActionToolMgr.h>
+#include <QtxMultiAction.h>
+#include <QtxRubberBand.h>
+
+#include <OpenGLUtils_FrameBuffer.h>
+
+#include <QPainter>
+#include <QTime>
+#include <QImage>
+#include <QKeyEvent>
+#include <QMouseEvent>
+#include <QApplication>
+#include <QMenu>
+
+#include <AIS_ListOfInteractive.hxx>
+#include <AIS_ListIteratorOfListOfInteractive.hxx>
+#include <AIS_Shape.hxx>
+
+#include <BRep_Tool.hxx>
+#include <BRepBndLib.hxx>
+#include <BRepGProp.hxx>
+#include <GProp_GProps.hxx>
+#include <TopoDS.hxx>
+
+#include <Graphic3d_MapIteratorOfMapOfStructure.hxx>
+#include <Graphic3d_MapOfStructure.hxx>
+#include <Graphic3d_Structure.hxx>
+#include <Graphic3d_ExportFormat.hxx>
+
+#include <Visual3d_View.hxx>
+#include <V3d_Plane.hxx>
+#include <V3d_Light.hxx>
+
+#include <gp_Dir.hxx>
+#include <gp_Pln.hxx>
+#include <gp_GTrsf.hxx>
+#include <TColgp_Array1OfPnt2d.hxx>
+
+#if OCC_VERSION_LARGE > 0x06060000 
+#include <Graphic3d_SequenceOfHClipPlane.hxx>
+#include <Graphic3d_ClipPlane.hxx>
+
+#endif
+
+#include <Standard_Version.hxx>
+
+#include "utilities.h"
+
+// // OpenCV includes
+// #include <cv.h>
+// #include <highgui.h>
+
+static QEvent* l_mbPressEvent = 0;
+
+#ifdef WIN32
+# include <QWindowsStyle>
+#endif
+
+#include <GL/gl.h>
+
+const char* imageZoomCursor[] = {
+"32 32 3 1",
+". c None",
+"a c #000000",
+"# c #ffffff",
+"................................",
+"................................",
+".#######........................",
+"..aaaaaaa.......................",
+"................................",
+".............#####..............",
+"...........##.aaaa##............",
+"..........#.aa.....a#...........",
+".........#.a.........#..........",
+".........#a..........#a.........",
+"........#.a...........#.........",
+"........#a............#a........",
+"........#a............#a........",
+"........#a............#a........",
+"........#a............#a........",
+".........#...........#.a........",
+".........#a..........#a.........",
+".........##.........#.a.........",
+"........#####.....##.a..........",
+".......###aaa#####.aa...........",
+"......###aa...aaaaa.......#.....",
+".....###aa................#a....",
+"....###aa.................#a....",
+"...###aa...............#######..",
+"....#aa.................aa#aaaa.",
+".....a....................#a....",
+"..........................#a....",
+"...........................a....",
+"................................",
+"................................",
+"................................",
+"................................"};
+
+const char* imageRotateCursor[] = {
+"32 32 3 1",
+". c None",
+"a c #000000",
+"# c #ffffff",
+"................................",
+"................................",
+"................................",
+"................................",
+"........#.......................",
+".......#.a......................",
+"......#######...................",
+".......#aaaaa#####..............",
+"........#..##.a#aa##........##..",
+".........a#.aa..#..a#.....##.aa.",
+".........#.a.....#...#..##.aa...",
+".........#a.......#..###.aa.....",
+"........#.a.......#a..#aa.......",
+"........#a.........#..#a........",
+"........#a.........#a.#a........",
+"........#a.........#a.#a........",
+"........#a.........#a.#a........",
+".........#.........#a#.a........",
+"........##a........#a#a.........",
+"......##.a#.......#.#.a.........",
+"....##.aa..##.....##.a..........",
+"..##.aa.....a#####.aa...........",
+"...aa.........aaa#a.............",
+"................#.a.............",
+"...............#.a..............",
+"..............#.a...............",
+"...............a................",
+"................................",
+"................................",
+"................................",
+"................................",
+"................................"};
+
+const char* imageCrossCursor[] = {
+  "32 32 3 1",
+  ". c None",
+  "a c #000000",
+  "# c #ffffff",
+  "................................",
+  "................................",
+  "................................",
+  "................................",
+  "................................",
+  "................................",
+  "................................",
+  "...............#................",
+  "...............#a...............",
+  "...............#a...............",
+  "...............#a...............",
+  "...............#a...............",
+  "...............#a...............",
+  "...............#a...............",
+  "...............#a...............",
+  ".......#################........",
+  "........aaaaaaa#aaaaaaaaa.......",
+  "...............#a...............",
+  "...............#a...............",
+  "...............#a...............",
+  "...............#a...............",
+  "...............#a...............",
+  "...............#a...............",
+  "...............#a...............",
+  "................a...............",
+  "................................",
+  "................................",
+  "................................",
+  "................................",
+  "................................",
+  "................................",
+  "................................"};
+
+
+/*!
+  \brief Constructor
+  \param theDesktop main window of application
+  \param theModel OCC 3D viewer
+*/
+OCCViewer_ViewWindow::OCCViewer_ViewWindow( SUIT_Desktop*     theDesktop,
+                                            OCCViewer_Viewer* theModel )
+: SUIT_ViewWindow( theDesktop )
+{
+  myModel = theModel;
+  myRestoreFlag = 0;
+  myEnableDrawMode = false;
+  myDrawRect=false;
+  updateEnabledDrawMode();
+  myScalingDlg = 0;
+  mySetRotationPointDlg = 0;
+  myRectBand = 0;
+  
+  IsSketcherStyle = false;
+  myIsKeyFree = false;
+
+  mypSketcher = 0;
+  myCurSketch = -1;
+  my2dMode = No2dMode;
+
+  myInteractionStyle = SUIT_ViewModel::STANDARD;
+  myPreselectionEnabled = true;
+  mySelectionEnabled = true;
+
+
+  clearViewAspects();
+  
+}
+
+/*!
+  \brief Destructor.
+*/
+OCCViewer_ViewWindow::~OCCViewer_ViewWindow()
+{
+  endDrawRect();
+  qDeleteAll( mySketchers );
+}
+
+/*!
+  \brief Internal initialization.
+*/
+void OCCViewer_ViewWindow::initLayout()
+{
+  myViewPort = new OCCViewer_ViewPort3d( this, myModel->getViewer3d(), V3d_ORTHOGRAPHIC );
+  myViewPort->installEventFilter(this);
+  setCentralWidget(myViewPort);
+  myOperation = NOTHING;
+
+  myCurrPointType = GRAVITY;
+  myPrevPointType = GRAVITY;
+  mySelectedPoint = gp_Pnt(0.,0.,0.);
+  myRotationPointSelection = false;
+
+  setTransformRequested ( NOTHING );
+  setTransformInProcess ( false );
+
+  createActions();
+  createToolBar();
+
+  switch (my2dMode) {
+  case XYPlane:
+    onTopView();
+    break;
+  case XZPlane:
+    onLeftView();
+    break;
+  case YZPlane:
+    onFrontView();
+    break;
+  }
+
+  // Graduated axes dialog
+  QtxAction* anAction = dynamic_cast<QtxAction*>( toolMgr()->action( GraduatedAxesId ) );
+  myCubeAxesDlg = new OCCViewer_CubeAxesDlg( anAction, this, "OCCViewer_CubeAxesDlg" );
+  myCubeAxesDlg->initialize();
+  
+  connect( myViewPort, SIGNAL( vpTransformed( OCCViewer_ViewPort* ) ), this, SLOT( emitViewModified() ) );
+}
+
+OCCViewer_ViewWindow* OCCViewer_ViewWindow::getView( const int mode ) const
+{
+  return mode == get2dMode() ? const_cast<OCCViewer_ViewWindow*>( this ) : 0;
+}
+
+/*!
+  \brief Detect viewer operation according the the mouse button pressed
+  and key modifiers used.
+  \param theEvent mouse event
+  \return type of the operation
+*/
+OCCViewer_ViewWindow::OperationType
+OCCViewer_ViewWindow::getButtonState( QMouseEvent* theEvent, int theInteractionStyle )
+{
+  OperationType aOp = NOTHING;
+  SUIT_ViewModel::InteractionStyle aStyle = (SUIT_ViewModel::InteractionStyle)theInteractionStyle;
+  if( (theEvent->modifiers() == SUIT_ViewModel::myStateMap[aStyle][SUIT_ViewModel::ZOOM]) &&
+      (theEvent->buttons() == SUIT_ViewModel::myButtonMap[aStyle][SUIT_ViewModel::ZOOM]) )
+    aOp = ZOOMVIEW;
+  else if( (theEvent->modifiers() == SUIT_ViewModel::myStateMap[aStyle][SUIT_ViewModel::PAN]) &&
+           (theEvent->buttons() == SUIT_ViewModel::myButtonMap[aStyle][SUIT_ViewModel::PAN]) )
+    aOp = PANVIEW;
+  else if( (theEvent->modifiers()  == SUIT_ViewModel::myStateMap[aStyle][SUIT_ViewModel::ROTATE]) &&
+           (theEvent->buttons() == SUIT_ViewModel::myButtonMap[aStyle][SUIT_ViewModel::ROTATE]) &&
+           (my2dMode == No2dMode))
+    aOp = ROTATE;
+
+  return aOp;
+}
+
+/*!
+  \brief Customize event handling
+  \param watched event receiver object
+  \param e event
+  \return \c true if the event processing should be stopped
+*/
+bool OCCViewer_ViewWindow::eventFilter( QObject* watched, QEvent* e )
+{
+  if ( watched == myViewPort ) {
+    int aType = e->type();
+    switch(aType) {
+    case QEvent::MouseButtonPress:
+      vpMousePressEvent((QMouseEvent*) e);
+      return true;
+
+    case QEvent::MouseButtonRelease:
+      vpMouseReleaseEvent((QMouseEvent*) e);
+      return true;
+
+    case QEvent::MouseMove:
+      vpMouseMoveEvent((QMouseEvent*) e);
+      return true;
+
+    case QEvent::MouseButtonDblClick:
+      emit mouseDoubleClicked(this, (QMouseEvent*)e);
+      return true;
+
+    case QEvent::Wheel:
+      {
+        QWheelEvent* aEvent = (QWheelEvent*) e;
+  myViewPort->startZoomAtPoint( aEvent->x(), aEvent->y() );
+  double delta = (double)( aEvent->delta() ) / ( 15 * 8 );
+  int x  = aEvent->x();
+  int y  = aEvent->y();
+  int x1 = (int)( aEvent->x() + width()*delta/100 );
+  int y1 = (int)( aEvent->y() + height()*delta/100 );
+  myViewPort->zoom( x, y, x1, y1 );
+  myViewPort->getView()->ZFitAll();
+      }
+      return true;
+
+    case QEvent::ContextMenu:
+      {
+        QContextMenuEvent * aEvent = (QContextMenuEvent*)e;
+        if ( aEvent->reason() != QContextMenuEvent::Mouse )
+          emit contextMenuRequested( aEvent );
+      }
+      return true;
+
+    case QEvent::KeyPress:
+      emit keyPressed(this, (QKeyEvent*) e);
+      return true;
+
+    default:
+      break;
+    }
+  }
+  return SUIT_ViewWindow::eventFilter(watched, e);
+}
+
+/*!
+  \brief Update state of enable draw mode state.
+*/
+void OCCViewer_ViewWindow::updateEnabledDrawMode()
+{
+  if ( myModel )
+    myEnableDrawMode = myModel->isSelectionEnabled() && myModel->isMultiSelectionEnabled();
+}
+
+/*!
+  \brief Handle mouse press event
+  \param theEvent mouse event
+*/
+void OCCViewer_ViewWindow::vpMousePressEvent( QMouseEvent* theEvent )
+{
+  myStartX = theEvent->x();
+  myStartY = theEvent->y();
+  int anInteractionStyle = interactionStyle();
+
+  // in "key free" interaction style zoom operation is activated by two buttons (simultaneously pressed),
+  // which are assigned for pan and rotate - these operations are activated immediately after pressing 
+  // of the first button, so it is necessary to switch to zoom when the second button is pressed
+  bool aSwitchToZoom = false;
+  if ( anInteractionStyle == SUIT_ViewModel::KEY_FREE && 
+       ( myOperation == PANVIEW || myOperation == ROTATE ) ) {
+    aSwitchToZoom = getButtonState( theEvent, anInteractionStyle ) == ZOOMVIEW;
+  }
+
+  switch ( myOperation ) {
+  case WINDOWFIT:
+    if ( theEvent->button() == Qt::LeftButton )
+      emit vpTransformationStarted ( WINDOWFIT );
+    break;
+
+  case PANGLOBAL:
+    if ( theEvent->button() == Qt::LeftButton )
+      emit vpTransformationStarted ( PANGLOBAL );
+    break;
+
+  case ZOOMVIEW:
+    if ( theEvent->button() == Qt::LeftButton ) {
+      myViewPort->startZoomAtPoint( myStartX, myStartY );
+      emit vpTransformationStarted ( ZOOMVIEW );
+    }
+    break;
+
+  case PANVIEW:
+    if ( aSwitchToZoom ) {
+      myViewPort->startZoomAtPoint( myStartX, myStartY );
+      activateZoom();
+    }
+    else if ( theEvent->button() == Qt::LeftButton )
+      emit vpTransformationStarted ( PANVIEW );
+    break;
+
+  case ROTATE:
+    if ( aSwitchToZoom ) {
+      myViewPort->startZoomAtPoint( myStartX, myStartY );
+      activateZoom();
+    }
+    else if ( theEvent->button() == Qt::LeftButton ) {
+      myViewPort->startRotation(myStartX, myStartY, myCurrPointType, mySelectedPoint);
+      emit vpTransformationStarted ( ROTATE );
+    }
+    break;
+
+  default:
+  /*  Try to activate a transformation */
+    OperationType aState;
+    if ( interactionStyle() == SUIT_ViewModel::STANDARD )
+      aState = getButtonState(theEvent, anInteractionStyle);
+    else {
+      aState = OCCViewer_ViewWindow::NOTHING;
+      myIsKeyFree = true;
+    }
+    switch ( aState ) {
+    case ZOOMVIEW:
+      myViewPort->startZoomAtPoint( myStartX, myStartY );
+      activateZoom();
+      break;
+    case PANVIEW:
+      activatePanning();
+      break;
+    case ROTATE:
+      activateRotation();
+      myViewPort->startRotation(myStartX, myStartY, myCurrPointType, mySelectedPoint);
+      break;
+    default:
+      if ( myRotationPointSelection )
+      {
+        if ( theEvent->button() == Qt::LeftButton )
+        {
+          Handle(AIS_InteractiveContext) ic = myModel->getAISContext();
+          ic->Select();
+          for ( ic->InitSelected(); ic->MoreSelected(); ic->NextSelected() )
+          {
+            TopoDS_Shape aShape = ic->SelectedShape();
+            GProp_GProps aSystem;
+            gp_Pnt aPnt;
+            if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX )
+            {
+              aPnt = BRep_Tool::Pnt( TopoDS::Vertex( aShape ) );
+            }
+            else if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_EDGE )
+            {
+              BRepGProp::LinearProperties( aShape, aSystem );
+              aPnt = aSystem.CentreOfMass();
+            }
+            else if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_FACE )
+            {
+              BRepGProp::SurfaceProperties( aShape, aSystem );
+              aPnt = aSystem.CentreOfMass();
+            }
+            else if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_SOLID )
+            {
+              BRepGProp::VolumeProperties( aShape, aSystem );
+              aPnt = aSystem.CentreOfMass();
+            }
+            else
+            {
+              myCurrPointType = myPrevPointType;
+              break;
+            }
+
+            if ( mySetRotationPointDlg )
+            {
+              myRotationPointSelection = false;
+              mySetRotationPointDlg->setCoords(aPnt.X(), aPnt.Y(), aPnt.Z());
+            }
+          }
+          if ( ic->NbSelected() == 0 ) myCurrPointType = myPrevPointType;
+          if ( mySetRotationPointDlg ) mySetRotationPointDlg->toggleChange();
+          ic->CloseAllContexts();
+          myOperation = NOTHING;
+          myViewPort->setCursor( myCursor );
+          myCursorIsHand = false;
+          myRotationPointSelection = false;
+        }
+      }
+      else
+        emit mousePressed(this, theEvent);
+      break;
+    }
+    /* notify that we start a transformation */
+    if ( transformRequested() )
+            emit vpTransformationStarted ( myOperation );
+  }
+  if ( transformRequested() )
+    setTransformInProcess( true );
+
+  /* we may need it for sketching... */
+  if ( l_mbPressEvent )
+    delete l_mbPressEvent;
+  l_mbPressEvent = new QMouseEvent( *theEvent );
+}
+
+
+/*!
+  \brief Start zooming operation.
+
+  Sets the corresponding cursor for the widget.
+*/
+void OCCViewer_ViewWindow::activateZoom()
+{
+  if ( !transformRequested() && !myCursorIsHand )
+    myCursor = cursor();                /* save old cursor */
+
+  if ( myOperation != ZOOMVIEW ) {
+    QPixmap zoomPixmap (imageZoomCursor);
+    QCursor zoomCursor (zoomPixmap);
+    if( setTransformRequested ( ZOOMVIEW ) )
+      myViewPort->setCursor( zoomCursor );
+  }
+}
+
+
+/*!
+  \brief Start panning operation.
+
+  Sets the corresponding cursor for the widget.
+*/
+void OCCViewer_ViewWindow::activatePanning()
+{
+  if ( !transformRequested() && !myCursorIsHand )
+    myCursor = cursor();                // save old cursor
+
+  if ( myOperation != PANVIEW ) {
+    QCursor panCursor (Qt::SizeAllCursor);
+    if( setTransformRequested ( PANVIEW ) )
+      myViewPort->setCursor( panCursor );
+  }
+}
+
+/*!
+  \brief Start rotation operation
+
+  Sets the corresponding cursor for the widget.
+*/
+void OCCViewer_ViewWindow::activateRotation()
+{
+  if ( !transformRequested() && !myCursorIsHand )
+    myCursor = cursor();                // save old cursor
+
+  if ( myOperation != ROTATE ) {
+    QPixmap rotatePixmap (imageRotateCursor);
+    QCursor rotCursor (rotatePixmap);
+    if( setTransformRequested ( ROTATE ) )
+      myViewPort->setCursor( rotCursor );
+  }
+}
+
+/*!
+  \brief Compute the gravity center.
+  \param theX used to return X coordinate of the gravity center
+  \param theY used to return Y coordinate of the gravity center
+  \param theZ used to return Z coordinate of the gravity center
+  \return \c true if the gravity center is computed
+*/
+bool OCCViewer_ViewWindow::computeGravityCenter( double& theX, double& theY, double& theZ )
+{
+  Handle(V3d_View) aView3d = myViewPort->getView();
+
+  // Project boundaries points and add to avergae gravity
+  // the ones which lie within the screen limits
+  Standard_Real aScreenLimits[4] = { 0.0, 0.0, 0.0, 0.0 };
+
+#if OCC_VERSION_LARGE > 0x06070100
+  // NDC space screen limits
+  aScreenLimits[0] = -1.0;
+  aScreenLimits[1] =  1.0;
+  aScreenLimits[2] = -1.0;
+  aScreenLimits[3] =  1.0;
+#else
+  aView3d->View()->ViewMapping().WindowLimit( aScreenLimits[0],
+                                              aScreenLimits[1],
+                                              aScreenLimits[2],
+                                              aScreenLimits[3] );
+#endif
+
+  Standard_Integer aPointsNb = 0;
+
+  Standard_Real aXmin = 0.0;
+  Standard_Real aYmin = 0.0;
+  Standard_Real aZmin = 0.0;
+  Standard_Real aXmax = 0.0;
+  Standard_Real aYmax = 0.0;
+  Standard_Real aZmax = 0.0;
+
+  Graphic3d_MapOfStructure aSetOfStructures;
+  aView3d->View()->DisplayedStructures( aSetOfStructures );
+  Graphic3d_MapIteratorOfMapOfStructure aStructureIt( aSetOfStructures );
+
+  for( ; aStructureIt.More(); aStructureIt.Next() ) {
+    const Handle(Graphic3d_Structure)& aStructure = aStructureIt.Key();
+    if ( aStructure->IsEmpty() ) {
+      continue;
+    }
+
+    aStructure->MinMaxValues( aXmin, aYmin, aZmin, aXmax, aYmax, aZmax );
+
+    // Infinite structures are skipped
+    Standard_Real aLIM = ShortRealLast() - 1.0;
+    if ( Abs( aXmin ) > aLIM || Abs( aYmin ) > aLIM || Abs( aZmin ) > aLIM
+      || Abs( aXmax ) > aLIM || Abs( aYmax ) > aLIM || Abs( aZmax ) > aLIM ) {
+      continue;
+    }
+
     gp_Pnt aPoints[8] = {
       gp_Pnt( aXmin, aYmin, aZmin ), gp_Pnt( aXmin, aYmin, aZmax ),
       gp_Pnt( aXmin, aYmax, aZmin ), gp_Pnt( aXmin, aYmax, aZmax ),
       gp_Pnt( aXmax, aYmin, aZmin ), gp_Pnt( aXmax, aYmin, aZmax ),
       gp_Pnt( aXmax, aYmax, aZmin ), gp_Pnt( aXmax, aYmax, aZmax )
     };
-\r
-    for ( Standard_Integer aPointIt = 0; aPointIt < 8; ++aPointIt ) {\r
+
+    for ( Standard_Integer aPointIt = 0; aPointIt < 8; ++aPointIt ) {
       const gp_Pnt& aBBPoint = aPoints[aPointIt];
 
 #if OCC_VERSION_LARGE > 0x06070100
@@ -690,2352 +691,2360 @@ bool OCCViewer_ViewWindow::computeGravityCenter( double& theX, double& theY, dou
         theX += aBBPoint.X();
         theY += aBBPoint.Y();
         theZ += aBBPoint.Z();
-      }\r
-    }\r
-  }\r
-\r
-  if ( aPointsNb > 0 )\r
-  {\r
-    theX /= aPointsNb;\r
-    theY /= aPointsNb;\r
-    theZ /= aPointsNb;\r
-  }\r
-  return true;\r
-}\r
-\r
-/*!\r
-  \brief Set the gravity center as a rotation point.\r
-*/\r
-void OCCViewer_ViewWindow::activateSetRotationGravity()\r
-{\r
-  if ( myRotationPointSelection )\r
-  {\r
-    Handle(AIS_InteractiveContext) ic = myModel->getAISContext();\r
-    ic->CloseAllContexts();\r
-    myOperation = NOTHING;\r
-    myViewPort->setCursor( myCursor );\r
-    myCursorIsHand = false;\r
-    myRotationPointSelection = false;\r
-  }\r
-\r
-  myPrevPointType = myCurrPointType;\r
-  myCurrPointType = GRAVITY;\r
-\r
-  Standard_Real Xcenter, Ycenter, Zcenter;\r
-  if ( computeGravityCenter( Xcenter, Ycenter, Zcenter ) )\r
-    mySetRotationPointDlg->setCoords( Xcenter, Ycenter, Zcenter );\r
-}\r
-\r
-/*!\r
-  \brief Update gravity center in the "Set Rotation Point" dialog box.\r
-  \sa OCCViewer_SetRotationPointDlg class\r
-*/\r
-void OCCViewer_ViewWindow::updateGravityCoords()\r
-{\r
-  if ( mySetRotationPointDlg && mySetRotationPointDlg->isVisible() && myCurrPointType == GRAVITY )\r
-  {\r
-    Standard_Real Xcenter, Ycenter, Zcenter;\r
-    if ( computeGravityCenter( Xcenter, Ycenter, Zcenter ) )\r
-      mySetRotationPointDlg->setCoords( Xcenter, Ycenter, Zcenter );\r
-  }\r
-}\r
-\r
-/*!\r
-  \brief Set the point selected by the user as a rotation point.\r
-  \param theX X coordinate of the rotation point\r
-  \param theY Y coordinate of the rotation point\r
-  \param theZ Z coordinate of the rotation point\r
-*/\r
-void OCCViewer_ViewWindow::activateSetRotationSelected( double theX, double theY, double theZ )\r
-{\r
-  if ( myRotationPointSelection )\r
-  {\r
-    Handle(AIS_InteractiveContext) ic = myModel->getAISContext();\r
-    ic->CloseAllContexts();\r
-    myOperation = NOTHING;\r
-    myViewPort->setCursor( myCursor );\r
-    myCursorIsHand = false;\r
-    myRotationPointSelection = false;\r
-  }\r
-\r
-  myPrevPointType = myCurrPointType;\r
-  myCurrPointType = SELECTED;\r
-  mySelectedPoint.SetCoord(theX,theY,theZ);\r
-}\r
-\r
-/*!\r
-  \brief Start the shape selection process.\r
-*/\r
-void OCCViewer_ViewWindow::activateStartPointSelection( TopAbs_ShapeEnum theShapeType )\r
-{\r
-  myPrevPointType = myCurrPointType;\r
-  myCurrPointType = SELECTED;\r
-\r
-  // activate selection ------>\r
-  Handle(AIS_InteractiveContext) ic = myModel->getAISContext();\r
-\r
-  ic->OpenLocalContext();\r
-\r
-  AIS_ListOfInteractive aList;\r
-  ic->DisplayedObjects( aList );\r
-  for ( AIS_ListIteratorOfListOfInteractive it( aList ); it.More(); it.Next() )\r
-  {\r
-    Handle(AIS_InteractiveObject) anObj = it.Value();\r
-    if ( !anObj.IsNull() && anObj->HasPresentation() &&\r
-         anObj->IsKind( STANDARD_TYPE(AIS_Shape) ) )\r
-    {\r
-      ic->Load(anObj,-1);\r
-      ic->Activate(anObj,AIS_Shape::SelectionMode(theShapeType));\r
-     }\r
-  }\r
-  // activate selection <------\r
-\r
-  if ( !myCursorIsHand )\r
-  {\r
-    QCursor handCursor (Qt::PointingHandCursor);\r
-    myCursorIsHand = true;\r
-    myCursor = cursor();\r
-    myViewPort->setCursor( handCursor );\r
-  }\r
-  myRotationPointSelection = true;\r
-}\r
-\r
-/*!\r
-  \brief Start global panning operation\r
-\r
-  Sets the corresponding cursor for the widget.\r
-*/\r
-void OCCViewer_ViewWindow::activateGlobalPanning()\r
-{\r
-  Handle(V3d_View) aView3d = myViewPort->getView();\r
-  if ( !aView3d.IsNull() ) {\r
-    QPixmap globalPanPixmap (imageCrossCursor);\r
-    QCursor glPanCursor (globalPanPixmap);\r
-    myCurScale = aView3d->Scale();\r
-    aView3d->FitAll(0.01, false);\r
-    myCursor = cursor();                // save old cursor\r
-    myViewPort->fitAll(); // fits view before selecting a new scene center\r
-    if( setTransformRequested( PANGLOBAL ) )\r
-      myViewPort->setCursor( glPanCursor );\r
-  }\r
-}\r
-\r
-/*!\r
-  \brief Starts fit operation.\r
-\r
-  Sets the corresponding cursor for the widget.\r
-*/\r
-void OCCViewer_ViewWindow::activateWindowFit()\r
-{\r
-  if ( !transformRequested() && !myCursorIsHand )\r
-    myCursor = cursor();                /* save old cursor */\r
-\r
-  if ( myOperation != WINDOWFIT ) {\r
-    QCursor handCursor (Qt::PointingHandCursor);\r
-    if( setTransformRequested ( WINDOWFIT ) )\r
-    {\r
-      myViewPort->setCursor ( handCursor );\r
-      myCursorIsHand = true;\r
-    }\r
-  }\r
-}\r
-\r
-/*!\r
-  \brief Start delayed viewer operation.\r
-*/\r
-bool OCCViewer_ViewWindow::setTransformRequested( OperationType op )\r
-{\r
-  bool ok = transformEnabled( op );\r
-  myOperation = ok ? op : NOTHING;\r
-  myViewPort->setMouseTracking( myOperation == NOTHING );  \r
-  return ok;\r
-}\r
-\r
-/*!\r
-  \brief Handle mouse move event.\r
-  \param theEvent mouse event\r
-*/\r
-void OCCViewer_ViewWindow::vpMouseMoveEvent( QMouseEvent* theEvent )\r
-{\r
-  if ( myIsKeyFree && interactionStyle() == SUIT_ViewModel::KEY_FREE ) {\r
-    myIsKeyFree = false;\r
-    switch ( getButtonState( theEvent, interactionStyle() ) ) {\r
-    case ZOOMVIEW:\r
-      myViewPort->startZoomAtPoint( myStartX, myStartY );\r
-      activateZoom();\r
-      break;\r
-    case PANVIEW:\r
-      activatePanning();\r
-      break;\r
-    case ROTATE:\r
-      activateRotation();\r
-      myViewPort->startRotation(myStartX, myStartY, myCurrPointType, mySelectedPoint);\r
-      break;\r
-    default:\r
-      break;\r
-    }\r
-  }\r
-\r
-  myCurrX = theEvent->x();\r
-  myCurrY = theEvent->y();\r
-  switch (myOperation) {\r
-  case ROTATE:\r
-    myViewPort->rotate(myCurrX, myCurrY, myCurrPointType, mySelectedPoint);\r
-    break;\r
-\r
-  case ZOOMVIEW:\r
-    myViewPort->zoom(myStartX, myStartY, myCurrX, myCurrY);\r
-    myStartX = myCurrX;\r
-    myStartY = myCurrY;\r
-    break;\r
-\r
-  case PANVIEW:\r
-    myViewPort->pan(myCurrX - myStartX, myStartY - myCurrY);\r
-    myStartX = myCurrX;\r
-    myStartY = myCurrY;\r
-    break;\r
-\r
-/*    case WINDOWFIT:\r
-    myDrawRect = true;\r
-    repaint();\r
-    break;\r
-*/\r
-  case PANGLOBAL:\r
-    break;\r
-\r
-  default:\r
-    if ( myRotationPointSelection || isSketcherStyle() )\r
-    {\r
-      emit mouseMoving( this, theEvent );\r
-    }\r
-    else\r
-    {\r
-      int aState = theEvent->modifiers();\r
-      int aButton = theEvent->buttons();\r
-      int anInteractionStyle = interactionStyle();\r
-      if ( ( anInteractionStyle == SUIT_ViewModel::STANDARD &&\r
-           aButton == Qt::LeftButton && ( aState == Qt::NoModifier || Qt::ShiftModifier ) ) ||\r
-         ( anInteractionStyle == SUIT_ViewModel::KEY_FREE &&\r
-         aButton == Qt::LeftButton && ( aState == Qt::ControlModifier || aState == ( Qt::ControlModifier|Qt::ShiftModifier ) ) ) ) {\r
-        myDrawRect = myEnableDrawMode;\r
-        if ( myDrawRect ) {\r
-          drawRect();\r
-          if ( !myCursorIsHand )        {   // we are going to sketch a rectangle\r
-            QCursor handCursor (Qt::PointingHandCursor);\r
-            myCursorIsHand = true;\r
-            myCursor = cursor();\r
-            myViewPort->setCursor( handCursor );\r
-          }\r
-        }\r
-        emit mouseMoving( this, theEvent );\r
-      }\r
-      else if ( ( anInteractionStyle == SUIT_ViewModel::STANDARD &&\r
-                aButton == Qt::RightButton && ( aState == Qt::NoModifier || Qt::ShiftModifier ) ) ||\r
-                ( anInteractionStyle == SUIT_ViewModel::KEY_FREE &&\r
-                aButton == Qt::RightButton && ( aState == Qt::ControlModifier || aState == ( Qt::ControlModifier|Qt::ShiftModifier ) ) ) ) {\r
-        OCCViewer_ViewSketcher* sketcher = 0;\r
-        QList<OCCViewer_ViewSketcher*>::Iterator it;\r
-        for ( it = mySketchers.begin(); it != mySketchers.end() && !sketcher; ++it )\r
-        {\r
-          OCCViewer_ViewSketcher* sk = (*it);\r
-          if( sk->isDefault() && sk->sketchButton() == aButton )\r
-            sketcher = sk;\r
-        }\r
-        if ( sketcher && myCurSketch == -1 )\r
-        {\r
-          activateSketching( sketcher->type() );\r
-          if ( mypSketcher )\r
-          {\r
-            myCurSketch = mypSketcher->sketchButton();\r
-\r
-            if ( l_mbPressEvent )\r
-            {\r
-              QApplication::sendEvent( getViewPort(), l_mbPressEvent );\r
-              delete l_mbPressEvent;\r
-              l_mbPressEvent = 0;\r
-            }\r
-            QApplication::sendEvent( getViewPort(), theEvent );\r
-          }\r
-        }\r
-      }\r
-      else\r
-        emit mouseMoving( this, theEvent );\r
-    }\r
-  }\r
-}\r
-\r
-/*!\r
-  \brief Handle mouse release event.\r
-  \param theEvent mouse event\r
-*/\r
-void OCCViewer_ViewWindow::vpMouseReleaseEvent(QMouseEvent* theEvent)\r
-{\r
-  switch ( myOperation ) {\r
-  case NOTHING:\r
-    {\r
-      int prevState = myCurSketch;\r
-      if(theEvent->button() == Qt::RightButton)\r
-      {\r
-        QList<OCCViewer_ViewSketcher*>::Iterator it;\r
-        for ( it = mySketchers.begin(); it != mySketchers.end() && myCurSketch != -1; ++it )\r
-        {\r
-          OCCViewer_ViewSketcher* sk = (*it);\r
-          if( ( sk->sketchButton() & theEvent->button() ) && sk->sketchButton() == myCurSketch )\r
-            myCurSketch = -1;\r
-        }\r
-      }\r
-\r
-      emit mouseReleased(this, theEvent);\r
-      if(theEvent->button() == Qt::RightButton && prevState == -1)\r
-      {\r
-        QContextMenuEvent aEvent( QContextMenuEvent::Mouse,\r
-                                  theEvent->pos(), theEvent->globalPos() );\r
-        emit contextMenuRequested( &aEvent );\r
-      }\r
-    }\r
-    break;\r
-  case ROTATE:\r
-    myViewPort->endRotation();\r
-    resetState();\r
-    break;\r
-\r
-  case PANVIEW:\r
-  case ZOOMVIEW:\r
-    resetState();\r
-    break;\r
-\r
-  case PANGLOBAL:\r
-    if ( theEvent->button() == Qt::LeftButton ) {\r
-      myViewPort->setCenter( theEvent->x(), theEvent->y() );\r
-      myViewPort->getView()->SetScale(myCurScale);\r
-      resetState();\r
-    }\r
-    break;\r
-\r
-  case WINDOWFIT:\r
-    if ( theEvent->button() == Qt::LeftButton ) {\r
-      myCurrX = theEvent->x();\r
-      myCurrY = theEvent->y();\r
-      drawRect();\r
-      QRect rect = SUIT_Tools::makeRect(myStartX, myStartY, myCurrX, myCurrY);\r
-      if ( !rect.isEmpty() ) myViewPort->fitRect(rect);\r
-      endDrawRect();\r
-      resetState();\r
-    }\r
-    break;\r
-  }\r
-\r
-  // NOTE: viewer 3D detects a rectangle of selection using this event\r
-  // so we must emit it BEFORE resetting the selection rectangle\r
-\r
-  if ( theEvent->button() == Qt::LeftButton && myDrawRect ) {\r
-    drawRect();\r
-    endDrawRect();\r
-    resetState();\r
-    myViewPort->update();\r
-  }\r
-\r
-  if ( l_mbPressEvent )\r
-  {\r
-    delete l_mbPressEvent;\r
-    l_mbPressEvent = 0;\r
-  }\r
-}\r
-\r
-/*!\r
-  \brief Reset the viewport to its initial state\r
-  ( no transformations in process etc. )\r
-*/\r
-void OCCViewer_ViewWindow::resetState()\r
-{\r
-  myDrawRect = false;\r
-\r
-  if ( myRotationPointSelection )\r
-  {\r
-    QCursor handCursor (Qt::PointingHandCursor);\r
-    myViewPort->setCursor( handCursor );\r
-  }\r
-  else\r
-  {\r
-    if ( transformRequested() || myCursorIsHand )\r
-      myViewPort->setCursor( myCursor );\r
-    myCursorIsHand = false;\r
-  }\r
-\r
-  if ( transformRequested() )\r
-    emit vpTransformationFinished (myOperation);\r
-\r
-  setTransformInProcess( false );\r
-  setTransformRequested( NOTHING );\r
-}\r
-\r
-\r
-/*!\r
-  \brief Draw rubber band rectangle.\r
-*/\r
-void OCCViewer_ViewWindow::drawRect()\r
-{\r
-  if ( !myRectBand ) {\r
-    myRectBand = new QtxRectRubberBand( myViewPort );\r
-    //QPalette palette;\r
-    //palette.setColor(myRectBand->foregroundRole(), Qt::white);\r
-    //myRectBand->setPalette(palette);\r
-  }\r
-  //myRectBand->hide();\r
-  \r
-  myRectBand->setUpdatesEnabled ( false );\r
-  QRect aRect = SUIT_Tools::makeRect(myStartX, myStartY, myCurrX, myCurrY);\r
-  myRectBand->initGeometry( aRect );\r
-\r
-  if ( !myRectBand->isVisible() )\r
-    myRectBand->show();\r
-\r
-  myRectBand->setUpdatesEnabled ( true );\r
-  //myRectBand->repaint();\r
-\r
-  //myRectBand->setVisible( aRect.isValid() );\r
-  //if ( myRectBand->isVisible() )\r
-  //  myRectBand->repaint();\r
-  //else\r
-  //  myRectBand->show();\r
-  //myRectBand->repaint();\r
-}\r
-\r
-/*!\r
-  \brief Clear rubber band rectangle on the end on the dragging operation.\r
-*/\r
-void OCCViewer_ViewWindow::endDrawRect()\r
-{\r
-  //delete myRectBand;\r
-  //myRectBand = 0;\r
-  if ( myRectBand )\r
-    {\r
-      myRectBand->clearGeometry();\r
-      myRectBand->hide();\r
-    }\r
-}\r
-\r
-/*!\r
-  \brief Create actions.\r
-*/\r
-void OCCViewer_ViewWindow::createActions()\r
-{\r
-  if( !toolMgr()->isEmpty() )\r
-    return;\r
-  \r
-  SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();\r
-\r
-  QtxAction* aAction;\r
-\r
-  // Dump view\r
-  aAction = new QtxAction(tr("MNU_DUMP_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_DUMP" ) ),\r
-                           tr( "MNU_DUMP_VIEW" ), 0, this);\r
-  aAction->setStatusTip(tr("DSC_DUMP_VIEW"));\r
-  connect(aAction, SIGNAL(triggered()), this, SLOT(onDumpView()));\r
-  toolMgr()->registerAction( aAction, DumpId );\r
-\r
-  // FitAll\r
-  aAction = new QtxAction(tr("MNU_FITALL"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_FITALL" ) ),\r
-                           tr( "MNU_FITALL" ), 0, this);\r
-  aAction->setStatusTip(tr("DSC_FITALL"));\r
-  connect(aAction, SIGNAL(triggered()), this, SLOT(onFitAll()));\r
-  toolMgr()->registerAction( aAction, FitAllId );\r
-\r
-  // FitRect\r
-  aAction = new QtxAction(tr("MNU_FITRECT"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_FITAREA" ) ),\r
-                           tr( "MNU_FITRECT" ), 0, this);\r
-  aAction->setStatusTip(tr("DSC_FITRECT"));\r
-  connect(aAction, SIGNAL(triggered()), this, SLOT(activateWindowFit()));\r
-  toolMgr()->registerAction( aAction, FitRectId );\r
-  \r
-  // Zoom\r
-  aAction = new QtxAction(tr("MNU_ZOOM_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_ZOOM" ) ),\r
-                           tr( "MNU_ZOOM_VIEW" ), 0, this);\r
-  aAction->setStatusTip(tr("DSC_ZOOM_VIEW"));\r
-  connect(aAction, SIGNAL(triggered()), this, SLOT(activateZoom()));\r
-  toolMgr()->registerAction( aAction, ZoomId );\r
-\r
-  // Panning\r
-  aAction = new QtxAction(tr("MNU_PAN_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_PAN" ) ),\r
-                           tr( "MNU_PAN_VIEW" ), 0, this);\r
-  aAction->setStatusTip(tr("DSC_PAN_VIEW"));\r
-  connect(aAction, SIGNAL(triggered()), this, SLOT(activatePanning()));\r
-  toolMgr()->registerAction( aAction, PanId );\r
-\r
-  // Global Panning\r
-  aAction = new QtxAction(tr("MNU_GLOBALPAN_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_GLOBALPAN" ) ),\r
-                           tr( "MNU_GLOBALPAN_VIEW" ), 0, this);\r
-  aAction->setStatusTip(tr("DSC_GLOBALPAN_VIEW"));\r
-  connect(aAction, SIGNAL(triggered()), this, SLOT(activateGlobalPanning()));\r
-  toolMgr()->registerAction( aAction, GlobalPanId );\r
-\r
-  // Rotation Point\r
-  mySetRotationPointAction = new QtxAction(tr("MNU_CHANGINGROTATIONPOINT_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_ROTATION_POINT" ) ),\r
-                           tr( "MNU_CHANGINGROTATIONPOINT_VIEW" ), 0, this);\r
-  mySetRotationPointAction->setStatusTip(tr("DSC_CHANGINGROTATIONPOINT_VIEW"));\r
-  mySetRotationPointAction->setCheckable( true );\r
-  connect(mySetRotationPointAction, SIGNAL(toggled( bool )), this, SLOT(onSetRotationPoint( bool )));\r
-  toolMgr()->registerAction( mySetRotationPointAction, ChangeRotationPointId );\r
-\r
-  // Rotation\r
-  aAction = new QtxAction(tr("MNU_ROTATE_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_ROTATE" ) ),\r
-                           tr( "MNU_ROTATE_VIEW" ), 0, this);\r
-  aAction->setStatusTip(tr("DSC_ROTATE_VIEW"));\r
-  connect(aAction, SIGNAL(triggered()), this, SLOT(activateRotation()));\r
-  toolMgr()->registerAction( aAction, RotationId );\r
-\r
-  // Projections\r
-  aAction = new QtxAction(tr("MNU_FRONT_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_FRONT" ) ),\r
-                           tr( "MNU_FRONT_VIEW" ), 0, this, false, "Viewers:Front view");\r
-  aAction->setStatusTip(tr("DSC_FRONT_VIEW"));\r
-  connect(aAction, SIGNAL(triggered()), this, SLOT(onFrontView()));\r
-  this->addAction(aAction);\r
-  toolMgr()->registerAction( aAction, FrontId );\r
-\r
-  aAction = new QtxAction(tr("MNU_BACK_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_BACK" ) ),\r
-                           tr( "MNU_BACK_VIEW" ), 0, this, false, "Viewers:Back view");\r
-  aAction->setStatusTip(tr("DSC_BACK_VIEW"));\r
-  connect(aAction, SIGNAL(triggered()), this, SLOT(onBackView()));\r
-  this->addAction(aAction);\r
-  toolMgr()->registerAction( aAction, BackId );\r
-\r
-  aAction = new QtxAction(tr("MNU_TOP_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_TOP" ) ),\r
-                           tr( "MNU_TOP_VIEW" ), 0, this, false, "Viewers:Top view");\r
-  aAction->setStatusTip(tr("DSC_TOP_VIEW"));\r
-  connect(aAction, SIGNAL(triggered()), this, SLOT(onTopView()));\r
-  this->addAction(aAction);\r
-  toolMgr()->registerAction( aAction, TopId );\r
-\r
-  aAction = new QtxAction(tr("MNU_BOTTOM_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_BOTTOM" ) ),\r
-                           tr( "MNU_BOTTOM_VIEW" ), 0, this, false, "Viewers:Bottom view");\r
-  aAction->setStatusTip(tr("DSC_BOTTOM_VIEW"));\r
-  connect(aAction, SIGNAL(triggered()), this, SLOT(onBottomView()));\r
-  this->addAction(aAction);\r
-  toolMgr()->registerAction( aAction, BottomId );\r
-  \r
-  aAction = new QtxAction(tr("MNU_LEFT_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_LEFT" ) ),\r
-                           tr( "MNU_LEFT_VIEW" ), 0, this, false, "Viewers:Left view");\r
-  aAction->setStatusTip(tr("DSC_LEFT_VIEW"));\r
-  connect(aAction, SIGNAL(triggered()), this, SLOT(onLeftView()));\r
-  this->addAction(aAction);\r
-  toolMgr()->registerAction( aAction, LeftId );\r
-\r
-  aAction = new QtxAction(tr("MNU_RIGHT_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_RIGHT" ) ),\r
-                           tr( "MNU_RIGHT_VIEW" ), 0, this, false, "Viewers:Right view");\r
-  aAction->setStatusTip(tr("DSC_RIGHT_VIEW"));\r
-  connect(aAction, SIGNAL(triggered()), this, SLOT(onRightView()));\r
-  this->addAction(aAction);\r
-  toolMgr()->registerAction( aAction, RightId );\r
-\r
-  // rotate anticlockwise\r
-  aAction = new QtxAction(tr("MNU_ANTICLOCKWISE_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_ANTICLOCKWISE" ) ),\r
-                           tr( "MNU_ANTICLOCKWISE_VIEW" ), 0, this, false, "Viewers:Rotate anticlockwise");\r
-  aAction->setStatusTip(tr("DSC_ANTICLOCKWISE_VIEW"));\r
-  connect(aAction, SIGNAL(triggered()), this, SLOT(onAntiClockWiseView()));\r
-  this->addAction(aAction);\r
-  toolMgr()->registerAction( aAction, AntiClockWiseId );\r
-\r
-  // rotate clockwise\r
-  aAction = new QtxAction(tr("MNU_CLOCKWISE_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_CLOCKWISE" ) ),\r
-                           tr( "MNU_CLOCKWISE_VIEW" ), 0, this, false, "Viewers:Rotate clockwise");\r
-  aAction->setStatusTip(tr("DSC_CLOCKWISE_VIEW"));\r
-  connect(aAction, SIGNAL(triggered()), this, SLOT(onClockWiseView()));\r
-  this->addAction(aAction);\r
-  toolMgr()->registerAction( aAction, ClockWiseId );\r
-\r
-  // Reset\r
-  aAction = new QtxAction(tr("MNU_RESET_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_RESET" ) ),\r
-                           tr( "MNU_RESET_VIEW" ), 0, this, false, "Viewers:Reset view");\r
-  aAction->setStatusTip(tr("DSC_RESET_VIEW"));\r
-  connect(aAction, SIGNAL(triggered()), this, SLOT(onResetView()));\r
-  this->addAction(aAction);\r
-  toolMgr()->registerAction( aAction, ResetId );\r
-\r
-  // Clone\r
-  aAction = new QtxAction(tr("MNU_CLONE_VIEW"),\r
-                          aResMgr->loadPixmap("OCCViewer", tr("ICON_OCCVIEWER_CLONE_VIEW")),\r
-                          tr("MNU_CLONE_VIEW"), 0, this);\r
-  aAction->setStatusTip(tr("DSC_CLONE_VIEW"));\r
-  connect(aAction, SIGNAL(triggered()), this, SLOT(onCloneView()));\r
-  toolMgr()->registerAction( aAction, CloneId );\r
-\r
-  aAction = new QtxAction (tr ("MNU_CLIPPING"), aResMgr->loadPixmap ("OCCViewer", tr ("ICON_OCCVIEWER_CLIPPING")),\r
-                                      tr ("MNU_CLIPPING"), 0, this);\r
-  aAction->setStatusTip (tr ("DSC_CLIPPING"));\r
-  aAction->setCheckable (true);\r
-  connect (aAction, SIGNAL (toggled (bool)), this, SLOT (onClipping (bool)));\r
-  toolMgr()->registerAction (aAction, ClippingId);\r
-\r
-  aAction = new QtxAction(tr("MNU_SHOOT_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_SHOOT_VIEW" ) ),\r
-                           tr( "MNU_SHOOT_VIEW" ), 0, this);\r
-  aAction->setStatusTip(tr("DSC_SHOOT_VIEW"));\r
-  connect(aAction, SIGNAL(triggered()), this, SLOT(onMemorizeView()));\r
-  toolMgr()->registerAction( aAction, MemId );\r
-\r
-  aAction = new QtxAction(tr("MNU_PRESETS_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_PRESETS_VIEW" ) ),\r
-                           tr( "MNU_PRESETS_VIEW" ), 0, this);\r
-  aAction->setStatusTip(tr("DSC_PRESETS_VIEW"));\r
-  connect(aAction, SIGNAL(triggered()), this, SLOT(onRestoreView()));\r
-  toolMgr()->registerAction( aAction, RestoreId );\r
-\r
-  if (myModel->trihedronActivated()) {\r
-    aAction = new QtxAction(tr("MNU_SHOW_TRIHEDRE"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_TRIHEDRON" ) ),\r
-                             tr( "MNU_SHOW_TRIHEDRE" ), 0, this);\r
-    aAction->setStatusTip(tr("DSC_SHOW_TRIHEDRE"));\r
-    connect(aAction, SIGNAL(triggered()), this, SLOT(onTrihedronShow()));\r
-    toolMgr()->registerAction( aAction, TrihedronShowId );\r
-  }\r
-\r
-  // Scale\r
-  aAction = new QtxAction(tr("MNU_SCALING"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_SCALING" ) ),\r
-                           tr( "MNU_SCALING" ), 0, this);\r
-  aAction->setStatusTip(tr("DSC_SCALING"));\r
-  connect(aAction, SIGNAL(triggered()), this, SLOT(onAxialScale()));\r
-  toolMgr()->registerAction( aAction, AxialScaleId );\r
-\r
-  // Enable/disable preselection\r
-  aAction = new QtxAction(tr("MNU_ENABLE_PRESELECTION"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_PRESELECTION" ) ),\r
-                          tr( "MNU_ENABLE_PRESELECTION" ), 0, this);\r
-  aAction->setStatusTip(tr("DSC_ENABLE_PRESELECTION"));\r
-  aAction->setCheckable(true);\r
-  connect(aAction, SIGNAL(toggled(bool)), this, SLOT(onSwitchPreselection(bool)));\r
-  toolMgr()->registerAction( aAction, SwitchPreselectionId );\r
-\r
-  // Enable/disable selection\r
-  aAction = new QtxAction(tr("MNU_ENABLE_SELECTION"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_SELECTION" ) ),\r
-                          tr( "MNU_ENABLE_SELECTION" ), 0, this);\r
-  aAction->setStatusTip(tr("DSC_ENABLE_SELECTION"));\r
-  aAction->setCheckable(true);\r
-  connect(aAction, SIGNAL(toggled(bool)), this, SLOT(onSwitchSelection(bool)));\r
-  toolMgr()->registerAction( aAction, SwitchSelectionId );\r
-\r
-  // Graduated axes \r
-  aAction = new QtxAction(tr("MNU_GRADUATED_AXES"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_GRADUATED_AXES" ) ),\r
-                           tr( "MNU_GRADUATED_AXES" ), 0, this);\r
-  aAction->setStatusTip(tr("DSC_GRADUATED_AXES"));\r
-  connect(aAction, SIGNAL(triggered()), this, SLOT(onGraduatedAxes()));\r
-  toolMgr()->registerAction( aAction, GraduatedAxesId );\r
-\r
-  // Active only ambient light or not\r
-  aAction = new QtxAction(tr("MNU_AMBIENT"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_AMBIENT" ) ),\r
-                           tr( "MNU_AMBIENT" ), 0, this);\r
-  aAction->setStatusTip(tr("DSC_AMBIENT"));\r
-  connect(aAction, SIGNAL(triggered()), this, SLOT(onAmbientToogle()));\r
-  toolMgr()->registerAction( aAction, AmbientId );\r
-\r
-  // Switch between interaction styles\r
-  aAction = new QtxAction(tr("MNU_STYLE_SWITCH"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_STYLE_SWITCH" ) ),\r
-                          tr( "MNU_STYLE_SWITCH" ), 0, this);\r
-  aAction->setStatusTip(tr("DSC_STYLE_SWITCH"));\r
-  aAction->setCheckable(true);\r
-  connect(aAction, SIGNAL(toggled(bool)), this, SLOT(onSwitchInteractionStyle(bool)));\r
-  toolMgr()->registerAction( aAction, SwitchInteractionStyleId );\r
-\r
-  // Switch between zooming styles\r
-  aAction = new QtxAction(tr("MNU_ZOOMING_STYLE_SWITCH"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_ZOOMING_STYLE_SWITCH" ) ),\r
-                          tr( "MNU_ZOOMING_STYLE_SWITCH" ), 0, this);\r
-  aAction->setStatusTip(tr("DSC_ZOOMING_STYLE_SWITCH"));\r
-  aAction->setCheckable(true);\r
-  connect(aAction, SIGNAL(toggled(bool)), this, SLOT(onSwitchZoomingStyle(bool)));\r
-  toolMgr()->registerAction( aAction, SwitchZoomingStyleId );\r
-\r
-  // Maximized view\r
-  aAction = new QtxAction(tr("MNU_MINIMIZE_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_MINIMIZE" ) ),\r
-                          tr( "MNU_MINIMIZE_VIEW" ), 0, this );\r
-  aAction->setStatusTip(tr("DSC_MINIMIZE_VIEW"));\r
-  connect(aAction, SIGNAL(triggered()), this, SLOT(onMaximizedView()));\r
-  toolMgr()->registerAction( aAction, MaximizedId );\r
-\r
-  // Return to 3d view\r
-  if (my2dMode!=No2dMode){\r
-    aAction = new QtxAction(tr("MNU_RETURN_3D_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_RETURN_3D_VIEW" ) ),\r
-                            tr( "MNU_RETURN_3D_VIEW" ), 0, this );\r
-    aAction->setStatusTip(tr("DSC_RETURN_3D_VIEW"));\r
-    connect(aAction, SIGNAL(triggered()), this, SLOT(returnTo3dView()));\r
-    toolMgr()->registerAction( aAction, ReturnTo3dViewId );\r
-  }\r
-\r
-  // Synchronize View \r
-  toolMgr()->registerAction( synchronizeAction(), SynchronizeId );\r
-}\r
-\r
-/*!\r
-  \brief Create toolbar.\r
-*/\r
-void OCCViewer_ViewWindow::createToolBar()\r
-{\r
-  QString aToolbarName;\r
-  switch (my2dMode) {\r
-  case XYPlane:\r
-    aToolbarName = tr( "LBL_XYTOOLBAR_LABEL" );\r
-    break;\r
-  case XZPlane:\r
-    aToolbarName = tr( "LBL_XZTOOLBAR_LABEL" );\r
-    break;\r
-  case YZPlane:\r
-    aToolbarName = tr( "LBL_YZTOOLBAR_LABEL" );\r
-    break;\r
-  default:\r
-    aToolbarName = tr( "LBL_3DTOOLBAR_LABEL" );\r
-  }\r
-  \r
-  int tid = toolMgr()->createToolBar( aToolbarName, false );\r
-  if ( my2dMode != No2dMode ){\r
-    toolMgr()->append( ReturnTo3dViewId, tid );\r
-    toolMgr()->append( toolMgr()->separator(), tid );\r
-  }\r
-  toolMgr()->append( DumpId, tid );\r
-  toolMgr()->append( SwitchInteractionStyleId, tid );\r
-#if OCC_VERSION_LARGE > 0x0603000A // available only with OCC-6.3-sp11 and higher version\r
-  toolMgr()->append( SwitchZoomingStyleId, tid );\r
-#endif\r
-  toolMgr()->append( SwitchPreselectionId, tid );\r
-  toolMgr()->append( SwitchSelectionId, tid );\r
-  if( myModel->trihedronActivated() )\r
-    toolMgr()->append( TrihedronShowId, tid );\r
-\r
-  QtxMultiAction* aScaleAction = new QtxMultiAction( this );\r
-  aScaleAction->insertAction( toolMgr()->action( FitAllId ) );\r
-  aScaleAction->insertAction( toolMgr()->action( FitRectId ) );\r
-  aScaleAction->insertAction( toolMgr()->action( ZoomId ) );\r
-  toolMgr()->append( aScaleAction, tid );\r
-\r
-  QtxMultiAction* aPanningAction = new QtxMultiAction( this );\r
-  aPanningAction->insertAction( toolMgr()->action( PanId ) );\r
-  aPanningAction->insertAction( toolMgr()->action( GlobalPanId ) );\r
-  toolMgr()->append( aPanningAction, tid );\r
-\r
-  if (my2dMode == No2dMode) {\r
-    toolMgr()->append( ChangeRotationPointId, tid );\r
-    toolMgr()->append( RotationId, tid );\r
-\r
-    QtxMultiAction* aViewsAction = new QtxMultiAction( this );\r
-    aViewsAction->insertAction( toolMgr()->action( FrontId ) );\r
-    aViewsAction->insertAction( toolMgr()->action( BackId ) );\r
-    aViewsAction->insertAction( toolMgr()->action( TopId ) );\r
-    aViewsAction->insertAction( toolMgr()->action( BottomId ) );\r
-    aViewsAction->insertAction( toolMgr()->action( LeftId ) );\r
-    aViewsAction->insertAction( toolMgr()->action( RightId ) );\r
-    toolMgr()->append( aViewsAction, tid );\r
-\r
-    toolMgr()->append( AntiClockWiseId, tid );\r
-    toolMgr()->append( ClockWiseId, tid );\r
-\r
-    toolMgr()->append( ResetId, tid );\r
-  }\r
-\r
-  QtxMultiAction* aMemAction = new QtxMultiAction( this );\r
-  aMemAction->insertAction( toolMgr()->action( MemId ) );\r
-  aMemAction->insertAction( toolMgr()->action( RestoreId ) );\r
-  toolMgr()->append( aMemAction, tid );\r
-\r
-  toolMgr()->append( toolMgr()->separator(), tid );\r
-  toolMgr()->append( CloneId, tid );\r
-  \r
-  toolMgr()->append( toolMgr()->separator(), tid );\r
-  toolMgr()->append( ClippingId, tid );\r
-  toolMgr()->append( AxialScaleId, tid );\r
-#if OCC_VERSION_LARGE > 0x06030009 // available only with OCC-6.3-sp10 and higher version\r
-  toolMgr()->append( GraduatedAxesId, tid );\r
-#endif\r
-  toolMgr()->append( AmbientId, tid );\r
-\r
-  toolMgr()->append( MaximizedId, tid );\r
-  toolMgr()->append( SynchronizeId, tid );\r
-}\r
-\r
-/*!\r
-  \brief Perform 'fit all' operation.\r
-*/\r
-void OCCViewer_ViewWindow::onViewFitAll()\r
-{\r
-  myViewPort->fitAll();\r
-}\r
-\r
-/*!\r
-  \brief Perform "front view" transformation.\r
-*/\r
-void OCCViewer_ViewWindow::onFrontView()\r
-{\r
-  emit vpTransformationStarted ( FRONTVIEW );\r
-  Handle(V3d_View) aView3d = myViewPort->getView();\r
-  if ( !aView3d.IsNull() ) aView3d->SetProj (V3d_Xpos);\r
-  onViewFitAll();\r
-  emit vpTransformationFinished ( FRONTVIEW );\r
-}\r
-\r
-/*!\r
-  \brief Perform "back view" transformation.\r
-*/\r
-void OCCViewer_ViewWindow::onBackView()\r
-{\r
-  emit vpTransformationStarted ( BACKVIEW );\r
-  Handle(V3d_View) aView3d = myViewPort->getView();\r
-  if ( !aView3d.IsNull() ) aView3d->SetProj (V3d_Xneg);\r
-  onViewFitAll();\r
-  emit vpTransformationFinished ( BACKVIEW );\r
-}\r
-\r
-/*!\r
-  \brief Perform "top view" transformation.\r
-*/\r
-void OCCViewer_ViewWindow::onTopView()\r
-{\r
-  emit vpTransformationStarted ( TOPVIEW );\r
-  Handle(V3d_View) aView3d = myViewPort->getView();\r
-  if ( !aView3d.IsNull() ) aView3d->SetProj (V3d_Zpos);\r
-  onViewFitAll();\r
-  emit vpTransformationFinished ( TOPVIEW );\r
-}\r
-\r
-/*!\r
-  \brief Perform "bottom view" transformation.\r
-*/\r
-void OCCViewer_ViewWindow::onBottomView()\r
-{\r
-  emit vpTransformationStarted ( BOTTOMVIEW );\r
-  Handle(V3d_View) aView3d = myViewPort->getView();\r
-  if ( !aView3d.IsNull() ) aView3d->SetProj (V3d_Zneg);\r
-  onViewFitAll();\r
-  emit vpTransformationFinished ( BOTTOMVIEW );\r
-}\r
-\r
-/*!\r
-  \brief Perform "left view" transformation.\r
-*/\r
-void OCCViewer_ViewWindow::onLeftView()\r
-{\r
-  emit vpTransformationStarted ( LEFTVIEW );\r
-  Handle(V3d_View) aView3d = myViewPort->getView();\r
-  if ( !aView3d.IsNull() ) aView3d->SetProj (V3d_Yneg);\r
-  onViewFitAll();\r
-  emit vpTransformationFinished ( LEFTVIEW );\r
-}\r
-\r
-/*!\r
-  \brief Perform "right view" transformation.\r
-*/\r
-void OCCViewer_ViewWindow::onRightView()\r
-{\r
-  emit vpTransformationStarted ( RIGHTVIEW );\r
-  Handle(V3d_View) aView3d = myViewPort->getView();\r
-  if ( !aView3d.IsNull() ) aView3d->SetProj (V3d_Ypos);\r
-  onViewFitAll();\r
-  emit vpTransformationFinished ( RIGHTVIEW );\r
-}\r
-\r
-/*!\r
-  \brief Rotate view 90 degrees clockwise\r
-*/\r
-void OCCViewer_ViewWindow::onClockWiseView()\r
-{\r
-  emit vpTransformationStarted ( CLOCKWISEVIEW );\r
-  myViewPort->rotateXY( 90. );\r
-  emit vpTransformationFinished ( CLOCKWISEVIEW );\r
-}\r
-\r
-/*!\r
-  \brief Rotate view 90 degrees conterclockwise\r
-*/\r
-void OCCViewer_ViewWindow::onAntiClockWiseView()\r
-{\r
-  emit vpTransformationStarted ( ANTICLOCKWISEVIEW );\r
-  myViewPort->rotateXY( -90. );\r
-  emit vpTransformationFinished ( ANTICLOCKWISEVIEW );\r
-}\r
-\r
-/*!\r
-  \brief Perform "reset view" transformation.\r
-\r
-  Sets default orientation of the viewport camera.\r
-*/\r
-void OCCViewer_ViewWindow::onResetView()\r
-{\r
-  emit vpTransformationStarted( RESETVIEW );\r
-  bool upd = myViewPort->getView()->SetImmediateUpdate( false );\r
-  myViewPort->getView()->Reset( false );\r
-  myViewPort->fitAll( false, true, false );\r
-  myViewPort->getView()->SetImmediateUpdate( upd );\r
-  myViewPort->getView()->Update();\r
-  emit vpTransformationFinished( RESETVIEW );\r
-}\r
-\r
-/*!\r
-  \brief Perform "fit all" transformation.\r
-*/\r
-void OCCViewer_ViewWindow::onFitAll()\r
-{\r
-  emit vpTransformationStarted( FITALLVIEW );\r
-  myViewPort->fitAll();\r
-  emit vpTransformationFinished( FITALLVIEW );\r
-}\r
-\r
-/*!\r
-  \brief Called if 'change rotation point' operation is activated.\r
-  \param on action state\r
-*/\r
-void OCCViewer_ViewWindow::onSetRotationPoint( bool on )\r
-{\r
-  if (on)\r
-  {\r
-    if (!mySetRotationPointDlg)\r
-    {\r
-      mySetRotationPointDlg = new OCCViewer_SetRotationPointDlg (this);\r
-      mySetRotationPointDlg->SetAction(mySetRotationPointAction);\r
-    }\r
-\r
-    if (!mySetRotationPointDlg->isVisible())\r
-    {\r
-      //if (mySetRotationPointDlg->IsFirstShown())\r
-      if (myCurrPointType == GRAVITY)\r
-      {\r
-        Standard_Real Xcenter, Ycenter, Zcenter;\r
-        if (computeGravityCenter(Xcenter, Ycenter, Zcenter))\r
-          mySetRotationPointDlg->setCoords(Xcenter, Ycenter, Zcenter);\r
-      }\r
-      mySetRotationPointDlg->show();\r
-    }\r
-  }\r
-  else\r
-  {\r
-    if (mySetRotationPointDlg->isVisible())\r
-      mySetRotationPointDlg->hide();\r
-  }\r
-}\r
-\r
-/*!\r
-   \brief Create one more window with same content.\r
-*/\r
-void OCCViewer_ViewWindow::onCloneView()\r
-{\r
-  SUIT_ViewWindow* vw = myManager->createViewWindow();\r
-  //vw->show();\r
-  emit viewCloned( vw );\r
-}\r
-\r
-/*!\r
-  Creates one more window with same content\r
-*/\r
-void OCCViewer_ViewWindow::onAxialScale()\r
-{\r
-  if ( !myScalingDlg )\r
-    myScalingDlg = new OCCViewer_AxialScaleDlg( this );\r
-  \r
-  if ( !myScalingDlg->isVisible() )\r
-  {\r
-    myScalingDlg->Update();\r
-    myScalingDlg->show();\r
-  }\r
-}\r
-\r
-/*!\r
-  Shows Graduated Axes dialog\r
-*/\r
-void OCCViewer_ViewWindow::onGraduatedAxes()\r
-{\r
-  myCubeAxesDlg->Update();\r
-  myCubeAxesDlg->show();\r
-}\r
-\r
-void OCCViewer_ViewWindow::onAmbientToogle()\r
-{\r
-  Handle(V3d_Viewer) viewer = myViewPort->getViewer();\r
-  viewer->InitDefinedLights();\r
-  while(viewer->MoreDefinedLights())\r
-    {\r
-      Handle(V3d_Light) light = viewer->DefinedLight();\r
-      if(light->Type() != V3d_AMBIENT)\r
-        {\r
-          Handle(V3d_View) aView3d = myViewPort->getView();\r
-          if( aView3d->IsActiveLight(light) ) viewer->SetLightOff(light);\r
-          else viewer->SetLightOn(light);\r
-        }\r
-      viewer->NextDefinedLights();\r
-    }\r
-  viewer->Update();\r
-}\r
-\r
-/*!\r
-  \brief Store view parameters.\r
-*/\r
-void OCCViewer_ViewWindow::onMemorizeView()\r
-{\r
-  appendViewAspect( getViewParams() );\r
-}\r
-\r
-/*!\r
-  \brief Restore view parameters.\r
-*/\r
-void OCCViewer_ViewWindow::onRestoreView()\r
-{\r
-  OCCViewer_CreateRestoreViewDlg* aDlg = new OCCViewer_CreateRestoreViewDlg( centralWidget(), this );\r
-  connect( aDlg, SIGNAL( dlgOk() ), this, SLOT( setRestoreFlag() ) );\r
-  aDlg->exec();\r
-  updateViewAspects( aDlg->parameters() );\r
-  if( myRestoreFlag && aDlg->parameters().count() )\r
-    performRestoring( aDlg->currentItem() );\r
-}\r
-\r
-/*!\r
-  \brief Restore view parameters.\r
-  \param anItem view parameters\r
-*/\r
-void OCCViewer_ViewWindow::performRestoring( const viewAspect& anItem, bool baseParamsOnly )\r
-{\r
-  Handle(V3d_View) aView3d = myViewPort->getView();\r
-\r
-  Standard_Boolean prev = aView3d->SetImmediateUpdate( Standard_False );\r
-  aView3d->SetScale( anItem.scale );\r
-  aView3d->SetTwist( anItem.twist );\r
-  aView3d->SetAt( anItem.atX, anItem.atY, anItem.atZ );\r
-  aView3d->SetImmediateUpdate( prev );\r
-  aView3d->SetEye( anItem.eyeX, anItem.eyeY, anItem.eyeZ );\r
-  aView3d->SetProj( anItem.projX, anItem.projY, anItem.projZ );\r
-  aView3d->SetAxialScale( anItem.scaleX, anItem.scaleY, anItem.scaleZ );\r
-\r
-#if OCC_VERSION_LARGE > 0x06070100\r
-  if ( anItem.centerX != 0.0 || anItem.centerY != 0.0 )\r
-  {\r
-    double anUpX = 0.0, anUpY = 0.0, anUpZ = 0.0;\r
-\r
-    // "eye" and "at" require conversion to represent center panning\r
-    // up direction is only available after setting angle of twist and\r
-    // other view parameters\r
-    aView3d->Up( anUpX, anUpY, anUpZ );\r
-\r
-    gp_Dir aProj( -anItem.projX, -anItem.projY, -anItem.projZ );\r
-    gp_Dir anUp( anUpX, anUpY, anUpZ );\r
-    gp_Pnt anAt( anItem.atX, anItem.atY, anItem.atZ );\r
-    gp_Pnt anEye( anItem.eyeX, anItem.eyeY, anItem.eyeZ );\r
-    gp_Dir aSide = aProj ^ anUp;\r
-\r
-    anAt.Translate( gp_Vec( aSide ) * anItem.centerX );\r
-    anAt.Translate( gp_Vec( anUp  ) * anItem.centerY );\r
-\r
-    aView3d->SetAt( anAt.X(), anAt.Y(), anAt.Z() );\r
-    aView3d->SetProj( anItem.projX, anItem.projY, anItem.projZ );\r
-  }\r
-#else\r
-  aView3d->SetCenter( anItem.centerX, anItem.centerY );\r
-#endif\r
-\r
-  if ( !baseParamsOnly ) {\r
-\r
-    myModel->setTrihedronShown( anItem.isVisible );\r
-    myModel->setTrihedronSize( anItem.size );\r
-        \r
-#if OCC_VERSION_LARGE > 0x06030009 // available only with OCC-6.3-sp10 and higher version\r
-    // graduated trihedron\r
-    bool anIsVisible = anItem.gtIsVisible;\r
-    OCCViewer_AxisWidget::AxisData anAxisData[3];\r
-    anAxisData[0].DrawName = anItem.gtDrawNameX;\r
-    anAxisData[1].DrawName = anItem.gtDrawNameZ;\r
-    anAxisData[2].DrawName = anItem.gtDrawNameZ;\r
-    anAxisData[0].Name = anItem.gtNameX;\r
-    anAxisData[1].Name = anItem.gtNameZ;\r
-    anAxisData[2].Name = anItem.gtNameZ;\r
-    anAxisData[0].NameColor = QColor( anItem.gtNameColorRX,\r
-              anItem.gtNameColorGX,\r
-              anItem.gtNameColorBX );\r
-    anAxisData[1].NameColor = QColor( anItem.gtNameColorRY,\r
-              anItem.gtNameColorGY,\r
-              anItem.gtNameColorBY );\r
-    anAxisData[2].NameColor = QColor( anItem.gtNameColorRZ,\r
-              anItem.gtNameColorGZ,\r
-              anItem.gtNameColorBZ );\r
-    anAxisData[0].DrawValues = anItem.gtDrawValuesX;\r
-    anAxisData[1].DrawValues = anItem.gtDrawValuesY;\r
-    anAxisData[2].DrawValues = anItem.gtDrawValuesZ;\r
-    anAxisData[0].NbValues = anItem.gtNbValuesX;\r
-    anAxisData[1].NbValues = anItem.gtNbValuesY;\r
-    anAxisData[2].NbValues = anItem.gtNbValuesZ;\r
-    anAxisData[0].Offset = anItem.gtOffsetX;\r
-    anAxisData[1].Offset = anItem.gtOffsetY;\r
-    anAxisData[2].Offset = anItem.gtOffsetZ;\r
-    anAxisData[0].Color = QColor( anItem.gtColorRX,\r
-          anItem.gtColorGX,\r
-          anItem.gtColorBX );\r
-    anAxisData[1].Color = QColor( anItem.gtColorRY,\r
-          anItem.gtColorGY,\r
-          anItem.gtColorBY );\r
-    anAxisData[2].Color = QColor( anItem.gtColorRZ,\r
-          anItem.gtColorGZ,\r
-          anItem.gtColorBZ );\r
-    anAxisData[0].DrawTickmarks = anItem.gtDrawTickmarksX;\r
-    anAxisData[1].DrawTickmarks = anItem.gtDrawTickmarksY;\r
-    anAxisData[2].DrawTickmarks = anItem.gtDrawTickmarksZ;\r
-    anAxisData[0].TickmarkLength = anItem.gtTickmarkLengthX;\r
-    anAxisData[1].TickmarkLength = anItem.gtTickmarkLengthY;\r
-    anAxisData[2].TickmarkLength = anItem.gtTickmarkLengthZ;\r
-\r
-    myCubeAxesDlg->SetData( anIsVisible, anAxisData );\r
-    myCubeAxesDlg->ApplyData( aView3d );\r
-#endif\r
-\r
-  } // if ( !baseParamsOnly )\r
-\r
-  myRestoreFlag = 0;\r
-}\r
-\r
-/*!\r
-  \brief Set restore flag.\r
-*/\r
-void OCCViewer_ViewWindow::setRestoreFlag()\r
-{\r
-  myRestoreFlag = 1;\r
-}\r
-\r
-/*!\r
-  \brief Called when action "show/hide trihedron" is activated.\r
-*/\r
-void OCCViewer_ViewWindow::onTrihedronShow()\r
-{\r
-  myModel->toggleTrihedron();\r
-}\r
-\r
-/*!\r
-  \brief Toggles preselection (highlighting) on/off\r
-*/\r
-void OCCViewer_ViewWindow::onSwitchPreselection( bool on )\r
-{\r
-  myPreselectionEnabled = on;\r
-  myModel->setSelectionOptions( isPreselectionEnabled(), myModel->isSelectionEnabled() );\r
-\r
-  // unhighlight all highlighted objects\r
-  /*if ( !on ) {\r
-    myModel->unHighlightAll( true, false );\r
-  }*/\r
-\r
-  // update action state if method is called outside\r
-  QtxAction* a = dynamic_cast<QtxAction*>( toolMgr()->action( SwitchPreselectionId ) );\r
-  if ( a && a->isChecked() != on ) {\r
-    a->setChecked( on );\r
-  }\r
-}\r
-\r
-/*!\r
-  \brief Toggles selection on/off\r
-*/\r
-void OCCViewer_ViewWindow::onSwitchSelection( bool on )\r
-{\r
-  mySelectionEnabled = on;\r
-  myModel->setSelectionOptions( myModel->isPreselectionEnabled(), isSelectionEnabled() );\r
-  \r
-  // update action state if method is called outside\r
-\r
-  // preselection\r
-  QtxAction* a = dynamic_cast<QtxAction*>( toolMgr()->action( SwitchPreselectionId ) );\r
-  if ( a ) {\r
-    a->setEnabled( on );\r
-  }\r
-\r
-  // selection\r
-  a = dynamic_cast<QtxAction*>( toolMgr()->action( SwitchSelectionId ) );\r
-  if ( a && a->isChecked() != on ) {\r
-    a->setChecked( on );\r
-  }\r
-}\r
-\r
-/*!\r
-  \brief Switches "keyboard free" interaction style on/off\r
-*/\r
-void OCCViewer_ViewWindow::onSwitchInteractionStyle( bool on )\r
-{\r
-  myInteractionStyle = on ? (int)SUIT_ViewModel::KEY_FREE : (int)SUIT_ViewModel::STANDARD;\r
-\r
-  // update action state if method is called outside\r
-  QtxAction* a = dynamic_cast<QtxAction*>( toolMgr()->action( SwitchInteractionStyleId ) );\r
-  if ( a->isChecked() != on )\r
-    a->setChecked( on );\r
-}\r
-\r
-/*!\r
-  \brief Toogles advanced zooming style (relatively to the cursor position) on/off\r
-*/\r
-void OCCViewer_ViewWindow::onSwitchZoomingStyle( bool on )\r
-{\r
-  myViewPort->setAdvancedZoomingEnabled( on );\r
-\r
-  // update action state if method is called outside\r
-  QtxAction* a = dynamic_cast<QtxAction*>( toolMgr()->action( SwitchZoomingStyleId ) );\r
-  if ( a->isChecked() != on )\r
-    a->setChecked( on );\r
-}\r
-\r
-/*!\r
-  \brief Get current interaction style\r
-  \return interaction style\r
-*/\r
-int OCCViewer_ViewWindow::interactionStyle() const\r
-{\r
-  return myInteractionStyle;\r
-}\r
-\r
-/*!\r
-  \brief Set current interaction style\r
-  \param theStyle interaction style\r
-*/\r
-void OCCViewer_ViewWindow::setInteractionStyle( const int theStyle )\r
-{\r
-  onSwitchInteractionStyle( theStyle == (int)SUIT_ViewModel::KEY_FREE );\r
-}\r
-\r
-/*!\r
-  \brief Get current zooming style\r
-  \return zooming style\r
-*/\r
-int OCCViewer_ViewWindow::zoomingStyle() const\r
-{\r
-  return myViewPort->isAdvancedZoomingEnabled() ? 1 : 0;\r
-}\r
-\r
-/*!\r
-  \brief Set current zooming style\r
-  \param theStyle zooming style\r
-*/\r
-void OCCViewer_ViewWindow::setZoomingStyle( const int theStyle )\r
-{\r
-  onSwitchZoomingStyle( theStyle == 1 );\r
-}\r
-\r
-/*!\r
-  \brief Dump view window contents to the pixmap.\r
-  \return pixmap containing all scene rendered in the window\r
-*/\r
-QImage OCCViewer_ViewWindow::dumpView()\r
-{\r
-  Handle(V3d_View) view = myViewPort->getView();\r
-  if ( view.IsNull() )\r
-    return QImage();\r
-  \r
-  int aWidth = myViewPort->width();\r
-  int aHeight = myViewPort->height();\r
-  QApplication::syncX();\r
-  view->Redraw(); // In order to reactivate GL context\r
-  //view->Update();\r
-\r
-  OpenGLUtils_FrameBuffer aFrameBuffer;\r
-  if( aFrameBuffer.init( aWidth, aHeight ) )\r
-  {\r
-    QImage anImage( aWidth, aHeight, QImage::Format_RGB32 );\r
-   \r
-    glPushAttrib( GL_VIEWPORT_BIT );\r
-    glViewport( 0, 0, aWidth, aHeight );\r
-    aFrameBuffer.bind();\r
-\r
-    // draw scene\r
-    view->Redraw();\r
-\r
-    aFrameBuffer.unbind();\r
-    glPopAttrib();\r
-\r
-    aFrameBuffer.bind();\r
-    glReadPixels( 0, 0, aWidth, aHeight, GL_RGBA, GL_UNSIGNED_BYTE, anImage.bits() );\r
-    aFrameBuffer.unbind();\r
-\r
-    anImage = anImage.rgbSwapped();\r
-    anImage = anImage.mirrored();\r
-    return anImage;\r
-  }\r
-  // if frame buffers are unsupported, use old functionality\r
-  //view->Redraw();\r
-\r
-  unsigned char* data = new unsigned char[ aWidth*aHeight*4 ];\r
-\r
-  QPoint p = myViewPort->mapFromParent(myViewPort->geometry().topLeft());\r
-\r
-  glReadPixels( p.x(), p.y(), aWidth, aHeight, GL_RGBA, GL_UNSIGNED_BYTE,\r
-                data);\r
-\r
-  QImage anImage( data, aWidth, aHeight, QImage::Format_ARGB32 );\r
-  anImage = anImage.mirrored();\r
-  anImage = anImage.rgbSwapped();\r
-  return anImage;\r
-}\r
-\r
-bool OCCViewer_ViewWindow::dumpViewToFormat( const QImage& img, \r
-                                             const QString& fileName, \r
-                                             const QString& format )\r
-{\r
-  if ( format != "PS" && format != "EPS")\r
-    return SUIT_ViewWindow::dumpViewToFormat( img, fileName, format );\r
-\r
-  Handle(Visual3d_View) a3dView = myViewPort->getView()->View();\r
-\r
-  if (format == "PS")\r
-    a3dView->Export(strdup(qPrintable(fileName)), Graphic3d_EF_PostScript);\r
-  else if (format == "EPS")\r
-    a3dView->Export(strdup(qPrintable(fileName)), Graphic3d_EF_EnhPostScript);\r
-\r
-  return true;\r
-}\r
-\r
-\r
-QString OCCViewer_ViewWindow::filter() const\r
-{\r
-  return tr( "OCC_IMAGE_FILES" );\r
-}\r
-\r
-\r
-/*!\r
-  \brief Set parameters of the cutting plane\r
-  \param on if \c true, cutting plane is enabled\r
-  \param x X position of plane point\r
-  \param y Y position of plane point\r
-  \param z Z position of plane point\r
-  \param dx X coordinate of plane normal\r
-  \param dy Y coordinate of plane normal\r
-  \param dz Z coordinate of plane normal\r
-*/\r
-void OCCViewer_ViewWindow::setCuttingPlane( bool on, const double x,  const double y,  const double z,\r
-                                            const double dx, const double dy, const double dz )\r
-{\r
-  Handle(V3d_View) view = myViewPort->getView();\r
-  if ( view.IsNull() )\r
-    return;\r
-\r
-  if ( on ) {\r
-    Handle(V3d_Viewer) viewer = myViewPort->getViewer();\r
-\r
-    // try to use already existing plane or create a new one\r
-    Handle(V3d_Plane) clipPlane;\r
-\r
-    // calculate new a,b,c,d values for the plane\r
-    gp_Pln pln (gp_Pnt(x, y, z), gp_Dir(dx, dy, dz));\r
-    double a, b, c, d;\r
-    pln.Coefficients(a, b, c, d);\r
-    \r
-    Graphic3d_SequenceOfHClipPlane aPlanes = view->GetClipPlanes();\r
-    Handle(Graphic3d_ClipPlane) aClipPlane;\r
-    if(aPlanes.Size() > 0 ) {\r
-      Graphic3d_SequenceOfHClipPlane::Iterator anIter (aPlanes);\r
-      aClipPlane = anIter.Value();\r
-      aClipPlane->SetEquation(pln);\r
-      aClipPlane->SetOn(Standard_True);\r
-    } else {\r
-      aClipPlane = new Graphic3d_ClipPlane(pln);\r
-      view->AddClipPlane(aClipPlane);\r
-      aClipPlane->SetOn(Standard_True);\r
-    }\r
-  }\r
-  else {\r
-    Graphic3d_SequenceOfHClipPlane aPlanes = view->GetClipPlanes();\r
-    Graphic3d_SequenceOfHClipPlane::Iterator anIter (aPlanes);\r
-    for( ;anIter.More();anIter.Next() ){\r
-      Handle(Graphic3d_ClipPlane) aClipPlane = anIter.Value();\r
-      aClipPlane->SetOn(Standard_False);\r
-    }\r
-  }\r
-\r
-  view->Update();\r
-  view->Redraw();\r
-}\r
-\r
-void OCCViewer_ViewWindow::setCuttingPlane( bool on, const gp_Pln pln )\r
-{\r
-  gp_Dir aDir = pln.Axis().Direction();\r
-  gp_Pnt aPnt = pln.Location();\r
-  setCuttingPlane(on, aPnt.X(), aPnt.Y(), aPnt.Z(), aDir.X(), aDir.Y(), aDir.Z());\r
-}\r
-\r
-\r
-/*!\r
-  \brief Check if any cutting plane is enabled\r
-  \return \c true if at least one cutting plane is enabled\r
-*/\r
-bool OCCViewer_ViewWindow::isCuttingPlane()\r
-{\r
-  Handle(V3d_View) view = myViewPort->getView();\r
-  bool res = false;\r
-  Graphic3d_SequenceOfHClipPlane aPlanes = view->GetClipPlanes();\r
-  Graphic3d_SequenceOfHClipPlane::Iterator anIter (aPlanes);\r
-  for( ;anIter.More();anIter.Next() ) {\r
-    Handle(Graphic3d_ClipPlane) aClipPlane = anIter.Value();\r
-    if(aClipPlane->IsOn()) {\r
-      res = true;\r
-      break;\r
-    }\r
-  }\r
-  return res;\r
-}\r
-\r
-/*!\r
-  \brief Get the visual parameters of the view window.\r
-  \return visual parameters of view window\r
-*/\r
-viewAspect OCCViewer_ViewWindow::getViewParams() const\r
-{\r
-  double projX, projY, projZ, twist;\r
-  double atX, atY, atZ, eyeX, eyeY, eyeZ;\r
-  double aScaleX, aScaleY, aScaleZ;\r
-\r
-  Handle(V3d_View) aView3d = myViewPort->getView();\r
-\r
-  aView3d->Proj( projX, projY, projZ );\r
-  aView3d->At( atX, atY, atZ );\r
-  aView3d->Eye( eyeX, eyeY, eyeZ );\r
-  twist = aView3d->Twist();\r
-\r
-  aView3d->AxialScale(aScaleX,aScaleY,aScaleZ);\r
-\r
-  bool isShown = myModel->isTrihedronVisible();\r
-  double size = myModel->trihedronSize();\r
-\r
-  QString aName = QTime::currentTime().toString() + QString::fromLatin1( " h:m:s" );\r
-\r
-  viewAspect params;\r
-  params.scale    = aView3d->Scale();\r
-  params.projX    = projX;\r
-  params.projY    = projY;\r
-  params.projZ    = projZ;\r
-  params.twist    = twist;\r
-  params.atX      = atX;\r
-  params.atY      = atY;\r
-  params.atZ      = atZ;\r
-  params.eyeX     = eyeX;\r
-  params.eyeY     = eyeY;\r
-  params.eyeZ     = eyeZ;\r
-  params.scaleX   = aScaleX;\r
-  params.scaleY   = aScaleY;\r
-  params.scaleZ   = aScaleZ;\r
-  params.name     = aName;\r
-  params.isVisible= isShown;\r
-  params.size     = size;\r
-\r
-#if OCC_VERSION_LARGE <= 0x06070100 // the property is deprecated after OCCT 6.7.1\r
-  aView3d->Center( params.centerX, params.centerY );\r
-#endif\r
-\r
-#if OCC_VERSION_LARGE > 0x06030009 // available only with OCC-6.3-sp10 and higher version\r
-  // graduated trihedron\r
-  bool anIsVisible = false;\r
-  OCCViewer_AxisWidget::AxisData anAxisData[3];\r
-  myCubeAxesDlg->GetData( anIsVisible, anAxisData );\r
-\r
-  params.gtIsVisible = anIsVisible;\r
-  params.gtDrawNameX = anAxisData[0].DrawName;\r
-  params.gtDrawNameY = anAxisData[1].DrawName;\r
-  params.gtDrawNameZ = anAxisData[2].DrawName;\r
-  params.gtNameX = anAxisData[0].Name;\r
-  params.gtNameY = anAxisData[1].Name;\r
-  params.gtNameZ = anAxisData[2].Name;\r
-  params.gtNameColorRX = anAxisData[0].NameColor.red();\r
-  params.gtNameColorGX = anAxisData[0].NameColor.green();\r
-  params.gtNameColorBX = anAxisData[0].NameColor.blue();\r
-  params.gtNameColorRY = anAxisData[1].NameColor.red();\r
-  params.gtNameColorGY = anAxisData[1].NameColor.green();\r
-  params.gtNameColorBY = anAxisData[1].NameColor.blue();\r
-  params.gtNameColorRZ = anAxisData[2].NameColor.red();\r
-  params.gtNameColorGZ = anAxisData[2].NameColor.green();\r
-  params.gtNameColorBZ = anAxisData[2].NameColor.blue();\r
-  params.gtDrawValuesX = anAxisData[0].DrawValues;\r
-  params.gtDrawValuesY = anAxisData[1].DrawValues;\r
-  params.gtDrawValuesZ = anAxisData[2].DrawValues;\r
-  params.gtNbValuesX = anAxisData[0].NbValues;\r
-  params.gtNbValuesY = anAxisData[1].NbValues;\r
-  params.gtNbValuesZ = anAxisData[2].NbValues;\r
-  params.gtOffsetX = anAxisData[0].Offset;\r
-  params.gtOffsetY = anAxisData[1].Offset;\r
-  params.gtOffsetZ = anAxisData[2].Offset;\r
-  params.gtColorRX = anAxisData[0].Color.red();\r
-  params.gtColorGX = anAxisData[0].Color.green();\r
-  params.gtColorBX = anAxisData[0].Color.blue();\r
-  params.gtColorRY = anAxisData[1].Color.red();\r
-  params.gtColorGY = anAxisData[1].Color.green();\r
-  params.gtColorBY = anAxisData[1].Color.blue();\r
-  params.gtColorRZ = anAxisData[2].Color.red();\r
-  params.gtColorGZ = anAxisData[2].Color.green();\r
-  params.gtColorBZ = anAxisData[2].Color.blue();\r
-  params.gtDrawTickmarksX = anAxisData[0].DrawTickmarks;\r
-  params.gtDrawTickmarksY = anAxisData[1].DrawTickmarks;\r
-  params.gtDrawTickmarksZ = anAxisData[2].DrawTickmarks;\r
-  params.gtTickmarkLengthX = anAxisData[0].TickmarkLength;\r
-  params.gtTickmarkLengthY = anAxisData[1].TickmarkLength;\r
-  params.gtTickmarkLengthZ = anAxisData[2].TickmarkLength;\r
-#endif\r
-\r
-  return params;\r
-}\r
-\r
-/*!\r
-  \brief Get visual parameters of this view window.\r
-  \return visual parameters of view window\r
-*/\r
-QString OCCViewer_ViewWindow::getVisualParameters()\r
-{\r
-  viewAspect params = getViewParams();\r
-\r
-  QStringList data;\r
-\r
-  data << QString( "scale=%1" )    .arg( params.scale,   0, 'e', 12 );\r
-#if OCC_VERSION_LARGE <= 0x06070100 // the property is deprecated after OCCT 6.7.1\r
-  data << QString( "centerX=%1" )  .arg( params.centerX, 0, 'e', 12 );\r
-  data << QString( "centerY=%1" )  .arg( params.centerY, 0, 'e', 12 );\r
-#endif\r
-  data << QString( "projX=%1" )    .arg( params.projX,   0, 'e', 12 );\r
-  data << QString( "projY=%1" )    .arg( params.projY,   0, 'e', 12 );\r
-  data << QString( "projZ=%1" )    .arg( params.projZ,   0, 'e', 12 );\r
-  data << QString( "twist=%1" )    .arg( params.twist,   0, 'e', 12 );\r
-  data << QString( "atX=%1" )      .arg( params.atX,     0, 'e', 12 );\r
-  data << QString( "atY=%1" )      .arg( params.atY,     0, 'e', 12 );\r
-  data << QString( "atZ=%1" )      .arg( params.atZ,     0, 'e', 12 );\r
-  data << QString( "eyeX=%1" )     .arg( params.eyeX,    0, 'e', 12 );\r
-  data << QString( "eyeY=%1" )     .arg( params.eyeY,    0, 'e', 12 );\r
-  data << QString( "eyeZ=%1" )     .arg( params.eyeZ,    0, 'e', 12 );\r
-  data << QString( "scaleX=%1" )   .arg( params.scaleX,  0, 'e', 12 );\r
-  data << QString( "scaleY=%1" )   .arg( params.scaleY,  0, 'e', 12 );\r
-  data << QString( "scaleZ=%1" )   .arg( params.scaleZ,  0, 'e', 12 );\r
-  data << QString( "isVisible=%1" ).arg( params.isVisible );\r
-  data << QString( "size=%1" )     .arg( params.size,    0, 'f',  2 );\r
-\r
-  ClipPlanesList aPlanes =  myModel->getClipPlanes();\r
-  for ( int i=0; i < aPlanes.size(); i++ )\r
-  {\r
-    OCCViewer_ClipPlane& aPlane = aPlanes[i];\r
-    QString ClippingPlane = QString( "ClippingPlane%1=").arg( i+1 );\r
-    ClippingPlane +=  QString( "Mode~%1;").arg( (int)aPlane.Mode );\r
-    ClippingPlane +=  QString( "IsActive~%1;").arg( aPlane.IsOn );\r
-    switch ( aPlane.Mode )\r
-    {\r
-      case OCCViewer_ClipPlane::Absolute :\r
-      {\r
-        ClippingPlane += QString( "AbsoluteOrientation~%1;" ).arg( aPlane.OrientationType );\r
-\r
-        if ( aPlane.OrientationType == OCCViewer_ClipPlane::AbsoluteCustom )\r
-        {\r
-          ClippingPlane += QString( "Dx~%1;" ).arg( aPlane.AbsoluteOrientation.Dx );\r
-          ClippingPlane += QString( "Dy~%1;" ).arg( aPlane.AbsoluteOrientation.Dy );\r
-          ClippingPlane += QString( "Dz~%1;" ).arg( aPlane.AbsoluteOrientation.Dz );\r
-        }\r
-        else\r
-        {\r
-          ClippingPlane += QString( "IsInvert~%1;" ).arg( aPlane.AbsoluteOrientation.IsInvert );\r
-        }\r
-      }\r
-      break;\r
-\r
-      case OCCViewer_ClipPlane::Relative :\r
-      {\r
-        ClippingPlane += QString( "RelativeOrientation~%1;" ).arg( aPlane.OrientationType );\r
-        ClippingPlane += QString( "Rotation1~%1;" ).arg( aPlane.RelativeOrientation.Rotation1 );\r
-        ClippingPlane += QString( "Rotation2~%1" ).arg( aPlane.RelativeOrientation.Rotation2 );\r
-      }\r
-      break;\r
-    }\r
-\r
-    ClippingPlane +=  QString( "X~%1;" ).arg( aPlane.X );\r
-    ClippingPlane +=  QString( "Y~%1;" ).arg( aPlane.Y );\r
-    ClippingPlane +=  QString( "Z~%1;" ).arg( aPlane.Z );\r
-    data << ClippingPlane;\r
-  }\r
-\r
-\r
-#if OCC_VERSION_LARGE > 0x06030009 // available only with OCC-6.3-sp10 or newer version\r
-  // graduated trihedron\r
-  data << QString( "gtIsVisible=%1" )      .arg( params.gtIsVisible );\r
-  data << QString( "gtDrawNameX=%1" )      .arg( params.gtDrawNameX );\r
-  data << QString( "gtDrawNameY=%1" )      .arg( params.gtDrawNameY );\r
-  data << QString( "gtDrawNameZ=%1" )      .arg( params.gtDrawNameZ );\r
-  data << QString( "gtNameX=%1" )          .arg( params.gtNameX );\r
-  data << QString( "gtNameY=%1" )          .arg( params.gtNameY );\r
-  data << QString( "gtNameZ=%1" )          .arg( params.gtNameZ );\r
-  data << QString( "gtNameColorRX=%1" )    .arg( params.gtNameColorRX );\r
-  data << QString( "gtNameColorGX=%1" )    .arg( params.gtNameColorGX );\r
-  data << QString( "gtNameColorBX=%1" )    .arg( params.gtNameColorBX );\r
-  data << QString( "gtNameColorRY=%1" )    .arg( params.gtNameColorRY );\r
-  data << QString( "gtNameColorGY=%1" )    .arg( params.gtNameColorGY );\r
-  data << QString( "gtNameColorBY=%1" )    .arg( params.gtNameColorBY );\r
-  data << QString( "gtNameColorRZ=%1" )    .arg( params.gtNameColorRZ );\r
-  data << QString( "gtNameColorGZ=%1" )    .arg( params.gtNameColorGZ );\r
-  data << QString( "gtNameColorBZ=%1" )    .arg( params.gtNameColorBZ );\r
-  data << QString( "gtDrawValuesX=%1" )    .arg( params.gtDrawValuesX );\r
-  data << QString( "gtDrawValuesY=%1" )    .arg( params.gtDrawValuesY );\r
-  data << QString( "gtDrawValuesZ=%1" )    .arg( params.gtDrawValuesZ );\r
-  data << QString( "gtNbValuesX=%1" )      .arg( params.gtNbValuesX );\r
-  data << QString( "gtNbValuesY=%1" )      .arg( params.gtNbValuesY );\r
-  data << QString( "gtNbValuesZ=%1" )      .arg( params.gtNbValuesZ );\r
-  data << QString( "gtOffsetX=%1" )        .arg( params.gtOffsetX );\r
-  data << QString( "gtOffsetY=%1" )        .arg( params.gtOffsetY );\r
-  data << QString( "gtOffsetZ=%1" )        .arg( params.gtOffsetZ );\r
-  data << QString( "gtColorRX=%1" )        .arg( params.gtColorRX );\r
-  data << QString( "gtColorGX=%1" )        .arg( params.gtColorGX );\r
-  data << QString( "gtColorBX=%1" )        .arg( params.gtColorBX );\r
-  data << QString( "gtColorRY=%1" )        .arg( params.gtColorRY );\r
-  data << QString( "gtColorGY=%1" )        .arg( params.gtColorGY );\r
-  data << QString( "gtColorBY=%1" )        .arg( params.gtColorBY );\r
-  data << QString( "gtColorRZ=%1" )        .arg( params.gtColorRZ );\r
-  data << QString( "gtColorGZ=%1" )        .arg( params.gtColorGZ );\r
-  data << QString( "gtColorBZ=%1" )        .arg( params.gtColorBZ );\r
-  data << QString( "gtDrawTickmarksX=%1" ) .arg( params.gtDrawTickmarksX );\r
-  data << QString( "gtDrawTickmarksY=%1" ) .arg( params.gtDrawTickmarksY );\r
-  data << QString( "gtDrawTickmarksZ=%1" ) .arg( params.gtDrawTickmarksZ );\r
-  data << QString( "gtTickmarkLengthX=%1" ).arg( params.gtTickmarkLengthX );\r
-  data << QString( "gtTickmarkLengthY=%1" ).arg( params.gtTickmarkLengthY );\r
-  data << QString( "gtTickmarkLengthZ=%1" ).arg( params.gtTickmarkLengthZ );\r
-#endif\r
-  QString bg = Qtx::backgroundToString( background() ).replace( "=", "$" );\r
-  data << QString( "background=%1" ).arg( bg );\r
-\r
-  return data.join("*");\r
-}\r
-\r
-/*!\r
-  \brief Restore visual parameters of the view window.\r
-  \param parameters visual parameters of view window\r
-*/\r
-void OCCViewer_ViewWindow::setVisualParameters( const QString& parameters )\r
-{\r
-  viewAspect params;\r
-  ClipPlanesList aClipPlanes;\r
-  QStringList data = parameters.split( '*' );\r
-  Qtx::BackgroundData bgData;\r
-  if ( parameters.contains( '=' )  ) // new format - "scale=1.000e+00*centerX=0.000e+00..."\r
-  {\r
-    foreach( QString param, data ) {\r
-      QString paramName  = param.section( '=', 0, 0 ).trimmed();\r
-      QString paramValue = param.section( '=', 1, 1 ).trimmed();\r
-      if      ( paramName == "scale" )             params.scale             = paramValue.toDouble();\r
-      else if ( paramName == "centerX" )           params.centerX           = paramValue.toDouble();\r
-      else if ( paramName == "centerY" )           params.centerY           = paramValue.toDouble();\r
-      else if ( paramName == "projX" )             params.projX             = paramValue.toDouble();\r
-      else if ( paramName == "projY" )             params.projY             = paramValue.toDouble();\r
-      else if ( paramName == "projZ" )             params.projZ             = paramValue.toDouble();\r
-      else if ( paramName == "twist" )             params.twist             = paramValue.toDouble();\r
-      else if ( paramName == "atX" )               params.atX               = paramValue.toDouble();\r
-      else if ( paramName == "atY" )               params.atY               = paramValue.toDouble();\r
-      else if ( paramName == "atZ" )               params.atZ               = paramValue.toDouble();\r
-      else if ( paramName == "eyeX" )              params.eyeX              = paramValue.toDouble();\r
-      else if ( paramName == "eyeY" )              params.eyeY              = paramValue.toDouble();\r
-      else if ( paramName == "eyeZ" )              params.eyeZ              = paramValue.toDouble();\r
-      else if ( paramName == "scaleX" )            params.scaleX            = paramValue.toDouble();\r
-      else if ( paramName == "scaleY" )            params.scaleY            = paramValue.toDouble();\r
-      else if ( paramName == "scaleZ" )            params.scaleZ            = paramValue.toDouble();\r
-      else if ( paramName == "isVisible" )         params.isVisible         = paramValue.toInt();\r
-      else if ( paramName == "size" )              params.size              = paramValue.toDouble();\r
-      else if ( paramName.contains( "ClippingPlane" ) )\r
-      {\r
-        QStringList ClipPlaneData = paramValue.split( ';' );\r
-        OCCViewer_ClipPlane aPlane;\r
-        foreach( QString ClipPlaneParam, ClipPlaneData )\r
-        {\r
-          QString ClipPlane_paramName  = ClipPlaneParam.section( '~', 0, 0 ).trimmed();\r
-          QString ClipPlane_paramValue = ClipPlaneParam.section( '~', 1, 1 ).trimmed();\r
-          if ( ClipPlane_paramName == "Mode" )\r
-          {\r
-            aPlane.Mode = ( OCCViewer_ClipPlane::PlaneMode ) ClipPlane_paramValue.toInt();\r
-          }\r
-          else if ( ClipPlane_paramName == "IsActive" ) aPlane.IsOn = ClipPlane_paramValue.toInt();\r
-          else if ( ClipPlane_paramName == "X" )        aPlane.X    = ClipPlane_paramValue.toDouble();\r
-          else if ( ClipPlane_paramName == "Y" )        aPlane.Y    = ClipPlane_paramValue.toDouble();\r
-          else if ( ClipPlane_paramName == "Z" )        aPlane.Z    = ClipPlane_paramValue.toDouble();\r
-          else\r
-          {\r
-            switch ( aPlane.Mode )\r
-            {\r
-              case OCCViewer_ClipPlane::Absolute :\r
-                if      ( ClipPlane_paramName == "Dx" ) aPlane.AbsoluteOrientation.Dx = ClipPlane_paramValue.toDouble();\r
-                else if ( ClipPlane_paramName == "Dy" ) aPlane.AbsoluteOrientation.Dy = ClipPlane_paramValue.toDouble();\r
-                else if ( ClipPlane_paramName == "Dz" ) aPlane.AbsoluteOrientation.Dz = ClipPlane_paramValue.toDouble();\r
-                else if ( ClipPlane_paramName == "IsInvert" ) aPlane.AbsoluteOrientation.IsInvert = ClipPlane_paramValue.toInt();\r
-                else if ( ClipPlane_paramName == "AbsoluteOrientation" ) aPlane.OrientationType = ClipPlane_paramValue.toInt();\r
-                break;\r
-\r
-              case OCCViewer_ClipPlane::Relative :\r
-                if      ( ClipPlane_paramName == "RelativeOrientation" ) aPlane.OrientationType = ClipPlane_paramValue.toInt();\r
-                else if ( ClipPlane_paramName == "Rotation1" )           aPlane.RelativeOrientation.Rotation1 = ClipPlane_paramValue.toDouble();\r
-                else if ( ClipPlane_paramName == "Rotation2" )           aPlane.RelativeOrientation.Rotation2 = ClipPlane_paramValue.toDouble();\r
-                break;\r
-            }\r
-          }\r
-        }\r
-        aClipPlanes.push_back(aPlane);\r
-      }\r
-      // graduated trihedron\r
-      else if ( paramName == "gtIsVisible" )       params.gtIsVisible       = paramValue.toInt();\r
-      else if ( paramName == "gtDrawNameX" )       params.gtDrawNameX       = paramValue.toInt();\r
-      else if ( paramName == "gtDrawNameY" )       params.gtDrawNameY       = paramValue.toInt();\r
-      else if ( paramName == "gtDrawNameZ" )       params.gtDrawNameZ       = paramValue.toInt();\r
-      else if ( paramName == "gtNameX" )           params.gtNameX           = paramValue;\r
-      else if ( paramName == "gtNameY" )           params.gtNameY           = paramValue;\r
-      else if ( paramName == "gtNameZ" )           params.gtNameZ           = paramValue;\r
-      else if ( paramName == "gtNameColorRX" )     params.gtNameColorRX     = paramValue.toInt();\r
-      else if ( paramName == "gtNameColorGX" )     params.gtNameColorGX     = paramValue.toInt();\r
-      else if ( paramName == "gtNameColorBX" )     params.gtNameColorBX     = paramValue.toInt();\r
-      else if ( paramName == "gtNameColorRY" )     params.gtNameColorRY     = paramValue.toInt();\r
-      else if ( paramName == "gtNameColorGY" )     params.gtNameColorGY     = paramValue.toInt();\r
-      else if ( paramName == "gtNameColorBY" )     params.gtNameColorBY     = paramValue.toInt();\r
-      else if ( paramName == "gtNameColorRZ" )     params.gtNameColorRZ     = paramValue.toInt();\r
-      else if ( paramName == "gtNameColorGZ" )     params.gtNameColorGZ     = paramValue.toInt();\r
-      else if ( paramName == "gtNameColorBZ" )     params.gtNameColorBZ     = paramValue.toInt();\r
-      else if ( paramName == "gtDrawValuesX" )     params.gtDrawValuesX     = paramValue.toInt();\r
-      else if ( paramName == "gtDrawValuesY" )     params.gtDrawValuesY     = paramValue.toInt();\r
-      else if ( paramName == "gtDrawValuesZ" )     params.gtDrawValuesZ     = paramValue.toInt();\r
-      else if ( paramName == "gtNbValuesX" )       params.gtNbValuesX       = paramValue.toInt();\r
-      else if ( paramName == "gtNbValuesY" )       params.gtNbValuesY       = paramValue.toInt();\r
-      else if ( paramName == "gtNbValuesZ" )       params.gtNbValuesZ       = paramValue.toInt();\r
-      else if ( paramName == "gtOffsetX" )         params.gtOffsetX         = paramValue.toInt();\r
-      else if ( paramName == "gtOffsetY" )         params.gtOffsetY         = paramValue.toInt();\r
-      else if ( paramName == "gtOffsetZ" )         params.gtOffsetZ         = paramValue.toInt();\r
-      else if ( paramName == "gtColorRX" )         params.gtColorRX         = paramValue.toInt();\r
-      else if ( paramName == "gtColorGX" )         params.gtColorGX         = paramValue.toInt();\r
-      else if ( paramName == "gtColorBX" )         params.gtColorBX         = paramValue.toInt();\r
-      else if ( paramName == "gtColorRY" )         params.gtColorRY         = paramValue.toInt();\r
-      else if ( paramName == "gtColorGY" )         params.gtColorGY         = paramValue.toInt();\r
-      else if ( paramName == "gtColorBY" )         params.gtColorBY         = paramValue.toInt();\r
-      else if ( paramName == "gtColorRZ" )         params.gtColorRZ         = paramValue.toInt();\r
-      else if ( paramName == "gtColorGZ" )         params.gtColorGZ         = paramValue.toInt();\r
-      else if ( paramName == "gtColorBZ" )         params.gtColorBZ         = paramValue.toInt();\r
-      else if ( paramName == "gtDrawTickmarksX" )  params.gtDrawTickmarksX  = paramValue.toInt();\r
-      else if ( paramName == "gtDrawTickmarksY" )  params.gtDrawTickmarksY  = paramValue.toInt();\r
-      else if ( paramName == "gtDrawTickmarksZ" )  params.gtDrawTickmarksZ  = paramValue.toInt();\r
-      else if ( paramName == "gtTickmarkLengthX" ) params.gtTickmarkLengthX = paramValue.toInt();\r
-      else if ( paramName == "gtTickmarkLengthY" ) params.gtTickmarkLengthY = paramValue.toInt();\r
-      else if ( paramName == "gtTickmarkLengthZ" ) params.gtTickmarkLengthZ = paramValue.toInt();\r
-      else if ( paramName == "background" )        {\r
-  QString bg = paramValue.replace( "$", "=" );\r
-  bgData = Qtx::stringToBackground( bg );\r
-      }\r
-    }\r
-  }\r
-  else // old format - "1.000e+00*0.000e+00..."\r
-  {\r
-    int idx = 0;\r
-    params.scale     = data.count() > idx ? data[idx++].toDouble() : 1.0;\r
-    params.centerX   = data.count() > idx ? data[idx++].toDouble() : 0.0;\r
-    params.centerY   = data.count() > idx ? data[idx++].toDouble() : 0.0;\r
-    params.projX     = data.count() > idx ? data[idx++].toDouble() : sqrt(1./3);\r
-    params.projY     = data.count() > idx ? data[idx++].toDouble() : -sqrt(1./3);\r
-    params.projZ     = data.count() > idx ? data[idx++].toDouble() : sqrt(1./3);\r
-    params.twist     = data.count() > idx ? data[idx++].toDouble() : 0.0;\r
-    params.atX       = data.count() > idx ? data[idx++].toDouble() : 0.0;\r
-    params.atY       = data.count() > idx ? data[idx++].toDouble() : 0.0;\r
-    params.atZ       = data.count() > idx ? data[idx++].toDouble() : 0.0;\r
-    params.eyeX      = data.count() > idx ? data[idx++].toDouble() : sqrt(250000./3);\r
-    params.eyeY      = data.count() > idx ? data[idx++].toDouble() : -sqrt(250000./3);\r
-    params.eyeZ      = data.count() > idx ? data[idx++].toDouble() : sqrt(250000./3);\r
-    params.scaleX    = data.count() > idx ? data[idx++].toDouble() : 1.0;\r
-    params.scaleY    = data.count() > idx ? data[idx++].toDouble() : 1.0;\r
-    params.scaleZ    = data.count() > idx ? data[idx++].toDouble() : 1.0;\r
-    params.isVisible = data.count() > idx ? data[idx++].toInt()    : 1;\r
-    params.size      = data.count() > idx ? data[idx++].toDouble() : 100.0;\r
-  }\r
-  performRestoring( params );  \r
-  setBackground( bgData );\r
-  myModel->setClipPlanes(aClipPlanes);\r
-}\r
-\r
-/*!\r
-  \brief Handle show event.\r
-\r
-  Emits Show() signal.\r
-\r
-  \param theEvent show event\r
-*/\r
-void OCCViewer_ViewWindow::showEvent( QShowEvent* theEvent )\r
-{\r
-  emit Show( theEvent );\r
-}\r
-\r
-/*!\r
-  \brief Handle hide event.\r
-\r
-  Emits Hide() signal.\r
-\r
-  \param theEvent hide event\r
-*/\r
-void OCCViewer_ViewWindow::hideEvent( QHideEvent* theEvent )\r
-{\r
-  emit Hide( theEvent );\r
-}\r
-\r
-\r
-/*!\r
-    Creates default sketcher. [ virtual protected ]\r
-*/\r
-OCCViewer_ViewSketcher* OCCViewer_ViewWindow::createSketcher( int type )\r
-{\r
-  if ( type == Rect )\r
-    return new OCCViewer_RectSketcher( this, type );\r
-  if ( type == Polygon )\r
-    return new OCCViewer_PolygonSketcher( this, type );\r
-  return 0;\r
-}\r
-\r
-void OCCViewer_ViewWindow::initSketchers()\r
-{\r
-  if ( mySketchers.isEmpty() )\r
-  {\r
-    mySketchers.append( createSketcher( Rect ) );\r
-    mySketchers.append( createSketcher( Polygon ) );\r
-  }\r
-}\r
-\r
-OCCViewer_ViewSketcher* OCCViewer_ViewWindow::getSketcher( const int typ )\r
-{\r
-  OCCViewer_ViewSketcher* sketcher = 0;\r
-  QList<OCCViewer_ViewSketcher*>::Iterator it;\r
-  for ( it = mySketchers.begin(); it != mySketchers.end() && !sketcher; ++it )\r
-  {\r
-    OCCViewer_ViewSketcher* sk = (*it);\r
-    if ( sk->type() == typ )\r
-      sketcher = sk;\r
-  }\r
-  return sketcher;\r
-}\r
-\r
-/*!\r
-    Handles requests for sketching in the active view. [ virtual public ]\r
-*/\r
-void OCCViewer_ViewWindow::activateSketching( int type )\r
-{\r
-  OCCViewer_ViewPort3d* vp = getViewPort();\r
-  if ( !vp )\r
-    return;\r
-\r
-  if ( !vp->isSketchingEnabled() )\r
-    return;\r
-\r
-  /* Finish current sketching */\r
-  if ( type == NoSketching )\r
-  {\r
-    if ( mypSketcher )\r
-    {\r
-      onSketchingFinished();\r
-      mypSketcher->deactivate();\r
-      mypSketcher = 0;\r
-    }\r
-  }\r
-  /* Activate new sketching */\r
-  else\r
-  {\r
-    activateSketching( NoSketching );  /* concurrency not suported */\r
-    mypSketcher = getSketcher( type );\r
-    if ( mypSketcher )\r
-    {\r
-      mypSketcher->activate();\r
-      onSketchingStarted();\r
-    }\r
-  }\r
-}\r
-\r
-/*!\r
-    Unhilights detected entities. [ virtual protected ]\r
-*/\r
-void OCCViewer_ViewWindow::onSketchingStarted()\r
-{\r
-}\r
-\r
-/*!\r
-    Selection by rectangle or polygon. [ virtual protected ]\r
-*/\r
-void OCCViewer_ViewWindow::onSketchingFinished()\r
-{\r
-  MESSAGE("OCCViewer_ViewWindow::onSketchingFinished()")\r
-  if ( mypSketcher && mypSketcher->result() == OCCViewer_ViewSketcher::Accept )\r
-  {\r
-    Handle(AIS_InteractiveContext) ic = myModel->getAISContext();\r
-    bool append = bool( mypSketcher->buttonState() && mypSketcher->isHasShift() );\r
-    switch( mypSketcher->type() )\r
-    {\r
-    case Rect:\r
-      {\r
-        QRect* aRect = (QRect*)mypSketcher->data();\r
-        if( aRect )\r
-        {\r
-          int aLeft = aRect->left();\r
-          int aRight = aRect->right();\r
-          int aTop = aRect->top();\r
-          int aBottom = aRect->bottom();\r
-//           myRect = aRect;\r
-\r
-          if( append )\r
-            ic->ShiftSelect( aLeft, aBottom, aRight, aTop, getViewPort()->getView(), Standard_False );\r
-          else\r
-            ic->Select( aLeft, aBottom, aRight, aTop, getViewPort()->getView(), Standard_False );\r
-        }\r
-      }\r
-      break;\r
-    case Polygon:\r
-      {\r
-        QPolygon* aPolygon = (QPolygon*)mypSketcher->data();\r
-        if( aPolygon )\r
-        {\r
-          int size = aPolygon->size();\r
-          TColgp_Array1OfPnt2d anArray( 1, size );\r
-\r
-          QPolygon::Iterator it = aPolygon->begin();\r
-          QPolygon::Iterator itEnd = aPolygon->end();\r
-          for( int index = 1; it != itEnd; ++it, index++ )\r
-          {\r
-            QPoint aPoint = *it;\r
-            anArray.SetValue( index, gp_Pnt2d( aPoint.x(), aPoint.y() ) );\r
-          }\r
-\r
-          if( append )\r
-            ic->ShiftSelect( anArray, getViewPort()->getView(), Standard_False );\r
-          else\r
-            ic->Select( anArray, getViewPort()->getView(), Standard_False );\r
-        }\r
-      }\r
-      break;\r
-    default:\r
-      break;\r
-    }\r
-\r
-    OCCViewer_ViewManager* aViewMgr = ( OCCViewer_ViewManager* )getViewManager();\r
-    aViewMgr->getOCCViewer()->performSelectionChanged();\r
-  }\r
-}\r
-\r
-OCCViewer_ViewPort3d* OCCViewer_ViewWindow::getViewPort()\r
-{\r
-  return myViewPort;\r
-}\r
-\r
-bool OCCViewer_ViewWindow::transformRequested() const\r
-{\r
-  return ( myOperation != NOTHING );\r
-}\r
-\r
-bool OCCViewer_ViewWindow::transformInProcess() const\r
-{\r
-  return myEventStarted;\r
-}\r
-\r
-void OCCViewer_ViewWindow::setTransformInProcess( bool bOn )\r
-{\r
-  myEventStarted = bOn;\r
-}\r
-\r
-/*!\r
-  Set enabled state of transformation (rotate, zoom, etc)\r
-*/\r
-void OCCViewer_ViewWindow::setTransformEnabled( const OperationType id, const bool on )\r
-{\r
-  if ( id != NOTHING ) myStatus.insert( id, on );\r
-}\r
-\r
-/*!\r
-  \return enabled state of transformation (rotate, zoom, etc)\r
-*/\r
-bool OCCViewer_ViewWindow::transformEnabled( const OperationType id ) const\r
-{\r
-  return myStatus.contains( id ) ? myStatus[ id ] : true;\r
-}\r
-\r
-void OCCViewer_ViewWindow::onMaximizedView()\r
-{\r
-  setMaximized(!isMaximized());\r
-}\r
-\r
-void OCCViewer_ViewWindow::returnTo3dView()\r
-{\r
-  setReturnedTo3dView( true );\r
-}\r
-\r
-void OCCViewer_ViewWindow::setReturnedTo3dView(bool isVisible3dView)\r
-{\r
-  if ( !toolMgr()->action( ReturnTo3dViewId ) ||\r
-    toolMgr()->isShown(ReturnTo3dViewId) != isVisible3dView ) return;\r
-  if ( !isVisible3dView )\r
-    toolMgr()->show( ReturnTo3dViewId );\r
-  else\r
-    toolMgr()->hide( ReturnTo3dViewId );\r
-  if ( isVisible3dView ) emit returnedTo3d( );\r
-}\r
-\r
-\r
-void OCCViewer_ViewWindow::setMaximized(bool toMaximize, bool toSendSignal)\r
-{\r
-  QAction* anAction =  toolMgr()->action( MaximizedId );\r
-  QAction* anAction2 =  toolMgr()->action( ReturnTo3dViewId );\r
-  SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();\r
-  if ( toMaximize ) {\r
-    anAction->setText( tr( "MNU_MINIMIZE_VIEW" ) );  \r
-    anAction->setToolTip( tr( "MNU_MINIMIZE_VIEW" ) );  \r
-    anAction->setIcon( aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_MINIMIZE" ) ) );\r
-    anAction->setStatusTip( tr( "DSC_MINIMIZE_VIEW" ) );\r
-    if ( anAction2 && my2dMode != No2dMode ) toolMgr()->show( ReturnTo3dViewId );\r
-    if (toSendSignal) {\r
-      emit maximized( this, true );\r
-    }\r
-  }\r
-  else {\r
-    anAction->setText( tr( "MNU_MAXIMIZE_VIEW" ) );  \r
-    anAction->setToolTip( tr( "MNU_MAXIMIZE_VIEW" ) );  \r
-    anAction->setIcon( aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_MAXIMIZE" ) ) );\r
-    anAction->setStatusTip( tr( "DSC_MAXIMIZE_VIEW" ) );\r
-    if ( anAction2 && my2dMode != No2dMode ) toolMgr()->hide( ReturnTo3dViewId );\r
-    if (toSendSignal) {\r
-      emit maximized( this, false );\r
-    }\r
-  }\r
-}\r
-\r
-bool OCCViewer_ViewWindow::isMaximized() const\r
-{\r
-  return !(toolMgr()->action( MaximizedId )->text() == tr( "MNU_MAXIMIZE_VIEW" ));\r
-}\r
-\r
-void OCCViewer_ViewWindow::setSketcherStyle( bool enable )\r
-{ \r
-  IsSketcherStyle = enable; \r
-}\r
-\r
-bool OCCViewer_ViewWindow::isSketcherStyle() const \r
-{ \r
-  return IsSketcherStyle; \r
-}\r
-\r
-\r
-void OCCViewer_ViewWindow::set2dMode(Mode2dType theType)\r
-{\r
-  my2dMode = theType;\r
-}\r
-\r
-// obsolete   \r
-QColor OCCViewer_ViewWindow::backgroundColor() const\r
-{\r
-  return myViewPort ? myViewPort->backgroundColor() : Qt::black;\r
-}\r
-   \r
-// obsolete\r
-void OCCViewer_ViewWindow::setBackgroundColor( const QColor& theColor )\r
-{\r
-  if ( myViewPort ) myViewPort->setBackgroundColor( theColor );\r
-}\r
-\r
-Qtx::BackgroundData OCCViewer_ViewWindow::background() const\r
-{\r
-  return myViewPort ? myViewPort->background() : Qtx::BackgroundData();\r
-}\r
-   \r
-void OCCViewer_ViewWindow::setBackground( const Qtx::BackgroundData& theBackground )\r
-{\r
-  if ( myViewPort ) myViewPort->setBackground( theBackground );\r
-}\r
-\r
-/*!\r
-  Clears view aspects\r
-*/\r
-void OCCViewer_ViewWindow::clearViewAspects()\r
-{\r
-  myViewAspects.clear();\r
-}\r
-\r
-/*!\r
-  \return const reference to list of view aspects\r
-*/\r
-const viewAspectList& OCCViewer_ViewWindow::getViewAspects()\r
-{\r
-  return myViewAspects;\r
-}\r
-\r
-/*!\r
-  Appends new view aspect\r
-  \param aParams - new view aspects\r
-*/\r
-void OCCViewer_ViewWindow::appendViewAspect( const viewAspect& aParams )\r
-{\r
-  myViewAspects.append( aParams );\r
-}\r
-\r
-/*!\r
-  Replaces old view aspects by new ones\r
-  \param aViewList - list of new view aspects\r
-*/\r
-void OCCViewer_ViewWindow::updateViewAspects( const viewAspectList& aViewList )\r
-{\r
-  myViewAspects = aViewList;\r
-}\r
-\r
-/*!\r
-  Get camera properties for the OCC view window.\r
-  \return shared pointer on camera properties.\r
-*/\r
-SUIT_CameraProperties OCCViewer_ViewWindow::cameraProperties()\r
-{\r
-  SUIT_CameraProperties aProps;\r
-\r
-  Handle(V3d_View) aSourceView = getViewPort()->getView();\r
-  if ( aSourceView.IsNull() )\r
-    return aProps;\r
-\r
-  if ( get2dMode() == No2dMode ) {\r
-    aProps.setDimension( SUIT_CameraProperties::Dim3D );\r
-  }\r
-  else {\r
-    aProps.setDimension( SUIT_CameraProperties::Dim2D );\r
-    aProps.setViewSide( (SUIT_CameraProperties::ViewSide)(int)get2dMode() );\r
-  }\r
-\r
-  // read common properites of the view\r
-  Standard_Real anUp[3];\r
-  Standard_Real anAt[3];\r
-  Standard_Real anEye[3];\r
-  Standard_Real aProj[3];\r
-  Standard_Real anAxialScale[3];\r
-\r
-  aSourceView->Up( anUp[0], anUp[1], anUp[2] );\r
-  aSourceView->At( anAt[0], anAt[1], anAt[2] );\r
-  aSourceView->Proj( aProj[0], aProj[1], aProj[2] );\r
-  getViewPort()->getAxialScale( anAxialScale[0], anAxialScale[1], anAxialScale[2] );\r
-\r
-  aProps.setAxialScale( anAxialScale[0], anAxialScale[1], anAxialScale[2] );\r
-  aProps.setViewUp( anUp[0], anUp[1], anUp[2] );\r
-\r
-#if OCC_VERSION_LARGE > 0x06070100\r
-  aSourceView->Eye( anEye[0], anEye[1], anEye[2] );\r
-\r
-  // store camera properties "as is": it is up to synchronized\r
-  // view classes to provide necessary property conversion.\r
-  aProps.setPosition( anEye[0], anEye[1], anEye[2] );\r
-  aProps.setFocalPoint( anAt[0], anAt[1], anAt[2] );\r
-\r
-  if ( aSourceView->Camera()->IsOrthographic() )\r
-  {\r
-    aProps.setProjection( SUIT_CameraProperties::PrjOrthogonal );\r
-    aProps.setViewAngle( 0.0 );\r
-  }\r
-  else\r
-  {\r
-    aProps.setProjection( SUIT_CameraProperties::PrjPerspective );\r
-    aProps.setViewAngle( aSourceView->Camera()->FOVy() );\r
-  }\r
-  aProps.setMappingScale( aSourceView->Camera()->Scale() );\r
-#else\r
-  Standard_Real aCameraDepth = aSourceView->Depth() + aSourceView->ZSize() * 0.5;\r
-\r
-  // generate view orientation matrix for transforming OCC projection reference point\r
-  // into a camera (eye) position.\r
-  gp_Dir aLeftDir = gp_Dir( anUp[0], anUp[1], anUp[2] ) ^ gp_Dir( aProj[0], aProj[1], aProj[2] );\r
-\r
-  gp_GTrsf aTrsf;\r
-  aTrsf.SetValue( 1, 1, aLeftDir.X() );\r
-  aTrsf.SetValue( 2, 1, aLeftDir.Y() );\r
-  aTrsf.SetValue( 3, 1, aLeftDir.Z() );\r
-\r
-  aTrsf.SetValue( 1, 2, anUp[0] );\r
-  aTrsf.SetValue( 2, 2, anUp[1] );\r
-  aTrsf.SetValue( 3, 2, anUp[2] );\r
-\r
-  aTrsf.SetValue( 1, 3, aProj[0] );\r
-  aTrsf.SetValue( 2, 3, aProj[1] );\r
-  aTrsf.SetValue( 3, 3, aProj[2] );\r
-\r
-  aTrsf.SetValue( 1, 4, anAt[0] );\r
-  aTrsf.SetValue( 2, 4, anAt[1] );\r
-  aTrsf.SetValue( 3, 4, anAt[2] );\r
-\r
-  Graphic3d_Vertex aProjRef = aSourceView->ViewMapping().ProjectionReferencePoint();\r
-\r
-  // transform to world-space coordinate system\r
-  gp_XYZ aPosition( aProjRef.X(), aProjRef.Y(), aCameraDepth );\r
-  aTrsf.Transforms( aPosition );\r
-\r
-  // compute focal point\r
-  double aFocalPoint[3];\r
-\r
-  aFocalPoint[0] = aPosition.X() - aProj[0] * aCameraDepth;\r
-  aFocalPoint[1] = aPosition.Y() - aProj[1] * aCameraDepth;\r
-  aFocalPoint[2] = aPosition.Z() - aProj[2] * aCameraDepth;\r
-\r
-  aProps.setFocalPoint( aFocalPoint[0], aFocalPoint[1], aFocalPoint[2] );\r
-  aProps.setPosition( aPosition.X(), aPosition.Y(), aPosition.Z() );\r
-\r
-  Standard_Real aViewScale[2];\r
-  aSourceView->Size( aViewScale[0], aViewScale[1] );\r
-  aProps.setMappingScale( aViewScale[1] );\r
-#endif\r
-\r
-  return aProps;\r
-}\r
-\r
-/*!\r
-  Synchronize views.\r
-  This implementation synchronizes OCC view's camera propreties.\r
-*/\r
-void OCCViewer_ViewWindow::synchronize( SUIT_ViewWindow* theView )\r
-{\r
-  bool blocked = blockSignals( true );\r
-\r
-  SUIT_CameraProperties aProps = theView->cameraProperties();\r
-  if ( !cameraProperties().isCompatible( aProps ) ) {\r
-    // other view, this one is being currently synchronized to, seems has become incompatible\r
-    // we have to break synchronization\r
-    updateSyncViews();\r
-    return;\r
-  }\r
-\r
-  Handle(V3d_View) aDestView = getViewPort()->getView();\r
-\r
-  aDestView->SetImmediateUpdate( Standard_False );\r
-\r
-  double anUpDir[3];\r
-  double aPosition[3];\r
-  double aFocalPoint[3];\r
-  double anAxialScale[3];\r
-\r
-  // get common properties\r
-  aProps.getFocalPoint( aFocalPoint[0], aFocalPoint[1], aFocalPoint[2] );\r
-  aProps.getPosition( aPosition[0], aPosition[1], aPosition[2] );\r
-  aProps.getViewUp( anUpDir[0], anUpDir[1], anUpDir[2] );\r
-  aProps.getAxialScale( anAxialScale[0], anAxialScale[1], anAxialScale[2] );\r
-\r
-#if OCC_VERSION_LARGE > 0x06070100\r
-  aDestView->SetAt( aFocalPoint[0], aFocalPoint[1], aFocalPoint[2] );\r
-  aDestView->SetEye( aPosition[0], aPosition[1], aPosition[2] );\r
-  aDestView->SetUp( anUpDir[0], anUpDir[1], anUpDir[2] );\r
-  aDestView->Camera()->SetScale( aProps.getMappingScale() );\r
-#else\r
-  gp_Dir aProjDir( aPosition[0] - aFocalPoint[0],\r
-                   aPosition[1] - aFocalPoint[1],\r
-                   aPosition[2] - aFocalPoint[2] );\r
-\r
-  // get custom view translation\r
-  Standard_Real aTranslation[3];\r
-  aDestView->At( aTranslation[0], aTranslation[1], aTranslation[2] );\r
-\r
-  gp_Dir aLeftDir = gp_Dir( anUpDir[0], anUpDir[1], anUpDir[2] )\r
-                  ^ gp_Dir( aProjDir.X(), aProjDir.Y(), aProjDir.Z() );\r
-\r
-  gp_GTrsf aTrsf;\r
-  aTrsf.SetValue( 1, 1, aLeftDir.X() );\r
-  aTrsf.SetValue( 2, 1, aLeftDir.Y() );\r
-  aTrsf.SetValue( 3, 1, aLeftDir.Z() );\r
-\r
-  aTrsf.SetValue( 1, 2, anUpDir[0] );\r
-  aTrsf.SetValue( 2, 2, anUpDir[1] );\r
-  aTrsf.SetValue( 3, 2, anUpDir[2] );\r
-\r
-  aTrsf.SetValue( 1, 3, aProjDir.X() );\r
-  aTrsf.SetValue( 2, 3, aProjDir.Y() );\r
-  aTrsf.SetValue( 3, 3, aProjDir.Z() );\r
-\r
-  aTrsf.SetValue( 1, 4, aTranslation[0] );\r
-  aTrsf.SetValue( 2, 4, aTranslation[1] );\r
-  aTrsf.SetValue( 3, 4, aTranslation[2] );\r
-  aTrsf.Invert();\r
-\r
-  // transform to view-space coordinate system\r
-  gp_XYZ aProjRef( aPosition[0], aPosition[1], aPosition[2] );\r
-  aTrsf.Transforms( aProjRef );\r
-\r
-  // set view camera properties using low-level approach. this is done\r
-  // in order to avoid interference with static variables in v3d view used\r
-  // when rotation is in process in another view.\r
-  Visual3d_ViewMapping aMapping = aDestView->View()->ViewMapping();\r
-  Visual3d_ViewOrientation anOrientation = aDestView->View()->ViewOrientation();\r
-\r
-  Graphic3d_Vector aMappingProj( aProjDir.X(), aProjDir.Y(), aProjDir.Z() );\r
-  Graphic3d_Vector aMappingUp( anUpDir[0], anUpDir[1], anUpDir[2] );\r
-\r
-  aMappingProj.Normalize();\r
-  aMappingUp.Normalize();\r
-\r
-  anOrientation.SetViewReferencePlane( aMappingProj );\r
-  anOrientation.SetViewReferenceUp( aMappingUp );\r
-\r
-  aDestView->SetViewMapping( aMapping );\r
-  aDestView->SetViewOrientation( anOrientation );\r
-\r
-  // set panning\r
-  aDestView->SetCenter( aProjRef.X(), aProjRef.Y() );\r
-\r
-  // set mapping scale\r
-  double aMapScaling = aProps.getMappingScale();\r
-  Standard_Real aWidth, aHeight;\r
-  aDestView->Size( aWidth, aHeight );\r
-  aDestView->SetSize ( aWidth > aHeight ? aMapScaling * (aWidth / aHeight) : aMapScaling );\r
-#endif\r
-\r
-  getViewPort()->setAxialScale( anAxialScale[0], anAxialScale[1], anAxialScale[2] );\r
-\r
-  aDestView->ZFitAll();\r
-  aDestView->SetImmediateUpdate( Standard_True );\r
-  aDestView->Redraw();\r
-\r
-  blockSignals( blocked );\r
-}\r
-\r
-/*!\r
-  \brief Indicates whether preselection is enabled\r
-  \return true if preselection is enabled\r
-*/\r
-bool OCCViewer_ViewWindow::isPreselectionEnabled() const\r
-{\r
-  return myPreselectionEnabled;\r
-}\r
-\r
-/*!\r
-  \brief Enables/disables preselection\r
-  \param theIsToEnable if true - preselection will be enabled\r
-*/\r
-void OCCViewer_ViewWindow::enablePreselection( bool theIsToEnable )\r
-{\r
-  onSwitchPreselection( theIsToEnable );\r
-}\r
-\r
-/*!\r
-  \brief Indicates whether selection is enabled\r
-  \return true if selection is enabled\r
-*/\r
-bool OCCViewer_ViewWindow::isSelectionEnabled() const\r
-{\r
-  return mySelectionEnabled;\r
-}\r
-\r
-/*!\r
-  \brief Enables/disables selection\r
-  \param theIsToEnable if true - selection will be enabled\r
-*/\r
-void OCCViewer_ViewWindow::enableSelection( bool theIsToEnable )\r
-{\r
-  onSwitchSelection( theIsToEnable );\r
-}\r
-\r
-\r
-/*!\r
-  \brief called if clipping operation is activated / deactivated.\r
-\r
-  Enables/disables clipping plane displaying.\r
-\r
-  \parma on action state\r
-*/\r
-void OCCViewer_ViewWindow::onClipping (bool theIsOn)\r
-{\r
-  if(!myModel) return;\r
-  OCCViewer_ClippingDlg* aClippingDlg = myModel->getClippingDlg();\r
-  \r
-  if (theIsOn) {\r
-    if (!aClippingDlg) {\r
-      aClippingDlg = new OCCViewer_ClippingDlg (this, myModel);\r
-      myModel->setClippingDlg(aClippingDlg);\r
-    }\r
-    if (!aClippingDlg->isVisible())\r
-      aClippingDlg->show();\r
-  } else {\r
-    if ( aClippingDlg ) {\r
-      aClippingDlg->close();\r
-      myModel->setClippingDlg(0);\r
-    }\r
-  }\r
-\r
-  SUIT_ViewManager* mgr = getViewManager();\r
-  if( mgr ) {\r
-    QVector<SUIT_ViewWindow*> aViews = mgr->getViews();\r
-    for(int i = 0, iEnd = aViews.size(); i < iEnd; i++) {\r
-      if(SUIT_ViewWindow* aViewWindow = aViews.at(i)) {\r
-       QtxActionToolMgr* mgr = aViewWindow->toolMgr();\r
-       if(!mgr) continue;\r
-       QAction* a = toolMgr()->action( ClippingId );\r
-       if(!a) continue;\r
-       if(theIsOn != a->isChecked()){\r
-         disconnect (a, SIGNAL (toggled (bool)), aViewWindow, SLOT (onClipping (bool)));\r
-         a->setChecked(theIsOn);\r
-         connect (a, SIGNAL (toggled (bool)), aViewWindow, SLOT (onClipping (bool)));\r
-       }\r
-      }\r
-    }\r
-  }\r
-}\r
+      }
+    }
+  }
+
+  if ( aPointsNb > 0 )
+  {
+    theX /= aPointsNb;
+    theY /= aPointsNb;
+    theZ /= aPointsNb;
+  }
+  return true;
+}
+
+/*!
+  \brief Set the gravity center as a rotation point.
+*/
+void OCCViewer_ViewWindow::activateSetRotationGravity()
+{
+  if ( myRotationPointSelection )
+  {
+    Handle(AIS_InteractiveContext) ic = myModel->getAISContext();
+    ic->CloseAllContexts();
+    myOperation = NOTHING;
+    myViewPort->setCursor( myCursor );
+    myCursorIsHand = false;
+    myRotationPointSelection = false;
+  }
+
+  myPrevPointType = myCurrPointType;
+  myCurrPointType = GRAVITY;
+
+  Standard_Real Xcenter, Ycenter, Zcenter;
+  if ( computeGravityCenter( Xcenter, Ycenter, Zcenter ) )
+    mySetRotationPointDlg->setCoords( Xcenter, Ycenter, Zcenter );
+}
+
+/*!
+  \brief Update gravity center in the "Set Rotation Point" dialog box.
+  \sa OCCViewer_SetRotationPointDlg class
+*/
+void OCCViewer_ViewWindow::updateGravityCoords()
+{
+  if ( mySetRotationPointDlg && mySetRotationPointDlg->isVisible() && myCurrPointType == GRAVITY )
+  {
+    Standard_Real Xcenter, Ycenter, Zcenter;
+    if ( computeGravityCenter( Xcenter, Ycenter, Zcenter ) )
+      mySetRotationPointDlg->setCoords( Xcenter, Ycenter, Zcenter );
+  }
+}
+
+/*!
+  \brief Set the point selected by the user as a rotation point.
+  \param theX X coordinate of the rotation point
+  \param theY Y coordinate of the rotation point
+  \param theZ Z coordinate of the rotation point
+*/
+void OCCViewer_ViewWindow::activateSetRotationSelected( double theX, double theY, double theZ )
+{
+  if ( myRotationPointSelection )
+  {
+    Handle(AIS_InteractiveContext) ic = myModel->getAISContext();
+    ic->CloseAllContexts();
+    myOperation = NOTHING;
+    myViewPort->setCursor( myCursor );
+    myCursorIsHand = false;
+    myRotationPointSelection = false;
+  }
+
+  myPrevPointType = myCurrPointType;
+  myCurrPointType = SELECTED;
+  mySelectedPoint.SetCoord(theX,theY,theZ);
+}
+
+/*!
+  \brief Start the shape selection process.
+*/
+void OCCViewer_ViewWindow::activateStartPointSelection( TopAbs_ShapeEnum theShapeType )
+{
+  myPrevPointType = myCurrPointType;
+  myCurrPointType = SELECTED;
+
+  // activate selection ------>
+  Handle(AIS_InteractiveContext) ic = myModel->getAISContext();
+
+  ic->OpenLocalContext();
+
+  AIS_ListOfInteractive aList;
+  ic->DisplayedObjects( aList );
+  for ( AIS_ListIteratorOfListOfInteractive it( aList ); it.More(); it.Next() )
+  {
+    Handle(AIS_InteractiveObject) anObj = it.Value();
+    if ( !anObj.IsNull() && anObj->HasPresentation() &&
+         anObj->IsKind( STANDARD_TYPE(AIS_Shape) ) )
+    {
+      ic->Load(anObj,-1);
+      ic->Activate(anObj,AIS_Shape::SelectionMode(theShapeType));
+     }
+  }
+  // activate selection <------
+
+  if ( !myCursorIsHand )
+  {
+    QCursor handCursor (Qt::PointingHandCursor);
+    myCursorIsHand = true;
+    myCursor = cursor();
+    myViewPort->setCursor( handCursor );
+  }
+  myRotationPointSelection = true;
+}
+
+/*!
+  \brief Start global panning operation
+
+  Sets the corresponding cursor for the widget.
+*/
+void OCCViewer_ViewWindow::activateGlobalPanning()
+{
+  Handle(V3d_View) aView3d = myViewPort->getView();
+  if ( !aView3d.IsNull() ) {
+    QPixmap globalPanPixmap (imageCrossCursor);
+    QCursor glPanCursor (globalPanPixmap);
+    myCurScale = aView3d->Scale();
+    aView3d->FitAll(0.01, false);
+    myCursor = cursor();                // save old cursor
+    myViewPort->fitAll(); // fits view before selecting a new scene center
+    if( setTransformRequested( PANGLOBAL ) )
+      myViewPort->setCursor( glPanCursor );
+  }
+}
+
+/*!
+  \brief Starts fit operation.
+
+  Sets the corresponding cursor for the widget.
+*/
+void OCCViewer_ViewWindow::activateWindowFit()
+{
+  if ( !transformRequested() && !myCursorIsHand )
+    myCursor = cursor();                /* save old cursor */
+
+  if ( myOperation != WINDOWFIT ) {
+    QCursor handCursor (Qt::PointingHandCursor);
+    if( setTransformRequested ( WINDOWFIT ) )
+    {
+      myViewPort->setCursor ( handCursor );
+      myCursorIsHand = true;
+    }
+  }
+}
+
+/*!
+  \brief Start delayed viewer operation.
+*/
+bool OCCViewer_ViewWindow::setTransformRequested( OperationType op )
+{
+  bool ok = transformEnabled( op );
+  myOperation = ok ? op : NOTHING;
+  myViewPort->setMouseTracking( myOperation == NOTHING );  
+  return ok;
+}
+
+/*!
+  \brief Handle mouse move event.
+  \param theEvent mouse event
+*/
+void OCCViewer_ViewWindow::vpMouseMoveEvent( QMouseEvent* theEvent )
+{
+  if ( myIsKeyFree && interactionStyle() == SUIT_ViewModel::KEY_FREE ) {
+    myIsKeyFree = false;
+    switch ( getButtonState( theEvent, interactionStyle() ) ) {
+    case ZOOMVIEW:
+      myViewPort->startZoomAtPoint( myStartX, myStartY );
+      activateZoom();
+      break;
+    case PANVIEW:
+      activatePanning();
+      break;
+    case ROTATE:
+      activateRotation();
+      myViewPort->startRotation(myStartX, myStartY, myCurrPointType, mySelectedPoint);
+      break;
+    default:
+      break;
+    }
+  }
+
+  myCurrX = theEvent->x();
+  myCurrY = theEvent->y();
+  switch (myOperation) {
+  case ROTATE:
+    myViewPort->rotate(myCurrX, myCurrY, myCurrPointType, mySelectedPoint);
+    break;
+
+  case ZOOMVIEW:
+    myViewPort->zoom(myStartX, myStartY, myCurrX, myCurrY);
+    myStartX = myCurrX;
+    myStartY = myCurrY;
+    break;
+
+  case PANVIEW:
+    myViewPort->pan(myCurrX - myStartX, myStartY - myCurrY);
+    myStartX = myCurrX;
+    myStartY = myCurrY;
+    break;
+
+/*    case WINDOWFIT:
+    myDrawRect = true;
+    repaint();
+    break;
+*/
+  case PANGLOBAL:
+    break;
+
+  default:
+    if ( myRotationPointSelection || isSketcherStyle() )
+    {
+      emit mouseMoving( this, theEvent );
+    }
+    else
+    {
+      int aState = theEvent->modifiers();
+      int aButton = theEvent->buttons();
+      int anInteractionStyle = interactionStyle();
+      if ( ( anInteractionStyle == SUIT_ViewModel::STANDARD &&
+           aButton == Qt::LeftButton && ( aState == Qt::NoModifier || Qt::ShiftModifier ) ) ||
+         ( anInteractionStyle == SUIT_ViewModel::KEY_FREE &&
+         aButton == Qt::LeftButton && ( aState == Qt::ControlModifier || aState == ( Qt::ControlModifier|Qt::ShiftModifier ) ) ) ) {
+        myDrawRect = myEnableDrawMode;
+        if ( myDrawRect ) {
+          drawRect();
+          if ( !myCursorIsHand )        {   // we are going to sketch a rectangle
+            QCursor handCursor (Qt::PointingHandCursor);
+            myCursorIsHand = true;
+            myCursor = cursor();
+            myViewPort->setCursor( handCursor );
+          }
+        }
+        emit mouseMoving( this, theEvent );
+      }
+      else if ( ( anInteractionStyle == SUIT_ViewModel::STANDARD &&
+                aButton == Qt::RightButton && ( aState == Qt::NoModifier || Qt::ShiftModifier ) ) ||
+                ( anInteractionStyle == SUIT_ViewModel::KEY_FREE &&
+                aButton == Qt::RightButton && ( aState == Qt::ControlModifier || aState == ( Qt::ControlModifier|Qt::ShiftModifier ) ) ) ) {
+        OCCViewer_ViewSketcher* sketcher = 0;
+        QList<OCCViewer_ViewSketcher*>::Iterator it;
+        for ( it = mySketchers.begin(); it != mySketchers.end() && !sketcher; ++it )
+        {
+          OCCViewer_ViewSketcher* sk = (*it);
+          if( sk->isDefault() && sk->sketchButton() == aButton )
+            sketcher = sk;
+        }
+        if ( sketcher && myCurSketch == -1 )
+        {
+          activateSketching( sketcher->type() );
+          if ( mypSketcher )
+          {
+            myCurSketch = mypSketcher->sketchButton();
+
+            if ( l_mbPressEvent )
+            {
+              QApplication::sendEvent( getViewPort(), l_mbPressEvent );
+              delete l_mbPressEvent;
+              l_mbPressEvent = 0;
+            }
+            QApplication::sendEvent( getViewPort(), theEvent );
+          }
+        }
+      }
+      else
+        emit mouseMoving( this, theEvent );
+    }
+  }
+}
+
+/*!
+  \brief Handle mouse release event.
+  \param theEvent mouse event
+*/
+void OCCViewer_ViewWindow::vpMouseReleaseEvent(QMouseEvent* theEvent)
+{
+  switch ( myOperation ) {
+  case NOTHING:
+    {
+      int prevState = myCurSketch;
+      if(theEvent->button() == Qt::RightButton)
+      {
+        QList<OCCViewer_ViewSketcher*>::Iterator it;
+        for ( it = mySketchers.begin(); it != mySketchers.end() && myCurSketch != -1; ++it )
+        {
+          OCCViewer_ViewSketcher* sk = (*it);
+          if( ( sk->sketchButton() & theEvent->button() ) && sk->sketchButton() == myCurSketch )
+            myCurSketch = -1;
+        }
+      }
+
+      emit mouseReleased(this, theEvent);
+      if(theEvent->button() == Qt::RightButton && prevState == -1)
+      {
+        QContextMenuEvent aEvent( QContextMenuEvent::Mouse,
+                                  theEvent->pos(), theEvent->globalPos() );
+        emit contextMenuRequested( &aEvent );
+      }
+    }
+    break;
+  case ROTATE:
+    myViewPort->endRotation();
+    resetState();
+    break;
+
+  case PANVIEW:
+  case ZOOMVIEW:
+    myViewPort->getView()->ZFitAll();
+    resetState();
+    break;
+
+  case PANGLOBAL:
+    if ( theEvent->button() == Qt::LeftButton ) {
+      myViewPort->setCenter( theEvent->x(), theEvent->y() );
+      myViewPort->getView()->SetScale(myCurScale);
+      resetState();
+    }
+    break;
+
+  case WINDOWFIT:
+    if ( theEvent->button() == Qt::LeftButton ) {
+      myCurrX = theEvent->x();
+      myCurrY = theEvent->y();
+      drawRect();
+      QRect rect = SUIT_Tools::makeRect(myStartX, myStartY, myCurrX, myCurrY);
+      if ( !rect.isEmpty() ) myViewPort->fitRect(rect);
+      endDrawRect();
+      resetState();
+    }
+    break;
+  }
+
+  // NOTE: viewer 3D detects a rectangle of selection using this event
+  // so we must emit it BEFORE resetting the selection rectangle
+
+  if ( theEvent->button() == Qt::LeftButton && myDrawRect ) {
+    drawRect();
+    endDrawRect();
+    resetState();
+    myViewPort->update();
+  }
+
+  if ( l_mbPressEvent )
+  {
+    delete l_mbPressEvent;
+    l_mbPressEvent = 0;
+  }
+}
+
+/*!
+  \brief Reset the viewport to its initial state
+  ( no transformations in process etc. )
+*/
+void OCCViewer_ViewWindow::resetState()
+{
+  myDrawRect = false;
+
+  if ( myRotationPointSelection )
+  {
+    QCursor handCursor (Qt::PointingHandCursor);
+    myViewPort->setCursor( handCursor );
+  }
+  else
+  {
+    if ( transformRequested() || myCursorIsHand )
+      myViewPort->setCursor( myCursor );
+    myCursorIsHand = false;
+  }
+
+  if ( transformRequested() )
+    emit vpTransformationFinished (myOperation);
+
+  setTransformInProcess( false );
+  setTransformRequested( NOTHING );
+}
+
+
+/*!
+  \brief Draw rubber band rectangle.
+*/
+void OCCViewer_ViewWindow::drawRect()
+{
+  if ( !myRectBand ) {
+    myRectBand = new QtxRectRubberBand( myViewPort );
+    //QPalette palette;
+    //palette.setColor(myRectBand->foregroundRole(), Qt::white);
+    //myRectBand->setPalette(palette);
+  }
+  //myRectBand->hide();
+  
+  myRectBand->setUpdatesEnabled ( false );
+  QRect aRect = SUIT_Tools::makeRect(myStartX, myStartY, myCurrX, myCurrY);
+  myRectBand->initGeometry( aRect );
+
+  if ( !myRectBand->isVisible() )
+    myRectBand->show();
+
+  myRectBand->setUpdatesEnabled ( true );
+  //myRectBand->repaint();
+
+  //myRectBand->setVisible( aRect.isValid() );
+  //if ( myRectBand->isVisible() )
+  //  myRectBand->repaint();
+  //else
+  //  myRectBand->show();
+  //myRectBand->repaint();
+}
+
+/*!
+  \brief Clear rubber band rectangle on the end on the dragging operation.
+*/
+void OCCViewer_ViewWindow::endDrawRect()
+{
+  //delete myRectBand;
+  //myRectBand = 0;
+  if ( myRectBand )
+    {
+      myRectBand->clearGeometry();
+      myRectBand->hide();
+    }
+}
+
+/*!
+  \brief Create actions.
+*/
+void OCCViewer_ViewWindow::createActions()
+{
+  if( !toolMgr()->isEmpty() )
+    return;
+  
+  SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
+
+  QtxAction* aAction;
+
+  // Dump view
+  aAction = new QtxAction(tr("MNU_DUMP_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_DUMP" ) ),
+                           tr( "MNU_DUMP_VIEW" ), 0, this);
+  aAction->setStatusTip(tr("DSC_DUMP_VIEW"));
+  connect(aAction, SIGNAL(triggered()), this, SLOT(onDumpView()));
+  toolMgr()->registerAction( aAction, DumpId );
+
+  // FitAll
+  aAction = new QtxAction(tr("MNU_FITALL"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_FITALL" ) ),
+                           tr( "MNU_FITALL" ), 0, this);
+  aAction->setStatusTip(tr("DSC_FITALL"));
+  connect(aAction, SIGNAL(triggered()), this, SLOT(onFitAll()));
+  toolMgr()->registerAction( aAction, FitAllId );
+
+  // FitRect
+  aAction = new QtxAction(tr("MNU_FITRECT"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_FITAREA" ) ),
+                           tr( "MNU_FITRECT" ), 0, this);
+  aAction->setStatusTip(tr("DSC_FITRECT"));
+  connect(aAction, SIGNAL(triggered()), this, SLOT(activateWindowFit()));
+  toolMgr()->registerAction( aAction, FitRectId );
+  
+  // Zoom
+  aAction = new QtxAction(tr("MNU_ZOOM_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_ZOOM" ) ),
+                           tr( "MNU_ZOOM_VIEW" ), 0, this);
+  aAction->setStatusTip(tr("DSC_ZOOM_VIEW"));
+  connect(aAction, SIGNAL(triggered()), this, SLOT(activateZoom()));
+  toolMgr()->registerAction( aAction, ZoomId );
+
+  // Panning
+  aAction = new QtxAction(tr("MNU_PAN_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_PAN" ) ),
+                           tr( "MNU_PAN_VIEW" ), 0, this);
+  aAction->setStatusTip(tr("DSC_PAN_VIEW"));
+  connect(aAction, SIGNAL(triggered()), this, SLOT(activatePanning()));
+  toolMgr()->registerAction( aAction, PanId );
+
+  // Global Panning
+  aAction = new QtxAction(tr("MNU_GLOBALPAN_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_GLOBALPAN" ) ),
+                           tr( "MNU_GLOBALPAN_VIEW" ), 0, this);
+  aAction->setStatusTip(tr("DSC_GLOBALPAN_VIEW"));
+  connect(aAction, SIGNAL(triggered()), this, SLOT(activateGlobalPanning()));
+  toolMgr()->registerAction( aAction, GlobalPanId );
+
+  // Rotation Point
+  mySetRotationPointAction = new QtxAction(tr("MNU_CHANGINGROTATIONPOINT_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_ROTATION_POINT" ) ),
+                           tr( "MNU_CHANGINGROTATIONPOINT_VIEW" ), 0, this);
+  mySetRotationPointAction->setStatusTip(tr("DSC_CHANGINGROTATIONPOINT_VIEW"));
+  mySetRotationPointAction->setCheckable( true );
+  connect(mySetRotationPointAction, SIGNAL(toggled( bool )), this, SLOT(onSetRotationPoint( bool )));
+  toolMgr()->registerAction( mySetRotationPointAction, ChangeRotationPointId );
+
+  // Rotation
+  aAction = new QtxAction(tr("MNU_ROTATE_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_ROTATE" ) ),
+                           tr( "MNU_ROTATE_VIEW" ), 0, this);
+  aAction->setStatusTip(tr("DSC_ROTATE_VIEW"));
+  connect(aAction, SIGNAL(triggered()), this, SLOT(activateRotation()));
+  toolMgr()->registerAction( aAction, RotationId );
+
+  // Projections
+  aAction = new QtxAction(tr("MNU_FRONT_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_FRONT" ) ),
+                           tr( "MNU_FRONT_VIEW" ), 0, this, false, "Viewers:Front view");
+  aAction->setStatusTip(tr("DSC_FRONT_VIEW"));
+  connect(aAction, SIGNAL(triggered()), this, SLOT(onFrontView()));
+  this->addAction(aAction);
+  toolMgr()->registerAction( aAction, FrontId );
+
+  aAction = new QtxAction(tr("MNU_BACK_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_BACK" ) ),
+                           tr( "MNU_BACK_VIEW" ), 0, this, false, "Viewers:Back view");
+  aAction->setStatusTip(tr("DSC_BACK_VIEW"));
+  connect(aAction, SIGNAL(triggered()), this, SLOT(onBackView()));
+  this->addAction(aAction);
+  toolMgr()->registerAction( aAction, BackId );
+
+  aAction = new QtxAction(tr("MNU_TOP_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_TOP" ) ),
+                           tr( "MNU_TOP_VIEW" ), 0, this, false, "Viewers:Top view");
+  aAction->setStatusTip(tr("DSC_TOP_VIEW"));
+  connect(aAction, SIGNAL(triggered()), this, SLOT(onTopView()));
+  this->addAction(aAction);
+  toolMgr()->registerAction( aAction, TopId );
+
+  aAction = new QtxAction(tr("MNU_BOTTOM_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_BOTTOM" ) ),
+                           tr( "MNU_BOTTOM_VIEW" ), 0, this, false, "Viewers:Bottom view");
+  aAction->setStatusTip(tr("DSC_BOTTOM_VIEW"));
+  connect(aAction, SIGNAL(triggered()), this, SLOT(onBottomView()));
+  this->addAction(aAction);
+  toolMgr()->registerAction( aAction, BottomId );
+  
+  aAction = new QtxAction(tr("MNU_LEFT_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_LEFT" ) ),
+                           tr( "MNU_LEFT_VIEW" ), 0, this, false, "Viewers:Left view");
+  aAction->setStatusTip(tr("DSC_LEFT_VIEW"));
+  connect(aAction, SIGNAL(triggered()), this, SLOT(onLeftView()));
+  this->addAction(aAction);
+  toolMgr()->registerAction( aAction, LeftId );
+
+  aAction = new QtxAction(tr("MNU_RIGHT_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_RIGHT" ) ),
+                           tr( "MNU_RIGHT_VIEW" ), 0, this, false, "Viewers:Right view");
+  aAction->setStatusTip(tr("DSC_RIGHT_VIEW"));
+  connect(aAction, SIGNAL(triggered()), this, SLOT(onRightView()));
+  this->addAction(aAction);
+  toolMgr()->registerAction( aAction, RightId );
+
+  // rotate anticlockwise
+  aAction = new QtxAction(tr("MNU_ANTICLOCKWISE_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_ANTICLOCKWISE" ) ),
+                           tr( "MNU_ANTICLOCKWISE_VIEW" ), 0, this, false, "Viewers:Rotate anticlockwise");
+  aAction->setStatusTip(tr("DSC_ANTICLOCKWISE_VIEW"));
+  connect(aAction, SIGNAL(triggered()), this, SLOT(onAntiClockWiseView()));
+  this->addAction(aAction);
+  toolMgr()->registerAction( aAction, AntiClockWiseId );
+
+  // rotate clockwise
+  aAction = new QtxAction(tr("MNU_CLOCKWISE_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_CLOCKWISE" ) ),
+                           tr( "MNU_CLOCKWISE_VIEW" ), 0, this, false, "Viewers:Rotate clockwise");
+  aAction->setStatusTip(tr("DSC_CLOCKWISE_VIEW"));
+  connect(aAction, SIGNAL(triggered()), this, SLOT(onClockWiseView()));
+  this->addAction(aAction);
+  toolMgr()->registerAction( aAction, ClockWiseId );
+
+  // Reset
+  aAction = new QtxAction(tr("MNU_RESET_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_RESET" ) ),
+                           tr( "MNU_RESET_VIEW" ), 0, this, false, "Viewers:Reset view");
+  aAction->setStatusTip(tr("DSC_RESET_VIEW"));
+  connect(aAction, SIGNAL(triggered()), this, SLOT(onResetView()));
+  this->addAction(aAction);
+  toolMgr()->registerAction( aAction, ResetId );
+
+  // Clone
+  aAction = new QtxAction(tr("MNU_CLONE_VIEW"),
+                          aResMgr->loadPixmap("OCCViewer", tr("ICON_OCCVIEWER_CLONE_VIEW")),
+                          tr("MNU_CLONE_VIEW"), 0, this);
+  aAction->setStatusTip(tr("DSC_CLONE_VIEW"));
+  connect(aAction, SIGNAL(triggered()), this, SLOT(onCloneView()));
+  toolMgr()->registerAction( aAction, CloneId );
+
+  aAction = new QtxAction (tr ("MNU_CLIPPING"), aResMgr->loadPixmap ("OCCViewer", tr ("ICON_OCCVIEWER_CLIPPING")),
+                                      tr ("MNU_CLIPPING"), 0, this);
+  aAction->setStatusTip (tr ("DSC_CLIPPING"));
+  aAction->setCheckable (true);
+  connect (aAction, SIGNAL (toggled (bool)), this, SLOT (onClipping (bool)));
+  toolMgr()->registerAction (aAction, ClippingId);
+
+  aAction = new QtxAction(tr("MNU_SHOOT_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_SHOOT_VIEW" ) ),
+                           tr( "MNU_SHOOT_VIEW" ), 0, this);
+  aAction->setStatusTip(tr("DSC_SHOOT_VIEW"));
+  connect(aAction, SIGNAL(triggered()), this, SLOT(onMemorizeView()));
+  toolMgr()->registerAction( aAction, MemId );
+
+  aAction = new QtxAction(tr("MNU_PRESETS_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_PRESETS_VIEW" ) ),
+                           tr( "MNU_PRESETS_VIEW" ), 0, this);
+  aAction->setStatusTip(tr("DSC_PRESETS_VIEW"));
+  connect(aAction, SIGNAL(triggered()), this, SLOT(onRestoreView()));
+  toolMgr()->registerAction( aAction, RestoreId );
+
+  if (myModel->trihedronActivated()) {
+    aAction = new QtxAction(tr("MNU_SHOW_TRIHEDRE"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_TRIHEDRON" ) ),
+                             tr( "MNU_SHOW_TRIHEDRE" ), 0, this);
+    aAction->setCheckable( true );
+    aAction->setChecked( true );
+    aAction->setStatusTip(tr("DSC_SHOW_TRIHEDRE"));
+    connect(aAction, SIGNAL(toggled(bool)), this, SLOT(onTrihedronShow(bool)));
+    toolMgr()->registerAction( aAction, TrihedronShowId );
+  }
+
+  // Scale
+  aAction = new QtxAction(tr("MNU_SCALING"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_SCALING" ) ),
+                           tr( "MNU_SCALING" ), 0, this);
+  aAction->setStatusTip(tr("DSC_SCALING"));
+  connect(aAction, SIGNAL(triggered()), this, SLOT(onAxialScale()));
+  toolMgr()->registerAction( aAction, AxialScaleId );
+
+  // Enable/disable preselection
+  aAction = new QtxAction(tr("MNU_ENABLE_PRESELECTION"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_PRESELECTION" ) ),
+                          tr( "MNU_ENABLE_PRESELECTION" ), 0, this);
+  aAction->setStatusTip(tr("DSC_ENABLE_PRESELECTION"));
+  aAction->setCheckable(true);
+  connect(aAction, SIGNAL(toggled(bool)), this, SLOT(onSwitchPreselection(bool)));
+  toolMgr()->registerAction( aAction, SwitchPreselectionId );
+
+  // Enable/disable selection
+  aAction = new QtxAction(tr("MNU_ENABLE_SELECTION"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_SELECTION" ) ),
+                          tr( "MNU_ENABLE_SELECTION" ), 0, this);
+  aAction->setStatusTip(tr("DSC_ENABLE_SELECTION"));
+  aAction->setCheckable(true);
+  connect(aAction, SIGNAL(toggled(bool)), this, SLOT(onSwitchSelection(bool)));
+  toolMgr()->registerAction( aAction, SwitchSelectionId );
+
+  // Graduated axes 
+  aAction = new QtxAction(tr("MNU_GRADUATED_AXES"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_GRADUATED_AXES" ) ),
+                           tr( "MNU_GRADUATED_AXES" ), 0, this);
+  aAction->setStatusTip(tr("DSC_GRADUATED_AXES"));
+  connect(aAction, SIGNAL(triggered()), this, SLOT(onGraduatedAxes()));
+  toolMgr()->registerAction( aAction, GraduatedAxesId );
+
+  // Active only ambient light or not
+  aAction = new QtxAction(tr("MNU_AMBIENT"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_AMBIENT" ) ),
+                           tr( "MNU_AMBIENT" ), 0, this);
+  aAction->setStatusTip(tr("DSC_AMBIENT"));
+  connect(aAction, SIGNAL(triggered()), this, SLOT(onAmbientToogle()));
+  toolMgr()->registerAction( aAction, AmbientId );
+
+  // Switch between interaction styles
+  aAction = new QtxAction(tr("MNU_STYLE_SWITCH"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_STYLE_SWITCH" ) ),
+                          tr( "MNU_STYLE_SWITCH" ), 0, this);
+  aAction->setStatusTip(tr("DSC_STYLE_SWITCH"));
+  aAction->setCheckable(true);
+  connect(aAction, SIGNAL(toggled(bool)), this, SLOT(onSwitchInteractionStyle(bool)));
+  toolMgr()->registerAction( aAction, SwitchInteractionStyleId );
+
+  // Switch between zooming styles
+  aAction = new QtxAction(tr("MNU_ZOOMING_STYLE_SWITCH"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_ZOOMING_STYLE_SWITCH" ) ),
+                          tr( "MNU_ZOOMING_STYLE_SWITCH" ), 0, this);
+  aAction->setStatusTip(tr("DSC_ZOOMING_STYLE_SWITCH"));
+  aAction->setCheckable(true);
+  connect(aAction, SIGNAL(toggled(bool)), this, SLOT(onSwitchZoomingStyle(bool)));
+  toolMgr()->registerAction( aAction, SwitchZoomingStyleId );
+
+  // Maximized view
+  aAction = new QtxAction(tr("MNU_MINIMIZE_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_MINIMIZE" ) ),
+                          tr( "MNU_MINIMIZE_VIEW" ), 0, this );
+  aAction->setStatusTip(tr("DSC_MINIMIZE_VIEW"));
+  connect(aAction, SIGNAL(triggered()), this, SLOT(onMaximizedView()));
+  toolMgr()->registerAction( aAction, MaximizedId );
+
+  // Return to 3d view
+  if (my2dMode!=No2dMode){
+    aAction = new QtxAction(tr("MNU_RETURN_3D_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_RETURN_3D_VIEW" ) ),
+                            tr( "MNU_RETURN_3D_VIEW" ), 0, this );
+    aAction->setStatusTip(tr("DSC_RETURN_3D_VIEW"));
+    connect(aAction, SIGNAL(triggered()), this, SLOT(returnTo3dView()));
+    toolMgr()->registerAction( aAction, ReturnTo3dViewId );
+  }
+
+  // Synchronize View 
+  toolMgr()->registerAction( synchronizeAction(), SynchronizeId );
+}
+
+/*!
+  \brief Create toolbar.
+*/
+void OCCViewer_ViewWindow::createToolBar()
+{
+  QString aToolbarName;
+  switch (my2dMode) {
+  case XYPlane:
+    aToolbarName = tr( "LBL_XYTOOLBAR_LABEL" );
+    break;
+  case XZPlane:
+    aToolbarName = tr( "LBL_XZTOOLBAR_LABEL" );
+    break;
+  case YZPlane:
+    aToolbarName = tr( "LBL_YZTOOLBAR_LABEL" );
+    break;
+  default:
+    aToolbarName = tr( "LBL_3DTOOLBAR_LABEL" );
+  }
+  
+  int tid = toolMgr()->createToolBar( aToolbarName, false );
+  if ( my2dMode != No2dMode ){
+    toolMgr()->append( ReturnTo3dViewId, tid );
+    toolMgr()->append( toolMgr()->separator(), tid );
+  }
+  toolMgr()->append( DumpId, tid );
+  toolMgr()->append( SwitchInteractionStyleId, tid );
+#if OCC_VERSION_LARGE > 0x0603000A // available only with OCC-6.3-sp11 and higher version
+  toolMgr()->append( SwitchZoomingStyleId, tid );
+#endif
+  toolMgr()->append( SwitchPreselectionId, tid );
+  toolMgr()->append( SwitchSelectionId, tid );
+  if( myModel->trihedronActivated() )
+    toolMgr()->append( TrihedronShowId, tid );
+
+  QtxMultiAction* aScaleAction = new QtxMultiAction( this );
+  aScaleAction->insertAction( toolMgr()->action( FitAllId ) );
+  aScaleAction->insertAction( toolMgr()->action( FitRectId ) );
+  aScaleAction->insertAction( toolMgr()->action( ZoomId ) );
+  toolMgr()->append( aScaleAction, tid );
+
+  QtxMultiAction* aPanningAction = new QtxMultiAction( this );
+  aPanningAction->insertAction( toolMgr()->action( PanId ) );
+  aPanningAction->insertAction( toolMgr()->action( GlobalPanId ) );
+  toolMgr()->append( aPanningAction, tid );
+
+  if (my2dMode == No2dMode) {
+    toolMgr()->append( ChangeRotationPointId, tid );
+    toolMgr()->append( RotationId, tid );
+
+    QtxMultiAction* aViewsAction = new QtxMultiAction( this );
+    aViewsAction->insertAction( toolMgr()->action( FrontId ) );
+    aViewsAction->insertAction( toolMgr()->action( BackId ) );
+    aViewsAction->insertAction( toolMgr()->action( TopId ) );
+    aViewsAction->insertAction( toolMgr()->action( BottomId ) );
+    aViewsAction->insertAction( toolMgr()->action( LeftId ) );
+    aViewsAction->insertAction( toolMgr()->action( RightId ) );
+    toolMgr()->append( aViewsAction, tid );
+
+    toolMgr()->append( AntiClockWiseId, tid );
+    toolMgr()->append( ClockWiseId, tid );
+
+    toolMgr()->append( ResetId, tid );
+  }
+
+  QtxMultiAction* aMemAction = new QtxMultiAction( this );
+  aMemAction->insertAction( toolMgr()->action( MemId ) );
+  aMemAction->insertAction( toolMgr()->action( RestoreId ) );
+  toolMgr()->append( aMemAction, tid );
+
+  toolMgr()->append( toolMgr()->separator(), tid );
+  toolMgr()->append( CloneId, tid );
+  
+  toolMgr()->append( toolMgr()->separator(), tid );
+  toolMgr()->append( ClippingId, tid );
+  toolMgr()->append( AxialScaleId, tid );
+#if OCC_VERSION_LARGE > 0x06030009 // available only with OCC-6.3-sp10 and higher version
+  toolMgr()->append( GraduatedAxesId, tid );
+#endif
+  toolMgr()->append( AmbientId, tid );
+
+  toolMgr()->append( MaximizedId, tid );
+  toolMgr()->append( SynchronizeId, tid );
+}
+
+/*!
+  \brief Perform 'fit all' operation.
+*/
+void OCCViewer_ViewWindow::onViewFitAll()
+{
+  myViewPort->fitAll();
+}
+
+/*!
+  \brief Perform "front view" transformation.
+*/
+void OCCViewer_ViewWindow::onFrontView()
+{
+  emit vpTransformationStarted ( FRONTVIEW );
+  Handle(V3d_View) aView3d = myViewPort->getView();
+  if ( !aView3d.IsNull() ) aView3d->SetProj (V3d_Xpos);
+  onViewFitAll();
+  emit vpTransformationFinished ( FRONTVIEW );
+}
+
+/*!
+  \brief Perform "back view" transformation.
+*/
+void OCCViewer_ViewWindow::onBackView()
+{
+  emit vpTransformationStarted ( BACKVIEW );
+  Handle(V3d_View) aView3d = myViewPort->getView();
+  if ( !aView3d.IsNull() ) aView3d->SetProj (V3d_Xneg);
+  onViewFitAll();
+  emit vpTransformationFinished ( BACKVIEW );
+}
+
+/*!
+  \brief Perform "top view" transformation.
+*/
+void OCCViewer_ViewWindow::onTopView()
+{
+  emit vpTransformationStarted ( TOPVIEW );
+  Handle(V3d_View) aView3d = myViewPort->getView();
+  if ( !aView3d.IsNull() ) aView3d->SetProj (V3d_Zpos);
+  onViewFitAll();
+  emit vpTransformationFinished ( TOPVIEW );
+}
+
+/*!
+  \brief Perform "bottom view" transformation.
+*/
+void OCCViewer_ViewWindow::onBottomView()
+{
+  emit vpTransformationStarted ( BOTTOMVIEW );
+  Handle(V3d_View) aView3d = myViewPort->getView();
+  if ( !aView3d.IsNull() ) aView3d->SetProj (V3d_Zneg);
+  onViewFitAll();
+  emit vpTransformationFinished ( BOTTOMVIEW );
+}
+
+/*!
+  \brief Perform "left view" transformation.
+*/
+void OCCViewer_ViewWindow::onLeftView()
+{
+  emit vpTransformationStarted ( LEFTVIEW );
+  Handle(V3d_View) aView3d = myViewPort->getView();
+  if ( !aView3d.IsNull() ) aView3d->SetProj (V3d_Yneg);
+  onViewFitAll();
+  emit vpTransformationFinished ( LEFTVIEW );
+}
+
+/*!
+  \brief Perform "right view" transformation.
+*/
+void OCCViewer_ViewWindow::onRightView()
+{
+  emit vpTransformationStarted ( RIGHTVIEW );
+  Handle(V3d_View) aView3d = myViewPort->getView();
+  if ( !aView3d.IsNull() ) aView3d->SetProj (V3d_Ypos);
+  onViewFitAll();
+  emit vpTransformationFinished ( RIGHTVIEW );
+}
+
+/*!
+  \brief Rotate view 90 degrees clockwise
+*/
+void OCCViewer_ViewWindow::onClockWiseView()
+{
+  emit vpTransformationStarted ( CLOCKWISEVIEW );
+  myViewPort->rotateXY( 90. );
+  emit vpTransformationFinished ( CLOCKWISEVIEW );
+}
+
+/*!
+  \brief Rotate view 90 degrees conterclockwise
+*/
+void OCCViewer_ViewWindow::onAntiClockWiseView()
+{
+  emit vpTransformationStarted ( ANTICLOCKWISEVIEW );
+  myViewPort->rotateXY( -90. );
+  emit vpTransformationFinished ( ANTICLOCKWISEVIEW );
+}
+
+/*!
+  \brief Perform "reset view" transformation.
+
+  Sets default orientation of the viewport camera.
+*/
+void OCCViewer_ViewWindow::onResetView()
+{
+  emit vpTransformationStarted( RESETVIEW );
+  bool upd = myViewPort->getView()->SetImmediateUpdate( false );
+  myViewPort->getView()->Reset( false );
+  myViewPort->fitAll( false, true, false );
+  myViewPort->getView()->SetImmediateUpdate( upd );
+  myViewPort->getView()->Update();
+  emit vpTransformationFinished( RESETVIEW );
+}
+
+/*!
+  \brief Perform "fit all" transformation.
+*/
+void OCCViewer_ViewWindow::onFitAll()
+{
+  emit vpTransformationStarted( FITALLVIEW );
+  myViewPort->fitAll();
+  emit vpTransformationFinished( FITALLVIEW );
+}
+
+/*!
+  \brief Called if 'change rotation point' operation is activated.
+  \param on action state
+*/
+void OCCViewer_ViewWindow::onSetRotationPoint( bool on )
+{
+  if (on)
+  {
+    if (!mySetRotationPointDlg)
+    {
+      mySetRotationPointDlg = new OCCViewer_SetRotationPointDlg (this);
+      mySetRotationPointDlg->SetAction(mySetRotationPointAction);
+    }
+
+    if (!mySetRotationPointDlg->isVisible())
+    {
+      //if (mySetRotationPointDlg->IsFirstShown())
+      if (myCurrPointType == GRAVITY)
+      {
+        Standard_Real Xcenter, Ycenter, Zcenter;
+        if (computeGravityCenter(Xcenter, Ycenter, Zcenter))
+          mySetRotationPointDlg->setCoords(Xcenter, Ycenter, Zcenter);
+      }
+      mySetRotationPointDlg->show();
+    }
+  }
+  else
+  {
+    if (mySetRotationPointDlg->isVisible())
+      mySetRotationPointDlg->hide();
+  }
+}
+
+/*!
+   \brief Create one more window with same content.
+*/
+void OCCViewer_ViewWindow::onCloneView()
+{
+  SUIT_ViewWindow* vw = myManager->createViewWindow();
+  //vw->show();
+  emit viewCloned( vw );
+}
+
+/*!
+  Creates one more window with same content
+*/
+void OCCViewer_ViewWindow::onAxialScale()
+{
+  if ( !myScalingDlg )
+    myScalingDlg = new OCCViewer_AxialScaleDlg( this );
+  
+  if ( !myScalingDlg->isVisible() )
+  {
+    myScalingDlg->Update();
+    myScalingDlg->show();
+  }
+}
+
+/*!
+  Shows Graduated Axes dialog
+*/
+void OCCViewer_ViewWindow::onGraduatedAxes()
+{
+  myCubeAxesDlg->Update();
+  myCubeAxesDlg->show();
+}
+
+void OCCViewer_ViewWindow::onAmbientToogle()
+{
+  Handle(V3d_Viewer) viewer = myViewPort->getViewer();
+  viewer->InitDefinedLights();
+  while(viewer->MoreDefinedLights())
+    {
+      Handle(V3d_Light) light = viewer->DefinedLight();
+      if(light->Type() != V3d_AMBIENT)
+        {
+          Handle(V3d_View) aView3d = myViewPort->getView();
+          if( aView3d->IsActiveLight(light) ) viewer->SetLightOff(light);
+          else viewer->SetLightOn(light);
+        }
+      viewer->NextDefinedLights();
+    }
+  viewer->Update();
+}
+
+/*!
+  \brief Store view parameters.
+*/
+void OCCViewer_ViewWindow::onMemorizeView()
+{
+  appendViewAspect( getViewParams() );
+}
+
+/*!
+  \brief Restore view parameters.
+*/
+void OCCViewer_ViewWindow::onRestoreView()
+{
+  OCCViewer_CreateRestoreViewDlg* aDlg = new OCCViewer_CreateRestoreViewDlg( centralWidget(), this );
+  connect( aDlg, SIGNAL( dlgOk() ), this, SLOT( setRestoreFlag() ) );
+  aDlg->exec();
+  updateViewAspects( aDlg->parameters() );
+  if( myRestoreFlag && aDlg->parameters().count() )
+    performRestoring( aDlg->currentItem() );
+}
+
+/*!
+  \brief Restore view parameters.
+  \param anItem view parameters
+*/
+void OCCViewer_ViewWindow::performRestoring( const viewAspect& anItem, bool baseParamsOnly )
+{
+  Handle(V3d_View) aView3d = myViewPort->getView();
+
+  Standard_Boolean prev = aView3d->SetImmediateUpdate( Standard_False );
+  aView3d->SetScale( anItem.scale );
+  aView3d->SetTwist( anItem.twist );
+  aView3d->SetAt( anItem.atX, anItem.atY, anItem.atZ );
+  aView3d->SetImmediateUpdate( prev );
+  aView3d->SetEye( anItem.eyeX, anItem.eyeY, anItem.eyeZ );
+  aView3d->SetProj( anItem.projX, anItem.projY, anItem.projZ );
+  aView3d->SetAxialScale( anItem.scaleX, anItem.scaleY, anItem.scaleZ );
+
+#if OCC_VERSION_LARGE > 0x06070100
+  if ( anItem.centerX != 0.0 || anItem.centerY != 0.0 )
+  {
+    double anUpX = 0.0, anUpY = 0.0, anUpZ = 0.0;
+
+    // "eye" and "at" require conversion to represent center panning
+    // up direction is only available after setting angle of twist and
+    // other view parameters
+    aView3d->Up( anUpX, anUpY, anUpZ );
+
+    gp_Dir aProj( -anItem.projX, -anItem.projY, -anItem.projZ );
+    gp_Dir anUp( anUpX, anUpY, anUpZ );
+    gp_Pnt anAt( anItem.atX, anItem.atY, anItem.atZ );
+    gp_Pnt anEye( anItem.eyeX, anItem.eyeY, anItem.eyeZ );
+    gp_Dir aSide = aProj ^ anUp;
+
+    anAt.Translate( gp_Vec( aSide ) * anItem.centerX );
+    anAt.Translate( gp_Vec( anUp  ) * anItem.centerY );
+
+    aView3d->SetAt( anAt.X(), anAt.Y(), anAt.Z() );
+    aView3d->SetProj( anItem.projX, anItem.projY, anItem.projZ );
+  }
+#else
+  aView3d->SetCenter( anItem.centerX, anItem.centerY );
+#endif
+
+  if ( !baseParamsOnly ) {
+
+    myModel->setTrihedronShown( anItem.isVisible );
+    myModel->setTrihedronSize( anItem.size );
+        
+#if OCC_VERSION_LARGE > 0x06030009 // available only with OCC-6.3-sp10 and higher version
+    // graduated trihedron
+    bool anIsVisible = anItem.gtIsVisible;
+    OCCViewer_AxisWidget::AxisData anAxisData[3];
+    anAxisData[0].DrawName = anItem.gtDrawNameX;
+    anAxisData[1].DrawName = anItem.gtDrawNameZ;
+    anAxisData[2].DrawName = anItem.gtDrawNameZ;
+    anAxisData[0].Name = anItem.gtNameX;
+    anAxisData[1].Name = anItem.gtNameZ;
+    anAxisData[2].Name = anItem.gtNameZ;
+    anAxisData[0].NameColor = QColor( anItem.gtNameColorRX,
+              anItem.gtNameColorGX,
+              anItem.gtNameColorBX );
+    anAxisData[1].NameColor = QColor( anItem.gtNameColorRY,
+              anItem.gtNameColorGY,
+              anItem.gtNameColorBY );
+    anAxisData[2].NameColor = QColor( anItem.gtNameColorRZ,
+              anItem.gtNameColorGZ,
+              anItem.gtNameColorBZ );
+    anAxisData[0].DrawValues = anItem.gtDrawValuesX;
+    anAxisData[1].DrawValues = anItem.gtDrawValuesY;
+    anAxisData[2].DrawValues = anItem.gtDrawValuesZ;
+    anAxisData[0].NbValues = anItem.gtNbValuesX;
+    anAxisData[1].NbValues = anItem.gtNbValuesY;
+    anAxisData[2].NbValues = anItem.gtNbValuesZ;
+    anAxisData[0].Offset = anItem.gtOffsetX;
+    anAxisData[1].Offset = anItem.gtOffsetY;
+    anAxisData[2].Offset = anItem.gtOffsetZ;
+    anAxisData[0].Color = QColor( anItem.gtColorRX,
+          anItem.gtColorGX,
+          anItem.gtColorBX );
+    anAxisData[1].Color = QColor( anItem.gtColorRY,
+          anItem.gtColorGY,
+          anItem.gtColorBY );
+    anAxisData[2].Color = QColor( anItem.gtColorRZ,
+          anItem.gtColorGZ,
+          anItem.gtColorBZ );
+    anAxisData[0].DrawTickmarks = anItem.gtDrawTickmarksX;
+    anAxisData[1].DrawTickmarks = anItem.gtDrawTickmarksY;
+    anAxisData[2].DrawTickmarks = anItem.gtDrawTickmarksZ;
+    anAxisData[0].TickmarkLength = anItem.gtTickmarkLengthX;
+    anAxisData[1].TickmarkLength = anItem.gtTickmarkLengthY;
+    anAxisData[2].TickmarkLength = anItem.gtTickmarkLengthZ;
+
+    myCubeAxesDlg->SetData( anIsVisible, anAxisData );
+    myCubeAxesDlg->ApplyData( aView3d );
+#endif
+
+  } // if ( !baseParamsOnly )
+
+  myRestoreFlag = 0;
+}
+
+/*!
+  \brief Set restore flag.
+*/
+void OCCViewer_ViewWindow::setRestoreFlag()
+{
+  myRestoreFlag = 1;
+}
+
+/*!
+  \brief Called when action "show/hide trihedron" is activated.
+*/
+void OCCViewer_ViewWindow::onTrihedronShow(bool show)
+{
+  myModel->setTrihedronShown(show);
+}
+
+/*!
+  \brief Toggles preselection (highlighting) on/off
+*/
+void OCCViewer_ViewWindow::onSwitchPreselection( bool on )
+{
+  myPreselectionEnabled = on;
+  myModel->setSelectionOptions( isPreselectionEnabled(), myModel->isSelectionEnabled() );
+
+  // unhighlight all highlighted objects
+  /*if ( !on ) {
+    myModel->unHighlightAll( true, false );
+  }*/
+
+  // update action state if method is called outside
+  QtxAction* a = dynamic_cast<QtxAction*>( toolMgr()->action( SwitchPreselectionId ) );
+  if ( a && a->isChecked() != on ) {
+    a->setChecked( on );
+  }
+}
+
+/*!
+  \brief Toggles selection on/off
+*/
+void OCCViewer_ViewWindow::onSwitchSelection( bool on )
+{
+  mySelectionEnabled = on;
+  myModel->setSelectionOptions( myModel->isPreselectionEnabled(), isSelectionEnabled() );
+  
+  // update action state if method is called outside
+
+  // preselection
+  QtxAction* a = dynamic_cast<QtxAction*>( toolMgr()->action( SwitchPreselectionId ) );
+  if ( a ) {
+    a->setEnabled( on );
+  }
+
+  // selection
+  a = dynamic_cast<QtxAction*>( toolMgr()->action( SwitchSelectionId ) );
+  if ( a && a->isChecked() != on ) {
+    a->setChecked( on );
+  }
+}
+
+/*!
+  \brief Switches "keyboard free" interaction style on/off
+*/
+void OCCViewer_ViewWindow::onSwitchInteractionStyle( bool on )
+{
+  myInteractionStyle = on ? (int)SUIT_ViewModel::KEY_FREE : (int)SUIT_ViewModel::STANDARD;
+
+  // update action state if method is called outside
+  QtxAction* a = dynamic_cast<QtxAction*>( toolMgr()->action( SwitchInteractionStyleId ) );
+  if ( a->isChecked() != on )
+    a->setChecked( on );
+}
+
+/*!
+  \brief Toogles advanced zooming style (relatively to the cursor position) on/off
+*/
+void OCCViewer_ViewWindow::onSwitchZoomingStyle( bool on )
+{
+  myViewPort->setAdvancedZoomingEnabled( on );
+
+  // update action state if method is called outside
+  QtxAction* a = dynamic_cast<QtxAction*>( toolMgr()->action( SwitchZoomingStyleId ) );
+  if ( a->isChecked() != on )
+    a->setChecked( on );
+}
+
+/*!
+  \brief Get current interaction style
+  \return interaction style
+*/
+int OCCViewer_ViewWindow::interactionStyle() const
+{
+  return myInteractionStyle;
+}
+
+/*!
+  \brief Set current interaction style
+  \param theStyle interaction style
+*/
+void OCCViewer_ViewWindow::setInteractionStyle( const int theStyle )
+{
+  onSwitchInteractionStyle( theStyle == (int)SUIT_ViewModel::KEY_FREE );
+}
+
+/*!
+  \brief Get current zooming style
+  \return zooming style
+*/
+int OCCViewer_ViewWindow::zoomingStyle() const
+{
+  return myViewPort->isAdvancedZoomingEnabled() ? 1 : 0;
+}
+
+/*!
+  \brief Set current zooming style
+  \param theStyle zooming style
+*/
+void OCCViewer_ViewWindow::setZoomingStyle( const int theStyle )
+{
+  onSwitchZoomingStyle( theStyle == 1 );
+}
+
+/*!
+  \brief Dump view window contents to the pixmap.
+  \return pixmap containing all scene rendered in the window
+*/
+QImage OCCViewer_ViewWindow::dumpView()
+{
+  Handle(V3d_View) view = myViewPort->getView();
+  if ( view.IsNull() )
+    return QImage();
+  
+  int aWidth = myViewPort->width();
+  int aHeight = myViewPort->height();
+  QApplication::syncX();
+  view->Redraw(); // In order to reactivate GL context
+  //view->Update();
+
+  OpenGLUtils_FrameBuffer aFrameBuffer;
+  if( aFrameBuffer.init( aWidth, aHeight ) )
+  {
+    QImage anImage( aWidth, aHeight, QImage::Format_RGB32 );
+   
+    glPushAttrib( GL_VIEWPORT_BIT );
+    glViewport( 0, 0, aWidth, aHeight );
+    aFrameBuffer.bind();
+
+    // draw scene
+    view->Redraw();
+
+    aFrameBuffer.unbind();
+    glPopAttrib();
+
+    aFrameBuffer.bind();
+    glReadPixels( 0, 0, aWidth, aHeight, GL_RGBA, GL_UNSIGNED_BYTE, anImage.bits() );
+    aFrameBuffer.unbind();
+
+    anImage = anImage.rgbSwapped();
+    anImage = anImage.mirrored();
+    return anImage;
+  }
+  // if frame buffers are unsupported, use old functionality
+  //view->Redraw();
+
+  unsigned char* data = new unsigned char[ aWidth*aHeight*4 ];
+
+  QPoint p = myViewPort->mapFromParent(myViewPort->geometry().topLeft());
+
+  glReadPixels( p.x(), p.y(), aWidth, aHeight, GL_RGBA, GL_UNSIGNED_BYTE,
+                data);
+
+  QImage anImage( data, aWidth, aHeight, QImage::Format_ARGB32 );
+  anImage = anImage.mirrored();
+  anImage = anImage.rgbSwapped();
+  return anImage;
+}
+
+bool OCCViewer_ViewWindow::dumpViewToFormat( const QImage& img, 
+                                             const QString& fileName, 
+                                             const QString& format )
+{
+  if ( format != "PS" && format != "EPS")
+    return SUIT_ViewWindow::dumpViewToFormat( img, fileName, format );
+
+  Handle(Visual3d_View) a3dView = myViewPort->getView()->View();
+
+  if (format == "PS")
+    a3dView->Export(strdup(qPrintable(fileName)), Graphic3d_EF_PostScript);
+  else if (format == "EPS")
+    a3dView->Export(strdup(qPrintable(fileName)), Graphic3d_EF_EnhPostScript);
+
+  return true;
+}
+
+
+QString OCCViewer_ViewWindow::filter() const
+{
+  return tr( "OCC_IMAGE_FILES" );
+}
+
+
+/*!
+  \brief Set parameters of the cutting plane
+  \param on if \c true, cutting plane is enabled
+  \param x X position of plane point
+  \param y Y position of plane point
+  \param z Z position of plane point
+  \param dx X coordinate of plane normal
+  \param dy Y coordinate of plane normal
+  \param dz Z coordinate of plane normal
+*/
+void OCCViewer_ViewWindow::setCuttingPlane( bool on, const double x,  const double y,  const double z,
+                                            const double dx, const double dy, const double dz )
+{
+  Handle(V3d_View) view = myViewPort->getView();
+  if ( view.IsNull() )
+    return;
+
+  if ( on ) {
+    Handle(V3d_Viewer) viewer = myViewPort->getViewer();
+
+    // try to use already existing plane or create a new one
+    Handle(V3d_Plane) clipPlane;
+
+    // calculate new a,b,c,d values for the plane
+    gp_Pln pln (gp_Pnt(x, y, z), gp_Dir(dx, dy, dz));
+    double a, b, c, d;
+    pln.Coefficients(a, b, c, d);
+    
+    Graphic3d_SequenceOfHClipPlane aPlanes = view->GetClipPlanes();
+    Handle(Graphic3d_ClipPlane) aClipPlane;
+    if(aPlanes.Size() > 0 ) {
+      Graphic3d_SequenceOfHClipPlane::Iterator anIter (aPlanes);
+      aClipPlane = anIter.Value();
+      aClipPlane->SetEquation(pln);
+      aClipPlane->SetOn(Standard_True);
+    } else {
+      aClipPlane = new Graphic3d_ClipPlane(pln);
+      view->AddClipPlane(aClipPlane);
+      aClipPlane->SetOn(Standard_True);
+    }
+  }
+  else {
+    Graphic3d_SequenceOfHClipPlane aPlanes = view->GetClipPlanes();
+    Graphic3d_SequenceOfHClipPlane::Iterator anIter (aPlanes);
+    for( ;anIter.More();anIter.Next() ){
+      Handle(Graphic3d_ClipPlane) aClipPlane = anIter.Value();
+      aClipPlane->SetOn(Standard_False);
+    }
+  }
+
+  view->Update();
+  view->Redraw();
+}
+
+void OCCViewer_ViewWindow::setCuttingPlane( bool on, const gp_Pln pln )
+{
+  gp_Dir aDir = pln.Axis().Direction();
+  gp_Pnt aPnt = pln.Location();
+  setCuttingPlane(on, aPnt.X(), aPnt.Y(), aPnt.Z(), aDir.X(), aDir.Y(), aDir.Z());
+}
+
+
+/*!
+  \brief Check if any cutting plane is enabled
+  \return \c true if at least one cutting plane is enabled
+*/
+bool OCCViewer_ViewWindow::isCuttingPlane()
+{
+  Handle(V3d_View) view = myViewPort->getView();
+  bool res = false;
+  Graphic3d_SequenceOfHClipPlane aPlanes = view->GetClipPlanes();
+  Graphic3d_SequenceOfHClipPlane::Iterator anIter (aPlanes);
+  for( ;anIter.More();anIter.Next() ) {
+    Handle(Graphic3d_ClipPlane) aClipPlane = anIter.Value();
+    if(aClipPlane->IsOn()) {
+      res = true;
+      break;
+    }
+  }
+  return res;
+}
+
+/*!
+  \brief Get the visual parameters of the view window.
+  \return visual parameters of view window
+*/
+viewAspect OCCViewer_ViewWindow::getViewParams() const
+{
+  double projX, projY, projZ, twist;
+  double atX, atY, atZ, eyeX, eyeY, eyeZ;
+  double aScaleX, aScaleY, aScaleZ;
+
+  Handle(V3d_View) aView3d = myViewPort->getView();
+
+  aView3d->Proj( projX, projY, projZ );
+  aView3d->At( atX, atY, atZ );
+  aView3d->Eye( eyeX, eyeY, eyeZ );
+  twist = aView3d->Twist();
+
+  aView3d->AxialScale(aScaleX,aScaleY,aScaleZ);
+
+  bool isShown = myModel->isTrihedronVisible();
+  double size = myModel->trihedronSize();
+
+  QString aName = QTime::currentTime().toString() + QString::fromLatin1( " h:m:s" );
+
+  viewAspect params;
+  params.scale    = aView3d->Scale();
+  params.projX    = projX;
+  params.projY    = projY;
+  params.projZ    = projZ;
+  params.twist    = twist;
+  params.atX      = atX;
+  params.atY      = atY;
+  params.atZ      = atZ;
+  params.eyeX     = eyeX;
+  params.eyeY     = eyeY;
+  params.eyeZ     = eyeZ;
+  params.scaleX   = aScaleX;
+  params.scaleY   = aScaleY;
+  params.scaleZ   = aScaleZ;
+  params.name     = aName;
+  params.isVisible= isShown;
+  params.size     = size;
+
+#if OCC_VERSION_LARGE <= 0x06070100 // the property is deprecated after OCCT 6.7.1
+  aView3d->Center( params.centerX, params.centerY );
+#endif
+
+#if OCC_VERSION_LARGE > 0x06030009 // available only with OCC-6.3-sp10 and higher version
+  // graduated trihedron
+  bool anIsVisible = false;
+  OCCViewer_AxisWidget::AxisData anAxisData[3];
+  myCubeAxesDlg->GetData( anIsVisible, anAxisData );
+
+  params.gtIsVisible = anIsVisible;
+  params.gtDrawNameX = anAxisData[0].DrawName;
+  params.gtDrawNameY = anAxisData[1].DrawName;
+  params.gtDrawNameZ = anAxisData[2].DrawName;
+  params.gtNameX = anAxisData[0].Name;
+  params.gtNameY = anAxisData[1].Name;
+  params.gtNameZ = anAxisData[2].Name;
+  params.gtNameColorRX = anAxisData[0].NameColor.red();
+  params.gtNameColorGX = anAxisData[0].NameColor.green();
+  params.gtNameColorBX = anAxisData[0].NameColor.blue();
+  params.gtNameColorRY = anAxisData[1].NameColor.red();
+  params.gtNameColorGY = anAxisData[1].NameColor.green();
+  params.gtNameColorBY = anAxisData[1].NameColor.blue();
+  params.gtNameColorRZ = anAxisData[2].NameColor.red();
+  params.gtNameColorGZ = anAxisData[2].NameColor.green();
+  params.gtNameColorBZ = anAxisData[2].NameColor.blue();
+  params.gtDrawValuesX = anAxisData[0].DrawValues;
+  params.gtDrawValuesY = anAxisData[1].DrawValues;
+  params.gtDrawValuesZ = anAxisData[2].DrawValues;
+  params.gtNbValuesX = anAxisData[0].NbValues;
+  params.gtNbValuesY = anAxisData[1].NbValues;
+  params.gtNbValuesZ = anAxisData[2].NbValues;
+  params.gtOffsetX = anAxisData[0].Offset;
+  params.gtOffsetY = anAxisData[1].Offset;
+  params.gtOffsetZ = anAxisData[2].Offset;
+  params.gtColorRX = anAxisData[0].Color.red();
+  params.gtColorGX = anAxisData[0].Color.green();
+  params.gtColorBX = anAxisData[0].Color.blue();
+  params.gtColorRY = anAxisData[1].Color.red();
+  params.gtColorGY = anAxisData[1].Color.green();
+  params.gtColorBY = anAxisData[1].Color.blue();
+  params.gtColorRZ = anAxisData[2].Color.red();
+  params.gtColorGZ = anAxisData[2].Color.green();
+  params.gtColorBZ = anAxisData[2].Color.blue();
+  params.gtDrawTickmarksX = anAxisData[0].DrawTickmarks;
+  params.gtDrawTickmarksY = anAxisData[1].DrawTickmarks;
+  params.gtDrawTickmarksZ = anAxisData[2].DrawTickmarks;
+  params.gtTickmarkLengthX = anAxisData[0].TickmarkLength;
+  params.gtTickmarkLengthY = anAxisData[1].TickmarkLength;
+  params.gtTickmarkLengthZ = anAxisData[2].TickmarkLength;
+#endif
+
+  return params;
+}
+
+/*!
+  \brief Get visual parameters of this view window.
+  \return visual parameters of view window
+*/
+QString OCCViewer_ViewWindow::getVisualParameters()
+{
+  viewAspect params = getViewParams();
+
+  QStringList data;
+
+  data << QString( "scale=%1" )    .arg( params.scale,   0, 'e', 12 );
+#if OCC_VERSION_LARGE <= 0x06070100 // the property is deprecated after OCCT 6.7.1
+  data << QString( "centerX=%1" )  .arg( params.centerX, 0, 'e', 12 );
+  data << QString( "centerY=%1" )  .arg( params.centerY, 0, 'e', 12 );
+#endif
+  data << QString( "projX=%1" )    .arg( params.projX,   0, 'e', 12 );
+  data << QString( "projY=%1" )    .arg( params.projY,   0, 'e', 12 );
+  data << QString( "projZ=%1" )    .arg( params.projZ,   0, 'e', 12 );
+  data << QString( "twist=%1" )    .arg( params.twist,   0, 'e', 12 );
+  data << QString( "atX=%1" )      .arg( params.atX,     0, 'e', 12 );
+  data << QString( "atY=%1" )      .arg( params.atY,     0, 'e', 12 );
+  data << QString( "atZ=%1" )      .arg( params.atZ,     0, 'e', 12 );
+  data << QString( "eyeX=%1" )     .arg( params.eyeX,    0, 'e', 12 );
+  data << QString( "eyeY=%1" )     .arg( params.eyeY,    0, 'e', 12 );
+  data << QString( "eyeZ=%1" )     .arg( params.eyeZ,    0, 'e', 12 );
+  data << QString( "scaleX=%1" )   .arg( params.scaleX,  0, 'e', 12 );
+  data << QString( "scaleY=%1" )   .arg( params.scaleY,  0, 'e', 12 );
+  data << QString( "scaleZ=%1" )   .arg( params.scaleZ,  0, 'e', 12 );
+  data << QString( "isVisible=%1" ).arg( params.isVisible );
+  data << QString( "size=%1" )     .arg( params.size,    0, 'f',  2 );
+
+  ClipPlanesList aPlanes =  myModel->getClipPlanes();
+  for ( int i=0; i < aPlanes.size(); i++ )
+  {
+    OCCViewer_ClipPlane& aPlane = aPlanes[i];
+    QString ClippingPlane = QString( "ClippingPlane%1=").arg( i+1 );
+    ClippingPlane +=  QString( "Mode~%1;").arg( (int)aPlane.Mode );
+    ClippingPlane +=  QString( "IsActive~%1;").arg( aPlane.IsOn );
+    switch ( aPlane.Mode )
+    {
+      case OCCViewer_ClipPlane::Absolute :
+      {
+        ClippingPlane += QString( "AbsoluteOrientation~%1;" ).arg( aPlane.OrientationType );
+
+        if ( aPlane.OrientationType == OCCViewer_ClipPlane::AbsoluteCustom )
+        {
+          ClippingPlane += QString( "Dx~%1;" ).arg( aPlane.AbsoluteOrientation.Dx );
+          ClippingPlane += QString( "Dy~%1;" ).arg( aPlane.AbsoluteOrientation.Dy );
+          ClippingPlane += QString( "Dz~%1;" ).arg( aPlane.AbsoluteOrientation.Dz );
+        }
+        else
+        {
+          ClippingPlane += QString( "IsInvert~%1;" ).arg( aPlane.AbsoluteOrientation.IsInvert );
+        }
+      }
+      break;
+
+      case OCCViewer_ClipPlane::Relative :
+      {
+        ClippingPlane += QString( "RelativeOrientation~%1;" ).arg( aPlane.OrientationType );
+        ClippingPlane += QString( "Rotation1~%1;" ).arg( aPlane.RelativeOrientation.Rotation1 );
+        ClippingPlane += QString( "Rotation2~%1" ).arg( aPlane.RelativeOrientation.Rotation2 );
+      }
+      break;
+    }
+
+    ClippingPlane +=  QString( "X~%1;" ).arg( aPlane.X );
+    ClippingPlane +=  QString( "Y~%1;" ).arg( aPlane.Y );
+    ClippingPlane +=  QString( "Z~%1;" ).arg( aPlane.Z );
+    data << ClippingPlane;
+  }
+
+
+#if OCC_VERSION_LARGE > 0x06030009 // available only with OCC-6.3-sp10 or newer version
+  // graduated trihedron
+  data << QString( "gtIsVisible=%1" )      .arg( params.gtIsVisible );
+  data << QString( "gtDrawNameX=%1" )      .arg( params.gtDrawNameX );
+  data << QString( "gtDrawNameY=%1" )      .arg( params.gtDrawNameY );
+  data << QString( "gtDrawNameZ=%1" )      .arg( params.gtDrawNameZ );
+  data << QString( "gtNameX=%1" )          .arg( params.gtNameX );
+  data << QString( "gtNameY=%1" )          .arg( params.gtNameY );
+  data << QString( "gtNameZ=%1" )          .arg( params.gtNameZ );
+  data << QString( "gtNameColorRX=%1" )    .arg( params.gtNameColorRX );
+  data << QString( "gtNameColorGX=%1" )    .arg( params.gtNameColorGX );
+  data << QString( "gtNameColorBX=%1" )    .arg( params.gtNameColorBX );
+  data << QString( "gtNameColorRY=%1" )    .arg( params.gtNameColorRY );
+  data << QString( "gtNameColorGY=%1" )    .arg( params.gtNameColorGY );
+  data << QString( "gtNameColorBY=%1" )    .arg( params.gtNameColorBY );
+  data << QString( "gtNameColorRZ=%1" )    .arg( params.gtNameColorRZ );
+  data << QString( "gtNameColorGZ=%1" )    .arg( params.gtNameColorGZ );
+  data << QString( "gtNameColorBZ=%1" )    .arg( params.gtNameColorBZ );
+  data << QString( "gtDrawValuesX=%1" )    .arg( params.gtDrawValuesX );
+  data << QString( "gtDrawValuesY=%1" )    .arg( params.gtDrawValuesY );
+  data << QString( "gtDrawValuesZ=%1" )    .arg( params.gtDrawValuesZ );
+  data << QString( "gtNbValuesX=%1" )      .arg( params.gtNbValuesX );
+  data << QString( "gtNbValuesY=%1" )      .arg( params.gtNbValuesY );
+  data << QString( "gtNbValuesZ=%1" )      .arg( params.gtNbValuesZ );
+  data << QString( "gtOffsetX=%1" )        .arg( params.gtOffsetX );
+  data << QString( "gtOffsetY=%1" )        .arg( params.gtOffsetY );
+  data << QString( "gtOffsetZ=%1" )        .arg( params.gtOffsetZ );
+  data << QString( "gtColorRX=%1" )        .arg( params.gtColorRX );
+  data << QString( "gtColorGX=%1" )        .arg( params.gtColorGX );
+  data << QString( "gtColorBX=%1" )        .arg( params.gtColorBX );
+  data << QString( "gtColorRY=%1" )        .arg( params.gtColorRY );
+  data << QString( "gtColorGY=%1" )        .arg( params.gtColorGY );
+  data << QString( "gtColorBY=%1" )        .arg( params.gtColorBY );
+  data << QString( "gtColorRZ=%1" )        .arg( params.gtColorRZ );
+  data << QString( "gtColorGZ=%1" )        .arg( params.gtColorGZ );
+  data << QString( "gtColorBZ=%1" )        .arg( params.gtColorBZ );
+  data << QString( "gtDrawTickmarksX=%1" ) .arg( params.gtDrawTickmarksX );
+  data << QString( "gtDrawTickmarksY=%1" ) .arg( params.gtDrawTickmarksY );
+  data << QString( "gtDrawTickmarksZ=%1" ) .arg( params.gtDrawTickmarksZ );
+  data << QString( "gtTickmarkLengthX=%1" ).arg( params.gtTickmarkLengthX );
+  data << QString( "gtTickmarkLengthY=%1" ).arg( params.gtTickmarkLengthY );
+  data << QString( "gtTickmarkLengthZ=%1" ).arg( params.gtTickmarkLengthZ );
+#endif
+  QString bg = Qtx::backgroundToString( background() ).replace( "=", "$" );
+  data << QString( "background=%1" ).arg( bg );
+
+  return data.join("*");
+}
+
+/*!
+  \brief Restore visual parameters of the view window.
+  \param parameters visual parameters of view window
+*/
+void OCCViewer_ViewWindow::setVisualParameters( const QString& parameters )
+{
+  viewAspect params;
+  ClipPlanesList aClipPlanes;
+  QStringList data = parameters.split( '*' );
+  Qtx::BackgroundData bgData;
+  if ( parameters.contains( '=' )  ) // new format - "scale=1.000e+00*centerX=0.000e+00..."
+  {
+    foreach( QString param, data ) {
+      QString paramName  = param.section( '=', 0, 0 ).trimmed();
+      QString paramValue = param.section( '=', 1, 1 ).trimmed();
+      if      ( paramName == "scale" )             params.scale             = paramValue.toDouble();
+      else if ( paramName == "centerX" )           params.centerX           = paramValue.toDouble();
+      else if ( paramName == "centerY" )           params.centerY           = paramValue.toDouble();
+      else if ( paramName == "projX" )             params.projX             = paramValue.toDouble();
+      else if ( paramName == "projY" )             params.projY             = paramValue.toDouble();
+      else if ( paramName == "projZ" )             params.projZ             = paramValue.toDouble();
+      else if ( paramName == "twist" )             params.twist             = paramValue.toDouble();
+      else if ( paramName == "atX" )               params.atX               = paramValue.toDouble();
+      else if ( paramName == "atY" )               params.atY               = paramValue.toDouble();
+      else if ( paramName == "atZ" )               params.atZ               = paramValue.toDouble();
+      else if ( paramName == "eyeX" )              params.eyeX              = paramValue.toDouble();
+      else if ( paramName == "eyeY" )              params.eyeY              = paramValue.toDouble();
+      else if ( paramName == "eyeZ" )              params.eyeZ              = paramValue.toDouble();
+      else if ( paramName == "scaleX" )            params.scaleX            = paramValue.toDouble();
+      else if ( paramName == "scaleY" )            params.scaleY            = paramValue.toDouble();
+      else if ( paramName == "scaleZ" )            params.scaleZ            = paramValue.toDouble();
+      else if ( paramName == "isVisible" )         params.isVisible         = paramValue.toInt();
+      else if ( paramName == "size" )              params.size              = paramValue.toDouble();
+      else if ( paramName.contains( "ClippingPlane" ) )
+      {
+        QStringList ClipPlaneData = paramValue.split( ';' );
+        OCCViewer_ClipPlane aPlane;
+        foreach( QString ClipPlaneParam, ClipPlaneData )
+        {
+          QString ClipPlane_paramName  = ClipPlaneParam.section( '~', 0, 0 ).trimmed();
+          QString ClipPlane_paramValue = ClipPlaneParam.section( '~', 1, 1 ).trimmed();
+          if ( ClipPlane_paramName == "Mode" )
+          {
+            aPlane.Mode = ( OCCViewer_ClipPlane::PlaneMode ) ClipPlane_paramValue.toInt();
+          }
+          else if ( ClipPlane_paramName == "IsActive" ) aPlane.IsOn = ClipPlane_paramValue.toInt();
+          else if ( ClipPlane_paramName == "X" )        aPlane.X    = ClipPlane_paramValue.toDouble();
+          else if ( ClipPlane_paramName == "Y" )        aPlane.Y    = ClipPlane_paramValue.toDouble();
+          else if ( ClipPlane_paramName == "Z" )        aPlane.Z    = ClipPlane_paramValue.toDouble();
+          else
+          {
+            switch ( aPlane.Mode )
+            {
+              case OCCViewer_ClipPlane::Absolute :
+                if      ( ClipPlane_paramName == "Dx" ) aPlane.AbsoluteOrientation.Dx = ClipPlane_paramValue.toDouble();
+                else if ( ClipPlane_paramName == "Dy" ) aPlane.AbsoluteOrientation.Dy = ClipPlane_paramValue.toDouble();
+                else if ( ClipPlane_paramName == "Dz" ) aPlane.AbsoluteOrientation.Dz = ClipPlane_paramValue.toDouble();
+                else if ( ClipPlane_paramName == "IsInvert" ) aPlane.AbsoluteOrientation.IsInvert = ClipPlane_paramValue.toInt();
+                else if ( ClipPlane_paramName == "AbsoluteOrientation" ) aPlane.OrientationType = ClipPlane_paramValue.toInt();
+                break;
+
+              case OCCViewer_ClipPlane::Relative :
+                if      ( ClipPlane_paramName == "RelativeOrientation" ) aPlane.OrientationType = ClipPlane_paramValue.toInt();
+                else if ( ClipPlane_paramName == "Rotation1" )           aPlane.RelativeOrientation.Rotation1 = ClipPlane_paramValue.toDouble();
+                else if ( ClipPlane_paramName == "Rotation2" )           aPlane.RelativeOrientation.Rotation2 = ClipPlane_paramValue.toDouble();
+                break;
+            }
+          }
+        }
+        aClipPlanes.push_back(aPlane);
+      }
+      // graduated trihedron
+      else if ( paramName == "gtIsVisible" )       params.gtIsVisible       = paramValue.toInt();
+      else if ( paramName == "gtDrawNameX" )       params.gtDrawNameX       = paramValue.toInt();
+      else if ( paramName == "gtDrawNameY" )       params.gtDrawNameY       = paramValue.toInt();
+      else if ( paramName == "gtDrawNameZ" )       params.gtDrawNameZ       = paramValue.toInt();
+      else if ( paramName == "gtNameX" )           params.gtNameX           = paramValue;
+      else if ( paramName == "gtNameY" )           params.gtNameY           = paramValue;
+      else if ( paramName == "gtNameZ" )           params.gtNameZ           = paramValue;
+      else if ( paramName == "gtNameColorRX" )     params.gtNameColorRX     = paramValue.toInt();
+      else if ( paramName == "gtNameColorGX" )     params.gtNameColorGX     = paramValue.toInt();
+      else if ( paramName == "gtNameColorBX" )     params.gtNameColorBX     = paramValue.toInt();
+      else if ( paramName == "gtNameColorRY" )     params.gtNameColorRY     = paramValue.toInt();
+      else if ( paramName == "gtNameColorGY" )     params.gtNameColorGY     = paramValue.toInt();
+      else if ( paramName == "gtNameColorBY" )     params.gtNameColorBY     = paramValue.toInt();
+      else if ( paramName == "gtNameColorRZ" )     params.gtNameColorRZ     = paramValue.toInt();
+      else if ( paramName == "gtNameColorGZ" )     params.gtNameColorGZ     = paramValue.toInt();
+      else if ( paramName == "gtNameColorBZ" )     params.gtNameColorBZ     = paramValue.toInt();
+      else if ( paramName == "gtDrawValuesX" )     params.gtDrawValuesX     = paramValue.toInt();
+      else if ( paramName == "gtDrawValuesY" )     params.gtDrawValuesY     = paramValue.toInt();
+      else if ( paramName == "gtDrawValuesZ" )     params.gtDrawValuesZ     = paramValue.toInt();
+      else if ( paramName == "gtNbValuesX" )       params.gtNbValuesX       = paramValue.toInt();
+      else if ( paramName == "gtNbValuesY" )       params.gtNbValuesY       = paramValue.toInt();
+      else if ( paramName == "gtNbValuesZ" )       params.gtNbValuesZ       = paramValue.toInt();
+      else if ( paramName == "gtOffsetX" )         params.gtOffsetX         = paramValue.toInt();
+      else if ( paramName == "gtOffsetY" )         params.gtOffsetY         = paramValue.toInt();
+      else if ( paramName == "gtOffsetZ" )         params.gtOffsetZ         = paramValue.toInt();
+      else if ( paramName == "gtColorRX" )         params.gtColorRX         = paramValue.toInt();
+      else if ( paramName == "gtColorGX" )         params.gtColorGX         = paramValue.toInt();
+      else if ( paramName == "gtColorBX" )         params.gtColorBX         = paramValue.toInt();
+      else if ( paramName == "gtColorRY" )         params.gtColorRY         = paramValue.toInt();
+      else if ( paramName == "gtColorGY" )         params.gtColorGY         = paramValue.toInt();
+      else if ( paramName == "gtColorBY" )         params.gtColorBY         = paramValue.toInt();
+      else if ( paramName == "gtColorRZ" )         params.gtColorRZ         = paramValue.toInt();
+      else if ( paramName == "gtColorGZ" )         params.gtColorGZ         = paramValue.toInt();
+      else if ( paramName == "gtColorBZ" )         params.gtColorBZ         = paramValue.toInt();
+      else if ( paramName == "gtDrawTickmarksX" )  params.gtDrawTickmarksX  = paramValue.toInt();
+      else if ( paramName == "gtDrawTickmarksY" )  params.gtDrawTickmarksY  = paramValue.toInt();
+      else if ( paramName == "gtDrawTickmarksZ" )  params.gtDrawTickmarksZ  = paramValue.toInt();
+      else if ( paramName == "gtTickmarkLengthX" ) params.gtTickmarkLengthX = paramValue.toInt();
+      else if ( paramName == "gtTickmarkLengthY" ) params.gtTickmarkLengthY = paramValue.toInt();
+      else if ( paramName == "gtTickmarkLengthZ" ) params.gtTickmarkLengthZ = paramValue.toInt();
+      else if ( paramName == "background" )        {
+  QString bg = paramValue.replace( "$", "=" );
+  bgData = Qtx::stringToBackground( bg );
+      }
+    }
+  }
+  else // old format - "1.000e+00*0.000e+00..."
+  {
+    int idx = 0;
+    params.scale     = data.count() > idx ? data[idx++].toDouble() : 1.0;
+    params.centerX   = data.count() > idx ? data[idx++].toDouble() : 0.0;
+    params.centerY   = data.count() > idx ? data[idx++].toDouble() : 0.0;
+    params.projX     = data.count() > idx ? data[idx++].toDouble() : sqrt(1./3);
+    params.projY     = data.count() > idx ? data[idx++].toDouble() : -sqrt(1./3);
+    params.projZ     = data.count() > idx ? data[idx++].toDouble() : sqrt(1./3);
+    params.twist     = data.count() > idx ? data[idx++].toDouble() : 0.0;
+    params.atX       = data.count() > idx ? data[idx++].toDouble() : 0.0;
+    params.atY       = data.count() > idx ? data[idx++].toDouble() : 0.0;
+    params.atZ       = data.count() > idx ? data[idx++].toDouble() : 0.0;
+    params.eyeX      = data.count() > idx ? data[idx++].toDouble() : sqrt(250000./3);
+    params.eyeY      = data.count() > idx ? data[idx++].toDouble() : -sqrt(250000./3);
+    params.eyeZ      = data.count() > idx ? data[idx++].toDouble() : sqrt(250000./3);
+    params.scaleX    = data.count() > idx ? data[idx++].toDouble() : 1.0;
+    params.scaleY    = data.count() > idx ? data[idx++].toDouble() : 1.0;
+    params.scaleZ    = data.count() > idx ? data[idx++].toDouble() : 1.0;
+    params.isVisible = data.count() > idx ? data[idx++].toInt()    : 1;
+    params.size      = data.count() > idx ? data[idx++].toDouble() : 100.0;
+  }
+  performRestoring( params );  
+  setBackground( bgData );
+  myModel->setClipPlanes(aClipPlanes);
+}
+
+/*!
+  \brief Handle show event.
+
+  Emits Show() signal.
+
+  \param theEvent show event
+*/
+void OCCViewer_ViewWindow::showEvent( QShowEvent* theEvent )
+{
+  emit Show( theEvent );
+}
+
+/*!
+  \brief Handle hide event.
+
+  Emits Hide() signal.
+
+  \param theEvent hide event
+*/
+void OCCViewer_ViewWindow::hideEvent( QHideEvent* theEvent )
+{
+  emit Hide( theEvent );
+}
+
+
+/*!
+    Creates default sketcher. [ virtual protected ]
+*/
+OCCViewer_ViewSketcher* OCCViewer_ViewWindow::createSketcher( int type )
+{
+  if ( type == Rect )
+    return new OCCViewer_RectSketcher( this, type );
+  if ( type == Polygon )
+    return new OCCViewer_PolygonSketcher( this, type );
+  return 0;
+}
+
+void OCCViewer_ViewWindow::initSketchers()
+{
+  if ( mySketchers.isEmpty() )
+  {
+    mySketchers.append( createSketcher( Rect ) );
+    mySketchers.append( createSketcher( Polygon ) );
+  }
+}
+
+OCCViewer_ViewSketcher* OCCViewer_ViewWindow::getSketcher( const int typ )
+{
+  OCCViewer_ViewSketcher* sketcher = 0;
+  QList<OCCViewer_ViewSketcher*>::Iterator it;
+  for ( it = mySketchers.begin(); it != mySketchers.end() && !sketcher; ++it )
+  {
+    OCCViewer_ViewSketcher* sk = (*it);
+    if ( sk->type() == typ )
+      sketcher = sk;
+  }
+  return sketcher;
+}
+
+/*!
+    Handles requests for sketching in the active view. [ virtual public ]
+*/
+void OCCViewer_ViewWindow::activateSketching( int type )
+{
+  OCCViewer_ViewPort3d* vp = getViewPort();
+  if ( !vp )
+    return;
+
+  if ( !vp->isSketchingEnabled() )
+    return;
+
+  /* Finish current sketching */
+  if ( type == NoSketching )
+  {
+    if ( mypSketcher )
+    {
+      onSketchingFinished();
+      mypSketcher->deactivate();
+      mypSketcher = 0;
+    }
+  }
+  /* Activate new sketching */
+  else
+  {
+    activateSketching( NoSketching );  /* concurrency not suported */
+    mypSketcher = getSketcher( type );
+    if ( mypSketcher )
+    {
+      mypSketcher->activate();
+      onSketchingStarted();
+    }
+  }
+}
+
+/*!
+    Unhilights detected entities. [ virtual protected ]
+*/
+void OCCViewer_ViewWindow::onSketchingStarted()
+{
+}
+
+/*!
+    Selection by rectangle or polygon. [ virtual protected ]
+*/
+void OCCViewer_ViewWindow::onSketchingFinished()
+{
+  MESSAGE("OCCViewer_ViewWindow::onSketchingFinished()")
+  if ( mypSketcher && mypSketcher->result() == OCCViewer_ViewSketcher::Accept )
+  {
+    Handle(AIS_InteractiveContext) ic = myModel->getAISContext();
+    bool append = bool( mypSketcher->buttonState() && mypSketcher->isHasShift() );
+    switch( mypSketcher->type() )
+    {
+    case Rect:
+      {
+        QRect* aRect = (QRect*)mypSketcher->data();
+        if( aRect )
+        {
+          int aLeft = aRect->left();
+          int aRight = aRect->right();
+          int aTop = aRect->top();
+          int aBottom = aRect->bottom();
+//           myRect = aRect;
+
+          if( append )
+            ic->ShiftSelect( aLeft, aBottom, aRight, aTop, getViewPort()->getView(), Standard_False );
+          else
+            ic->Select( aLeft, aBottom, aRight, aTop, getViewPort()->getView(), Standard_False );
+        }
+      }
+      break;
+    case Polygon:
+      {
+        QPolygon* aPolygon = (QPolygon*)mypSketcher->data();
+        if( aPolygon )
+        {
+          int size = aPolygon->size();
+          TColgp_Array1OfPnt2d anArray( 1, size );
+
+          QPolygon::Iterator it = aPolygon->begin();
+          QPolygon::Iterator itEnd = aPolygon->end();
+          for( int index = 1; it != itEnd; ++it, index++ )
+          {
+            QPoint aPoint = *it;
+            anArray.SetValue( index, gp_Pnt2d( aPoint.x(), aPoint.y() ) );
+          }
+
+          if( append )
+            ic->ShiftSelect( anArray, getViewPort()->getView(), Standard_False );
+          else
+            ic->Select( anArray, getViewPort()->getView(), Standard_False );
+        }
+      }
+      break;
+    default:
+      break;
+    }
+
+    OCCViewer_ViewManager* aViewMgr = ( OCCViewer_ViewManager* )getViewManager();
+    aViewMgr->getOCCViewer()->performSelectionChanged();
+  }
+}
+
+OCCViewer_ViewPort3d* OCCViewer_ViewWindow::getViewPort()
+{
+  return myViewPort;
+}
+
+bool OCCViewer_ViewWindow::transformRequested() const
+{
+  return ( myOperation != NOTHING );
+}
+
+bool OCCViewer_ViewWindow::transformInProcess() const
+{
+  return myEventStarted;
+}
+
+void OCCViewer_ViewWindow::setTransformInProcess( bool bOn )
+{
+  myEventStarted = bOn;
+}
+
+/*!
+  Set enabled state of transformation (rotate, zoom, etc)
+*/
+void OCCViewer_ViewWindow::setTransformEnabled( const OperationType id, const bool on )
+{
+  if ( id != NOTHING ) myStatus.insert( id, on );
+}
+
+/*!
+  \return enabled state of transformation (rotate, zoom, etc)
+*/
+bool OCCViewer_ViewWindow::transformEnabled( const OperationType id ) const
+{
+  return myStatus.contains( id ) ? myStatus[ id ] : true;
+}
+
+void OCCViewer_ViewWindow::onMaximizedView()
+{
+  setMaximized(!isMaximized());
+}
+
+void OCCViewer_ViewWindow::returnTo3dView()
+{
+  setReturnedTo3dView( true );
+}
+
+void OCCViewer_ViewWindow::setReturnedTo3dView(bool isVisible3dView)
+{
+  if ( !toolMgr()->action( ReturnTo3dViewId ) ||
+    toolMgr()->isShown(ReturnTo3dViewId) != isVisible3dView ) return;
+  if ( !isVisible3dView )
+    toolMgr()->show( ReturnTo3dViewId );
+  else
+    toolMgr()->hide( ReturnTo3dViewId );
+  if ( isVisible3dView ) emit returnedTo3d( );
+}
+
+
+void OCCViewer_ViewWindow::setMaximized(bool toMaximize, bool toSendSignal)
+{
+  QAction* anAction =  toolMgr()->action( MaximizedId );
+  QAction* anAction2 =  toolMgr()->action( ReturnTo3dViewId );
+  SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
+  if ( toMaximize ) {
+    anAction->setText( tr( "MNU_MINIMIZE_VIEW" ) );  
+    anAction->setToolTip( tr( "MNU_MINIMIZE_VIEW" ) );  
+    anAction->setIcon( aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_MINIMIZE" ) ) );
+    anAction->setStatusTip( tr( "DSC_MINIMIZE_VIEW" ) );
+    if ( anAction2 && my2dMode != No2dMode ) toolMgr()->show( ReturnTo3dViewId );
+    if (toSendSignal) {
+      emit maximized( this, true );
+    }
+  }
+  else {
+    anAction->setText( tr( "MNU_MAXIMIZE_VIEW" ) );  
+    anAction->setToolTip( tr( "MNU_MAXIMIZE_VIEW" ) );  
+    anAction->setIcon( aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_MAXIMIZE" ) ) );
+    anAction->setStatusTip( tr( "DSC_MAXIMIZE_VIEW" ) );
+    if ( anAction2 && my2dMode != No2dMode ) toolMgr()->hide( ReturnTo3dViewId );
+    if (toSendSignal) {
+      emit maximized( this, false );
+    }
+  }
+}
+
+bool OCCViewer_ViewWindow::isMaximized() const
+{
+  return !(toolMgr()->action( MaximizedId )->text() == tr( "MNU_MAXIMIZE_VIEW" ));
+}
+
+void OCCViewer_ViewWindow::setSketcherStyle( bool enable )
+{ 
+  IsSketcherStyle = enable; 
+}
+
+bool OCCViewer_ViewWindow::isSketcherStyle() const 
+{ 
+  return IsSketcherStyle; 
+}
+
+
+void OCCViewer_ViewWindow::set2dMode(Mode2dType theType)
+{
+  my2dMode = theType;
+}
+
+// obsolete   
+QColor OCCViewer_ViewWindow::backgroundColor() const
+{
+  return myViewPort ? myViewPort->backgroundColor() : Qt::black;
+}
+   
+// obsolete
+void OCCViewer_ViewWindow::setBackgroundColor( const QColor& theColor )
+{
+  if ( myViewPort ) myViewPort->setBackgroundColor( theColor );
+}
+
+Qtx::BackgroundData OCCViewer_ViewWindow::background() const
+{
+  return myViewPort ? myViewPort->background() : Qtx::BackgroundData();
+}
+   
+void OCCViewer_ViewWindow::setBackground( const Qtx::BackgroundData& theBackground )
+{
+  if ( myViewPort ) myViewPort->setBackground( theBackground );
+}
+
+void OCCViewer_ViewWindow::showStaticTrihedron( bool on )
+{
+  if ( myViewPort ) myViewPort->showStaticTrihedron( on );
+}
+
+/*!
+  Clears view aspects
+*/
+void OCCViewer_ViewWindow::clearViewAspects()
+{
+  myViewAspects.clear();
+}
+
+/*!
+  \return const reference to list of view aspects
+*/
+const viewAspectList& OCCViewer_ViewWindow::getViewAspects()
+{
+  return myViewAspects;
+}
+
+/*!
+  Appends new view aspect
+  \param aParams - new view aspects
+*/
+void OCCViewer_ViewWindow::appendViewAspect( const viewAspect& aParams )
+{
+  myViewAspects.append( aParams );
+}
+
+/*!
+  Replaces old view aspects by new ones
+  \param aViewList - list of new view aspects
+*/
+void OCCViewer_ViewWindow::updateViewAspects( const viewAspectList& aViewList )
+{
+  myViewAspects = aViewList;
+}
+
+/*!
+  Get camera properties for the OCC view window.
+  \return shared pointer on camera properties.
+*/
+SUIT_CameraProperties OCCViewer_ViewWindow::cameraProperties()
+{
+  SUIT_CameraProperties aProps;
+
+  Handle(V3d_View) aSourceView = getViewPort()->getView();
+  if ( aSourceView.IsNull() )
+    return aProps;
+
+  if ( get2dMode() == No2dMode ) {
+    aProps.setDimension( SUIT_CameraProperties::Dim3D );
+  }
+  else {
+    aProps.setDimension( SUIT_CameraProperties::Dim2D );
+    aProps.setViewSide( (SUIT_CameraProperties::ViewSide)(int)get2dMode() );
+  }
+
+  // read common properites of the view
+  Standard_Real anUp[3];
+  Standard_Real anAt[3];
+  Standard_Real anEye[3];
+  Standard_Real aProj[3];
+  Standard_Real anAxialScale[3];
+
+  aSourceView->Up( anUp[0], anUp[1], anUp[2] );
+  aSourceView->At( anAt[0], anAt[1], anAt[2] );
+  aSourceView->Proj( aProj[0], aProj[1], aProj[2] );
+  getViewPort()->getAxialScale( anAxialScale[0], anAxialScale[1], anAxialScale[2] );
+
+  aProps.setAxialScale( anAxialScale[0], anAxialScale[1], anAxialScale[2] );
+  aProps.setViewUp( anUp[0], anUp[1], anUp[2] );
+
+#if OCC_VERSION_LARGE > 0x06070100
+  aSourceView->Eye( anEye[0], anEye[1], anEye[2] );
+
+  // store camera properties "as is": it is up to synchronized
+  // view classes to provide necessary property conversion.
+  aProps.setPosition( anEye[0], anEye[1], anEye[2] );
+  aProps.setFocalPoint( anAt[0], anAt[1], anAt[2] );
+
+  if ( aSourceView->Camera()->IsOrthographic() )
+  {
+    aProps.setProjection( SUIT_CameraProperties::PrjOrthogonal );
+    aProps.setViewAngle( 0.0 );
+  }
+  else
+  {
+    aProps.setProjection( SUIT_CameraProperties::PrjPerspective );
+    aProps.setViewAngle( aSourceView->Camera()->FOVy() );
+  }
+  aProps.setMappingScale( aSourceView->Camera()->Scale() );
+#else
+  Standard_Real aCameraDepth = aSourceView->Depth() + aSourceView->ZSize() * 0.5;
+
+  // generate view orientation matrix for transforming OCC projection reference point
+  // into a camera (eye) position.
+  gp_Dir aLeftDir = gp_Dir( anUp[0], anUp[1], anUp[2] ) ^ gp_Dir( aProj[0], aProj[1], aProj[2] );
+
+  gp_GTrsf aTrsf;
+  aTrsf.SetValue( 1, 1, aLeftDir.X() );
+  aTrsf.SetValue( 2, 1, aLeftDir.Y() );
+  aTrsf.SetValue( 3, 1, aLeftDir.Z() );
+
+  aTrsf.SetValue( 1, 2, anUp[0] );
+  aTrsf.SetValue( 2, 2, anUp[1] );
+  aTrsf.SetValue( 3, 2, anUp[2] );
+
+  aTrsf.SetValue( 1, 3, aProj[0] );
+  aTrsf.SetValue( 2, 3, aProj[1] );
+  aTrsf.SetValue( 3, 3, aProj[2] );
+
+  aTrsf.SetValue( 1, 4, anAt[0] );
+  aTrsf.SetValue( 2, 4, anAt[1] );
+  aTrsf.SetValue( 3, 4, anAt[2] );
+
+  Graphic3d_Vertex aProjRef = aSourceView->ViewMapping().ProjectionReferencePoint();
+
+  // transform to world-space coordinate system
+  gp_XYZ aPosition( aProjRef.X(), aProjRef.Y(), aCameraDepth );
+  aTrsf.Transforms( aPosition );
+
+  // compute focal point
+  double aFocalPoint[3];
+
+  aFocalPoint[0] = aPosition.X() - aProj[0] * aCameraDepth;
+  aFocalPoint[1] = aPosition.Y() - aProj[1] * aCameraDepth;
+  aFocalPoint[2] = aPosition.Z() - aProj[2] * aCameraDepth;
+
+  aProps.setFocalPoint( aFocalPoint[0], aFocalPoint[1], aFocalPoint[2] );
+  aProps.setPosition( aPosition.X(), aPosition.Y(), aPosition.Z() );
+
+  Standard_Real aViewScale[2];
+  aSourceView->Size( aViewScale[0], aViewScale[1] );
+  aProps.setMappingScale( aViewScale[1] );
+#endif
+
+  return aProps;
+}
+
+/*!
+  Synchronize views.
+  This implementation synchronizes OCC view's camera propreties.
+*/
+void OCCViewer_ViewWindow::synchronize( SUIT_ViewWindow* theView )
+{
+  bool blocked = blockSignals( true );
+
+  SUIT_CameraProperties aProps = theView->cameraProperties();
+  if ( !cameraProperties().isCompatible( aProps ) ) {
+    // other view, this one is being currently synchronized to, seems has become incompatible
+    // we have to break synchronization
+    updateSyncViews();
+    return;
+  }
+
+  Handle(V3d_View) aDestView = getViewPort()->getView();
+
+  aDestView->SetImmediateUpdate( Standard_False );
+
+  double anUpDir[3];
+  double aPosition[3];
+  double aFocalPoint[3];
+  double anAxialScale[3];
+
+  // get common properties
+  aProps.getFocalPoint( aFocalPoint[0], aFocalPoint[1], aFocalPoint[2] );
+  aProps.getPosition( aPosition[0], aPosition[1], aPosition[2] );
+  aProps.getViewUp( anUpDir[0], anUpDir[1], anUpDir[2] );
+  aProps.getAxialScale( anAxialScale[0], anAxialScale[1], anAxialScale[2] );
+
+#if OCC_VERSION_LARGE > 0x06070100
+  aDestView->SetAt( aFocalPoint[0], aFocalPoint[1], aFocalPoint[2] );
+  aDestView->SetEye( aPosition[0], aPosition[1], aPosition[2] );
+  aDestView->SetUp( anUpDir[0], anUpDir[1], anUpDir[2] );
+  aDestView->Camera()->SetScale( aProps.getMappingScale() );
+#else
+  gp_Dir aProjDir( aPosition[0] - aFocalPoint[0],
+                   aPosition[1] - aFocalPoint[1],
+                   aPosition[2] - aFocalPoint[2] );
+
+  // get custom view translation
+  Standard_Real aTranslation[3];
+  aDestView->At( aTranslation[0], aTranslation[1], aTranslation[2] );
+
+  gp_Dir aLeftDir = gp_Dir( anUpDir[0], anUpDir[1], anUpDir[2] )
+                  ^ gp_Dir( aProjDir.X(), aProjDir.Y(), aProjDir.Z() );
+
+  gp_GTrsf aTrsf;
+  aTrsf.SetValue( 1, 1, aLeftDir.X() );
+  aTrsf.SetValue( 2, 1, aLeftDir.Y() );
+  aTrsf.SetValue( 3, 1, aLeftDir.Z() );
+
+  aTrsf.SetValue( 1, 2, anUpDir[0] );
+  aTrsf.SetValue( 2, 2, anUpDir[1] );
+  aTrsf.SetValue( 3, 2, anUpDir[2] );
+
+  aTrsf.SetValue( 1, 3, aProjDir.X() );
+  aTrsf.SetValue( 2, 3, aProjDir.Y() );
+  aTrsf.SetValue( 3, 3, aProjDir.Z() );
+
+  aTrsf.SetValue( 1, 4, aTranslation[0] );
+  aTrsf.SetValue( 2, 4, aTranslation[1] );
+  aTrsf.SetValue( 3, 4, aTranslation[2] );
+  aTrsf.Invert();
+
+  // transform to view-space coordinate system
+  gp_XYZ aProjRef( aPosition[0], aPosition[1], aPosition[2] );
+  aTrsf.Transforms( aProjRef );
+
+  // set view camera properties using low-level approach. this is done
+  // in order to avoid interference with static variables in v3d view used
+  // when rotation is in process in another view.
+  Visual3d_ViewMapping aMapping = aDestView->View()->ViewMapping();
+  Visual3d_ViewOrientation anOrientation = aDestView->View()->ViewOrientation();
+
+  Graphic3d_Vector aMappingProj( aProjDir.X(), aProjDir.Y(), aProjDir.Z() );
+  Graphic3d_Vector aMappingUp( anUpDir[0], anUpDir[1], anUpDir[2] );
+
+  aMappingProj.Normalize();
+  aMappingUp.Normalize();
+
+  anOrientation.SetViewReferencePlane( aMappingProj );
+  anOrientation.SetViewReferenceUp( aMappingUp );
+
+  aDestView->SetViewMapping( aMapping );
+  aDestView->SetViewOrientation( anOrientation );
+
+  // set panning
+  aDestView->SetCenter( aProjRef.X(), aProjRef.Y() );
+
+  // set mapping scale
+  double aMapScaling = aProps.getMappingScale();
+  Standard_Real aWidth, aHeight;
+  aDestView->Size( aWidth, aHeight );
+  aDestView->SetSize ( aWidth > aHeight ? aMapScaling * (aWidth / aHeight) : aMapScaling );
+#endif
+
+  getViewPort()->setAxialScale( anAxialScale[0], anAxialScale[1], anAxialScale[2] );
+
+  aDestView->ZFitAll();
+  aDestView->SetImmediateUpdate( Standard_True );
+  aDestView->Redraw();
+
+  blockSignals( blocked );
+}
+
+/*!
+  \brief Indicates whether preselection is enabled
+  \return true if preselection is enabled
+*/
+bool OCCViewer_ViewWindow::isPreselectionEnabled() const
+{
+  return myPreselectionEnabled;
+}
+
+/*!
+  \brief Enables/disables preselection
+  \param theIsToEnable if true - preselection will be enabled
+*/
+void OCCViewer_ViewWindow::enablePreselection( bool theIsToEnable )
+{
+  onSwitchPreselection( theIsToEnable );
+}
+
+/*!
+  \brief Indicates whether selection is enabled
+  \return true if selection is enabled
+*/
+bool OCCViewer_ViewWindow::isSelectionEnabled() const
+{
+  return mySelectionEnabled;
+}
+
+/*!
+  \brief Enables/disables selection
+  \param theIsToEnable if true - selection will be enabled
+*/
+void OCCViewer_ViewWindow::enableSelection( bool theIsToEnable )
+{
+  onSwitchSelection( theIsToEnable );
+}
+
+
+/*!
+  \brief called if clipping operation is activated / deactivated.
+
+  Enables/disables clipping plane displaying.
+
+  \parma on action state
+*/
+void OCCViewer_ViewWindow::onClipping (bool theIsOn)
+{
+  if(!myModel) return;
+  OCCViewer_ClippingDlg* aClippingDlg = myModel->getClippingDlg();
+  
+  if (theIsOn) {
+    if (!aClippingDlg) {
+      aClippingDlg = new OCCViewer_ClippingDlg (this, myModel);
+      myModel->setClippingDlg(aClippingDlg);
+    }
+    if (!aClippingDlg->isVisible())
+      aClippingDlg->show();
+  } else {
+    if ( aClippingDlg ) {
+      aClippingDlg->close();
+      myModel->setClippingDlg(0);
+    }
+  }
+
+  SUIT_ViewManager* mgr = getViewManager();
+  if( mgr ) {
+    QVector<SUIT_ViewWindow*> aViews = mgr->getViews();
+    for(int i = 0, iEnd = aViews.size(); i < iEnd; i++) {
+      if(SUIT_ViewWindow* aViewWindow = aViews.at(i)) {
+       QtxActionToolMgr* mgr = aViewWindow->toolMgr();
+       if(!mgr) continue;
+       QAction* a = toolMgr()->action( ClippingId );
+       if(!a) continue;
+       if(theIsOn != a->isChecked()){
+         disconnect (a, SIGNAL (toggled (bool)), aViewWindow, SLOT (onClipping (bool)));
+         a->setChecked(theIsOn);
+         connect (a, SIGNAL (toggled (bool)), aViewWindow, SLOT (onClipping (bool)));
+       }
+      }
+    }
+  }
+}
index 57b819862524d722f416c17f81756b822e7676f4..421e43f049b4956cabd1b472ae3f4af953a8c670 100755 (executable)
@@ -223,6 +223,8 @@ public:
   virtual QColor  backgroundColor() const;                      // obsolete
   virtual void    setBackgroundColor( const QColor& );          // obsolete
 
+  virtual void    showStaticTrihedron( bool );
+
   virtual Qtx::BackgroundData  background() const;
   virtual void                 setBackground( const Qtx::BackgroundData& );
 
@@ -258,7 +260,7 @@ public slots:
   virtual void onAmbientToogle();
   virtual void onMemorizeView();
   virtual void onRestoreView();
-  virtual void onTrihedronShow();
+  virtual void onTrihedronShow(bool);
   virtual void setRestoreFlag();
   virtual void onSwitchInteractionStyle( bool on );
   virtual void onSwitchZoomingStyle( bool on );
index 40695337d08ef2f3d93af492e3b16d234a1d0eb6..ffeee2b0faa43c285eb700f3ea9251e949d2ae9a 100644 (file)
     </message>
     <message>
         <source>LBL_SELECTPOINT</source>
-        <translation>Gravity Center of Select Object</translation>
+        <translation>Gravity Center of Selected Object</translation>
     </message>
     <message>
         <source>LBL_POINT</source>
index 6ec3398a5db6aa58b513781703ac152cb7558199..f5afea2c963e5bc099de785b5ae11088394610bc 100644 (file)
 <?xml version="1.0" encoding="utf-8"?>
 <!DOCTYPE TS>
-<TS version="2.0">
-<context>
+<TS version="2.0" language="ja" sourcelanguage="en">
+  <context>
     <name>@default</name>
     <message>
-        <source>MNU_FRONT_VIEW</source>
-        <translation>正面</translation>
+      <source>MNU_FRONT_VIEW</source>
+      <translation>正面</translation>
     </message>
     <message>
-        <source>ERROR</source>
-        <translation>エラー</translation>
+      <source>ERROR</source>
+      <translation>エラー</translation>
     </message>
     <message>
-        <source>MNU_DUMP_VIEW</source>
-        <translation>シーンを保存します。</translation>
+      <source>MNU_DUMP_VIEW</source>
+      <translation>シーンを保存します。</translation>
     </message>
     <message>
-        <source>DSC_TOP_VIEW</source>
-        <translation>上から見る</translation>
+      <source>DSC_TOP_VIEW</source>
+      <translation>上から見る</translation>
     </message>
     <message>
-        <source>MNU_PAN_VIEW</source>
-        <translation>並進移動</translation>
+      <source>MNU_PAN_VIEW</source>
+      <translation>並進移動</translation>
     </message>
     <message>
-        <source>MNU_CLONE_VIEW</source>
-        <translation>ビューの複製</translation>
+      <source>MNU_CLONE_VIEW</source>
+      <translation>ビューの複製</translation>
     </message>
     <message>
-        <source>DSC_SHOW_TRIHEDRE</source>
-        <translation>表示/非表示の三面体をシーンに</translation>
+      <source>DSC_SHOW_TRIHEDRE</source>
+      <translation>表示/非表示の三面体をシーンに</translation>
     </message>
     <message>
-        <source>MNU_SHOW_TRIHEDRE</source>
-        <translation>軸の表示/非表示</translation>
+      <source>MNU_SHOW_TRIHEDRE</source>
+      <translation>軸の表示/非表示</translation>
     </message>
     <message>
-        <source>MNU_TOP_VIEW</source>
-        <translation>上面</translation>
+      <source>MNU_TOP_VIEW</source>
+      <translation>上面</translation>
     </message>
     <message>
-        <source>DSC_GLOBALPAN_VIEW</source>
-        <translation>ビューの新しい中心地の選択</translation>
+      <source>DSC_GLOBALPAN_VIEW</source>
+      <translation>ビューの新しい中心地の選択</translation>
     </message>
     <message>
-        <source>DSC_ROTATE_VIEW</source>
-        <translation>ステージの中心の周りを回転します。</translation>
+      <source>DSC_ROTATE_VIEW</source>
+      <translation>ステージの中心の周りを回転します。</translation>
     </message>
     <message>
-        <source>MNU_ZOOM_VIEW</source>
-        <translation>ズーム</translation>
+      <source>MNU_ZOOM_VIEW</source>
+      <translation>ズーム</translation>
     </message>
     <message>
-        <source>DSC_PAN_VIEW</source>
-        <translation>ビューを移動します。</translation>
+      <source>DSC_PAN_VIEW</source>
+      <translation>ビューを移動します。</translation>
     </message>
     <message>
-        <source>DSC_LEFT_VIEW</source>
-        <translation>左側のビュー</translation>
+      <source>DSC_LEFT_VIEW</source>
+      <translation>左側のビュー</translation>
     </message>
     <message>
-        <source>DSC_SHOOT_VIEW</source>
-        <translation>状態の現在のシーンを保存し、一覧に追加</translation>
+      <source>DSC_SHOOT_VIEW</source>
+      <translation>状態の現在のシーンを保存し、一覧に追加</translation>
     </message>
     <message>
-        <source>DSC_FITALL</source>
-        <translation>すべてのオブジェクトを表示するには、シーンを Redimentionner</translation>
+      <source>DSC_FITALL</source>
+      <translation>すべてのオブジェクトを表示するには、シーンを Redimentionner</translation>
     </message>
     <message>
-        <source>MNU_FITALL</source>
-        <translation>全体表示</translation>
+      <source>MNU_FITALL</source>
+      <translation>全体表示</translation>
     </message>
     <message>
-        <source>MNU_ROTATE_VIEW</source>
-        <translation>回転</translation>
+      <source>MNU_ROTATE_VIEW</source>
+      <translation>回転</translation>
     </message>
     <message>
-        <source>DSC_FRONT_VIEW</source>
-        <translation>正面</translation>
+      <source>DSC_FRONT_VIEW</source>
+      <translation>正面</translation>
     </message>
     <message>
-        <source>MNU_ROTATIONPOINTGRAVITY_VIEW</source>
-        <translation>回転点: 重力の中心部</translation>
+      <source>MNU_ROTATIONPOINTGRAVITY_VIEW</source>
+      <translation>回転点: 重力の中心部</translation>
     </message>
     <message>
-        <source>MNU_GLOBALPAN_VIEW</source>
-        <translation>グローバルパンニング</translation>
+      <source>MNU_GLOBALPAN_VIEW</source>
+      <translation>グローバルパンニング</translation>
     </message>
     <message>
-        <source>INF_APP_DUMP_VIEW</source>
-        <translation>ビューを保存します。</translation>
+      <source>INF_APP_DUMP_VIEW</source>
+      <translation>ビューを保存します。</translation>
     </message>
     <message>
-        <source>DSC_CLIPPING</source>
-        <translation>クリップ平面を定義します。</translation>
+      <source>DSC_CLIPPING</source>
+      <translation>クリップ平面を定義します。</translation>
     </message>
     <message>
-        <source>DSC_CLONE_VIEW</source>
-        <translation>現在のステージの可視化の新しいウィンドウを開く</translation>
+      <source>DSC_CLONE_VIEW</source>
+      <translation>現在のステージの可視化の新しいウィンドウを開く</translation>
     </message>
     <message>
-        <source>INF_APP_SHOOT_VIEW</source>
-        <translation>場面を覚えています。</translation>
+      <source>INF_APP_SHOOT_VIEW</source>
+      <translation>場面を覚えています。</translation>
     </message>
     <message>
-        <source>MNU_CLIPPING</source>
-        <translation>断面</translation>
+      <source>MNU_CLIPPING</source>
+      <translation>断面</translation>
     </message>
     <message>
-        <source>MNU_BACK_VIEW</source>
-        <translation>背面</translation>
+      <source>MNU_BACK_VIEW</source>
+      <translation>背面</translation>
     </message>
     <message>
-        <source>MNU_SHOOT_VIEW</source>
-        <translation>ビューの保存</translation>
+      <source>MNU_SHOOT_VIEW</source>
+      <translation>ビューの保存</translation>
     </message>
     <message>
-        <source>DSC_CHANGINGROTATIONPOINT_VIEW</source>
-        <translation>シーンになってポイントを変更します。</translation>
+      <source>DSC_CHANGINGROTATIONPOINT_VIEW</source>
+      <translation>シーンになってポイントを変更します。</translation>
     </message>
     <message>
-        <source>MNU_BOTTOM_VIEW</source>
-        <translation>底面</translation>
+      <source>MNU_BOTTOM_VIEW</source>
+      <translation>底面</translation>
     </message>
     <message>
-        <source>MNU_RESET_VIEW</source>
-        <translation>表示リセット</translation>
+      <source>MNU_RESET_VIEW</source>
+      <translation>表示リセット</translation>
     </message>
     <message>
-        <source>MNU_LEFT_VIEW</source>
-        <translation>左側面</translation>
+      <source>MNU_LEFT_VIEW</source>
+      <translation>左側面</translation>
     </message>
     <message>
-        <source>DSC_RIGHT_VIEW</source>
-        <translation>右側のビュー</translation>
+      <source>DSC_RIGHT_VIEW</source>
+      <translation>右側のビュー</translation>
     </message>
     <message>
-        <source>DSC_ANTICLOCKWISE_VIEW</source>
-        <translation>表示を左に</translation>
+      <source>DSC_ANTICLOCKWISE_VIEW</source>
+      <translation>表示を左に</translation>
     </message>
     <message>
-        <source>DSC_CLOCKWISE_VIEW</source>
-        <translation>右のビューを回転させる</translation>
+      <source>DSC_CLOCKWISE_VIEW</source>
+      <translation>右のビューを回転させる</translation>
     </message>
     <message>
-        <source>MNU_CHANGINGROTATIONPOINT_VIEW</source>
-        <translation>回転の基準点を変更</translation>
+      <source>MNU_CHANGINGROTATIONPOINT_VIEW</source>
+      <translation>回転の基準点を変更</translation>
     </message>
     <message>
-        <source>DSC_FITRECT</source>
-        <translation>彼の党をボックスで選択を表示するには、ステージのサイズを変更します。</translation>
+      <source>DSC_FITRECT</source>
+      <translation>彼の党をボックスで選択を表示するには、ステージのサイズを変更します。</translation>
     </message>
     <message>
-        <source>MNU_FITRECT</source>
-        <translation>表示エリア</translation>
+      <source>MNU_FITRECT</source>
+      <translation>表示エリア</translation>
     </message>
     <message>
-        <source>DSC_BOTTOM_VIEW</source>
-        <translation>下から表示します。</translation>
+      <source>DSC_BOTTOM_VIEW</source>
+      <translation>下から表示します。</translation>
     </message>
     <message>
-        <source>DSC_DUMP_VIEW</source>
-        <translation>現在のシーンをイメージ ファイルに保存します。</translation>
+      <source>DSC_DUMP_VIEW</source>
+      <translation>現在のシーンをイメージ ファイルに保存します。</translation>
     </message>
     <message>
-        <source>DSC_ZOOM_VIEW</source>
-        <translation>ズーム</translation>
+      <source>DSC_ZOOM_VIEW</source>
+      <translation>ズーム</translation>
     </message>
     <message>
-        <source>MNU_ROTATIONPOINT000_VIEW</source>
-        <translation>回転点: (0,0,0)</translation>
+      <source>MNU_ROTATIONPOINT000_VIEW</source>
+      <translation>回転点: (0,0,0)</translation>
     </message>
     <message>
-        <source>MNU_ROTATIONPOINTSELECTED_VIEW</source>
-        <translation>回転点: ユーザーが選択したポイント</translation>
+      <source>MNU_ROTATIONPOINTSELECTED_VIEW</source>
+      <translation>回転点: ユーザーが選択したポイント</translation>
     </message>
     <message>
-        <source>DSC_RESET_VIEW</source>
-        <translation>ビューのポイントを復元します。</translation>
+      <source>DSC_RESET_VIEW</source>
+      <translation>ビューのポイントを復元します。</translation>
     </message>
     <message>
-        <source>ERR_DOC_CANT_SAVE_FILE</source>
-        <translation>ファイルを保存できませんでした。</translation>
+      <source>ERR_DOC_CANT_SAVE_FILE</source>
+      <translation>ファイルを保存できませんでした。</translation>
     </message>
     <message>
-        <source>DSC_PRESETS_VIEW</source>
-        <translation>状態の復元は、現在のシーンの記憶</translation>
+      <source>DSC_PRESETS_VIEW</source>
+      <translation>状態の復元は、現在のシーンの記憶</translation>
     </message>
     <message>
-        <source>MNU_PRESETS_VIEW</source>
-        <translation>ビューの読み込み</translation>
+      <source>MNU_PRESETS_VIEW</source>
+      <translation>ビューの読み込み</translation>
     </message>
     <message>
-        <source>MNU_ANTICLOCKWISE_VIEW</source>
-        <translation>左回転</translation>
+      <source>MNU_ANTICLOCKWISE_VIEW</source>
+      <translation>左回転</translation>
     </message>
     <message>
-        <source>MNU_CLOCKWISE_VIEW</source>
-        <translation>右回転</translation>
+      <source>MNU_CLOCKWISE_VIEW</source>
+      <translation>右回転</translation>
     </message>
     <message>
-        <source>MNU_RIGHT_VIEW</source>
-        <translation>右側面</translation>
+      <source>MNU_RIGHT_VIEW</source>
+      <translation>右側面</translation>
     </message>
     <message>
-        <source>INF_APP_PRESETS_VIEW</source>
-        <translation>ビューの復元</translation>
+      <source>INF_APP_PRESETS_VIEW</source>
+      <translation>ビューの復元</translation>
     </message>
     <message>
-        <source>LBL_XYTOOLBAR_LABEL</source>
-        <translation>XY ビューの操作</translation>
+      <source>LBL_XYTOOLBAR_LABEL</source>
+      <translation>XY ビューの操作</translation>
     </message>
     <message>
-        <source>LBL_XZTOOLBAR_LABEL</source>
-        <translation>XZ ビューの操作</translation>
+      <source>LBL_XZTOOLBAR_LABEL</source>
+      <translation>XZ ビューの操作</translation>
     </message>
     <message>
-        <source>LBL_YZTOOLBAR_LABEL</source>
-        <translation>YZ ビューの操作</translation>
+      <source>LBL_YZTOOLBAR_LABEL</source>
+      <translation>YZ ビューの操作</translation>
     </message>
     <message>
-        <source>LBL_3DTOOLBAR_LABEL</source>
-        <translation>3D ビューの操作</translation>
+      <source>LBL_3DTOOLBAR_LABEL</source>
+      <translation>3D ビューの操作</translation>
     </message>
     <message>
-        <source>DSC_BACK_VIEW</source>
-        <translation>背面図</translation>
+      <source>DSC_BACK_VIEW</source>
+      <translation>背面図</translation>
     </message>
     <message>
-        <source>DSC_SCALING</source>
-        <translation>座標のスケールの軸を変更します。</translation>
+      <source>DSC_SCALING</source>
+      <translation>座標のスケールの軸を変更します。</translation>
     </message>
     <message>
-        <source>MNU_SCALING</source>
-        <translation>軸のスケーリング</translation>
+      <source>MNU_SCALING</source>
+      <translation>軸のスケーリング</translation>
     </message>
     <message>
-        <source>DSC_GRADUATED_AXES</source>
-        <translation>目盛付軸</translation>
+      <source>DSC_GRADUATED_AXES</source>
+      <translation>目盛付軸</translation>
     </message>
     <message>
-        <source>MNU_GRADUATED_AXES</source>
-        <translation>目盛付軸</translation>
+      <source>MNU_GRADUATED_AXES</source>
+      <translation>目盛付軸</translation>
     </message>
     <message>
-        <source>DSC_AMBIENT</source>
-        <translation>環境光のみの表示</translation>
+      <source>DSC_AMBIENT</source>
+      <translation>環境光のみの表示</translation>
     </message>
     <message>
-        <source>MNU_AMBIENT</source>
-        <translation>アンビエント ライトを表示します。</translation>
+      <source>MNU_AMBIENT</source>
+      <translation>アンビエント ライトを表示します。</translation>
     </message>
     <message>
-        <source>DSC_STYLE_SWITCH</source>
-        <translation>相互作用のスタイルを変更します。</translation>
+      <source>DSC_STYLE_SWITCH</source>
+      <translation>相互作用のスタイルを変更します。</translation>
     </message>
     <message>
-        <source>MNU_STYLE_SWITCH</source>
-        <translation>相互作用のスタイルを変更します。</translation>
+      <source>MNU_STYLE_SWITCH</source>
+      <translation>相互作用のスタイルを変更します。</translation>
     </message>
     <message>
-        <source>DSC_ZOOMING_STYLE_SWITCH</source>
-        <translation>ズームのスタイルを変更します。</translation>
+      <source>DSC_ZOOMING_STYLE_SWITCH</source>
+      <translation>ズームのスタイルを変更します。</translation>
     </message>
     <message>
-        <source>MNU_ZOOMING_STYLE_SWITCH</source>
-        <translation>ズームのスタイルを変更します。</translation>
+      <source>MNU_ZOOMING_STYLE_SWITCH</source>
+      <translation>ズームのスタイルを変更します。</translation>
     </message>
     <message>
-        <source>DSC_ENABLE_PRESELECTION</source>
-        <translation>予選の有効/無効にします。</translation>
+      <source>DSC_ENABLE_PRESELECTION</source>
+      <translation>予選の有効/無効にします。</translation>
     </message>
     <message>
-        <source>MNU_ENABLE_PRESELECTION</source>
-        <translation>予選の有効/無効にします。</translation>
+      <source>MNU_ENABLE_PRESELECTION</source>
+      <translation>予選の有効/無効にします。</translation>
     </message>
     <message>
-        <source>DSC_ENABLE_SELECTION</source>
-        <translation>選択を有効/無効にします。</translation>
+      <source>DSC_ENABLE_SELECTION</source>
+      <translation>選択を有効/無効にします。</translation>
     </message>
     <message>
-        <source>MNU_ENABLE_SELECTION</source>
-        <translation>選択を有効/無効にします。</translation>
+      <source>MNU_ENABLE_SELECTION</source>
+      <translation>選択を有効/無効にします。</translation>
     </message>
     <message>
-        <source>OCC_IMAGE_FILES</source>
-        <translation>イメージファイル (*.bmp *.png *.jpg *.jpeg *.eps *.ps)</translation>
+      <source>OCC_IMAGE_FILES</source>
+      <translation>イメージファイル (*.bmp *.png *.jpg *.jpeg *.eps *.ps)</translation>
     </message>
     <message>
-        <source>OCC_TEXTURE_FILES</source>
-        <translation>イメージファイル (*.jpeg *jpg *.jpe *.png *.bmp *.gif *.ppm *.tif *.tiff* .tga *.exr)</translation>
+      <source>OCC_TEXTURE_FILES</source>
+      <translatorcomment>Update to new supported format (see OCCT Image_AlienPixMap documentation)</translatorcomment>
+      <translation>イメージファイル (*.bmp *.gif *.pix *.xwd *.rgb *.rs)</translation>
     </message>
     <message>
-        <source>DSC_MAXIMIZE_VIEW</source>
-        <translation>ビューの最大化</translation>
+      <source>DSC_MAXIMIZE_VIEW</source>
+      <translation>ビューの最大化</translation>
     </message>
     <message>
-        <source>DSC_MINIMIZE_VIEW</source>
-        <translation>ビューの最小化</translation>
+      <source>DSC_MINIMIZE_VIEW</source>
+      <translation>ビューの最小化</translation>
     </message>
     <message>
-        <source>DSC_RETURN_3D_VIEW</source>
-        <translation>3D view に戻る</translation>
+      <source>DSC_RETURN_3D_VIEW</source>
+      <translation>3D view に戻る</translation>
     </message>
     <message>
-        <source>MNU_MAXIMIZE_VIEW</source>
-        <translation>ビューの最大化</translation>
+      <source>MNU_MAXIMIZE_VIEW</source>
+      <translation>ビューの最大化</translation>
     </message>
     <message>
-        <source>MNU_MINIMIZE_VIEW</source>
-        <translation>ビューの最小化</translation>
+      <source>MNU_MINIMIZE_VIEW</source>
+      <translation>ビューの最小化</translation>
     </message>
     <message>
-        <source>MNU_RETURN_3D_VIEW</source>
-        <translation>3D に戻る</translation>
+      <source>MNU_RETURN_3D_VIEW</source>
+      <translation>3D に戻る</translation>
     </message>
-</context>
-<context>
+  </context>
+  <context>
     <name>OCCViewer_CreateRestoreViewDlg</name>
     <message>
-        <source>CAPTION</source>
-        <translation>ビューの読み込み</translation>
+      <source>CAPTION</source>
+      <translation>ビューの読み込み</translation>
     </message>
-</context>
-<context>
+  </context>
+  <context>
     <name>OCCViewer_SetRotationPointDlg</name>
     <message>
-        <source>LBL_X</source>
-        <translation>X:</translation>
+      <source>LBL_X</source>
+      <translation>X:</translation>
     </message>
     <message>
-        <source>LBL_Y</source>
-        <translation>Y:</translation>
+      <source>LBL_Y</source>
+      <translation>Y:</translation>
     </message>
     <message>
-        <source>LBL_Z</source>
-        <translation>Z:</translation>
+      <source>LBL_Z</source>
+      <translation>Z:</translation>
     </message>
     <message>
-        <source>USE_BBCENTER</source>
-        <translation>境界ボックスの中心を使用します。</translation>
+      <source>USE_BBCENTER</source>
+      <translation>境界ボックスの中心を使用します。</translation>
     </message>
     <message>
-        <source>LBL_TOORIGIN</source>
-        <translation>原点を設定</translation>
+      <source>LBL_TOORIGIN</source>
+      <translation>原点を設定</translation>
     </message>
     <message>
-        <source>CAPTION</source>
-        <translation>回転中心設定</translation>
+      <source>CAPTION</source>
+      <translation>回転中心設定</translation>
     </message>
     <message>
-        <source>LBL_SELECTPOINT</source>
-        <translation>ビューで、項目を選択します。</translation>
+      <source>LBL_SELECTPOINT</source>
+      <translation>ビューで、項目を選択します。</translation>
     </message>
-</context>
-<context>
+    <message>
+      <source>LBL_POINT</source>
+      <translation>点</translation>
+    </message>
+    <message>
+      <source>LBL_EDGE</source>
+      <translation>エッジ</translation>
+    </message>
+    <message>
+      <source>LBL_FACE</source>
+      <translation>面</translation>
+    </message>
+    <message>
+      <source>LBL_SOLID</source>
+      <translation>ソリッド</translation>
+    </message>
+  </context>
+  <context>
     <name>OCCViewer_ViewManager</name>
     <message>
-        <source>OCC_VIEW_TITLE</source>
-        <translation>シーン OCC: %M - ビューアー: %V</translation>
+      <source>OCC_VIEW_TITLE</source>
+      <translation>シーン OCC: %M - ビューアー: %V</translation>
     </message>
-</context>
-<context>
+  </context>
+  <context>
     <name>OCCViewer_Viewer</name>
     <message>
-        <source>MEN_DUMP_VIEW</source>
-        <translation>ビューの保存</translation>
+      <source>MEN_DUMP_VIEW</source>
+      <translation>ビューの保存</translation>
     </message>
     <message>
-        <source>MEN_SHOW_TOOLBAR</source>
-        <translation>ツールバーを表示</translation>
+      <source>MEN_SHOW_TOOLBAR</source>
+      <translation>ツールバーを表示</translation>
     </message>
     <message>
-        <source>MEN_CHANGE_BACKGROUND</source>
-        <translation>背景の変更</translation>
+      <source>MEN_CHANGE_BACKGROUND</source>
+      <translation>背景の変更</translation>
     </message>
     <message>
-        <source>MEN_CHANGE_IMAGE</source>
-        <translation>背景画像の設定/変更</translation>
+      <source>MEN_CHANGE_IMAGE</source>
+      <translation>背景画像の設定/変更</translation>
     </message>
     <message>
-        <source>SELECT_IMAGE</source>
-        <translation>イメージの選択</translation>
+      <source>SELECT_IMAGE</source>
+      <translation>イメージの選択</translation>
     </message>
     <message>
-        <source>CENTERED</source>
-        <translation>中心のモード</translation>
+      <source>CENTERED</source>
+      <translation>中心のモード</translation>
     </message>
     <message>
-        <source>TILED</source>
-        <translation>テンキー モード</translation>
+      <source>TILED</source>
+      <translation>テンキー モード</translation>
     </message>
     <message>
-        <source>STRETCHED</source>
-        <translation>ストレッチ モード</translation>
+      <source>STRETCHED</source>
+      <translation>ストレッチ モード</translation>
     </message>
     <message>
-        <source>GT_HORIZONTALGRADIENT</source>
-        <translation>水平方向のグラデーション</translation>
+      <source>GT_HORIZONTALGRADIENT</source>
+      <translation>水平方向のグラデーション</translation>
     </message>
     <message>
-        <source>GT_VERTICALGRADIENT</source>
-        <translation>垂直方向のグラデーション</translation>
+      <source>GT_VERTICALGRADIENT</source>
+      <translation>垂直方向のグラデーション</translation>
     </message>
     <message>
-        <source>GT_FIRSTDIAGONALGRADIENT</source>
-        <translation>最初の斜めのグラデーション</translation>
+      <source>GT_FIRSTDIAGONALGRADIENT</source>
+      <translation>最初の斜めのグラデーション</translation>
     </message>
     <message>
-        <source>GT_SECONDDIAGONALGRADIENT</source>
-        <translation>2 番目の斜めのグラデーション</translation>
+      <source>GT_SECONDDIAGONALGRADIENT</source>
+      <translation>2 番目の斜めのグラデーション</translation>
     </message>
     <message>
-        <source>GT_FIRSTCORNERGRADIENT</source>
-        <translation>最初のコーナーのグラデーション</translation>
+      <source>GT_FIRSTCORNERGRADIENT</source>
+      <translation>最初のコーナーのグラデーション</translation>
     </message>
     <message>
-        <source>GT_SECONDCORNERGRADIENT</source>
-        <translation>グラデーションの 2 番目の角</translation>
+      <source>GT_SECONDCORNERGRADIENT</source>
+      <translation>グラデーションの 2 番目の角</translation>
     </message>
     <message>
-        <source>GT_THIRDCORNERGRADIENT</source>
-        <translation>3 番目の角勾配</translation>
+      <source>GT_THIRDCORNERGRADIENT</source>
+      <translation>3 番目の角勾配</translation>
     </message>
     <message>
-        <source>GT_FORTHCORNERGRADIENT</source>
-        <translation>第 4 コーナー グラデーション</translation>
+      <source>GT_FORTHCORNERGRADIENT</source>
+      <translation>第 4 コーナー グラデーション</translation>
     </message>
     <message>
-        <source>BG_IMAGE_FILES</source>
-        <translation>イメージ ファイル (*.bmp *.gif *.pix *.xwd *.rgb * .rs)</translation>
+      <source>BG_IMAGE_FILES</source>
+      <translation>イメージ ファイル (*.bmp *.gif *.pix *.xwd *.rgb * .rs)</translation>
     </message>
-</context>
-<context>
+  </context>
+  <context>
     <name>OCCViewer_AxialScaleDlg</name>
     <message>
-        <source>DLG_SCALING</source>
-        <translation>スケールの変更</translation>
+      <source>DLG_SCALING</source>
+      <translation>スケールの変更</translation>
     </message>
     <message>
-        <source>LBL_X</source>
-        <translation>X:</translation>
+      <source>LBL_X</source>
+      <translation>X:</translation>
     </message>
     <message>
-        <source>LBL_Y</source>
-        <translation>Y:</translation>
+      <source>LBL_Y</source>
+      <translation>Y:</translation>
     </message>
     <message>
-        <source>LBL_Z</source>
-        <translation>Z:</translation>
+      <source>LBL_Z</source>
+      <translation>Z:</translation>
     </message>
-</context>
-<context>
+  </context>
+  <context>
     <name>OCCViewer_ClippingDlg</name>
     <message>
-        <source>CLIPPING_PLANES</source>
-        <translation>平面の切り抜き</translation>
+      <source>CLIPPING_PLANES</source>
+      <translation>平面の切り抜き</translation>
     </message>
     <message>
-        <source>NO_PLANES</source>
-        <translation>平面がない</translation>
+      <source>NO_PLANES</source>
+      <translation>平面がない</translation>
     </message>
     <message>
-        <source>IS_ACTIVE_PLANE</source>
-        <translation>アクティブな平面</translation>
+      <source>IS_ACTIVE_PLANE</source>
+      <translation>アクティブな平面</translation>
     </message>
     <message>
-        <source>BTN_NEW</source>
-        <translation>新規</translation>
+      <source>BTN_NEW</source>
+      <translation>新規</translation>
     </message>
     <message>
-        <source>BTN_DELETE</source>
-        <translation>削除</translation>
+      <source>BTN_DELETE</source>
+      <translation>削除</translation>
     </message>
     <message>
-        <source>AUTO_APPLY</source>
-        <translation>自動適用</translation>
+      <source>AUTO_APPLY</source>
+      <translation>自動適用</translation>
     </message>
     <message>
-        <source>MODE</source>
-        <translation>モード</translation>
+      <source>MODE</source>
+      <translation>モード</translation>
     </message>
     <message>
-        <source>ORIENTATION</source>
-        <translation>方向</translation>
+      <source>ORIENTATION</source>
+      <translation>方向</translation>
     </message>
     <message>
-        <source>DISTANCE</source>
-        <translation>距離</translation>
+      <source>DISTANCE</source>
+      <translation>距離</translation>
     </message>
     <message>
-        <source>ROTATION_AROUND_X_Y2Z</source>
-        <translation>X軸周りに回転(Y軸からZ軸へ)</translation>
+      <source>ROTATION_AROUND_X_Y2Z</source>
+      <translation>X軸周りに回転(Y軸からZ軸へ)</translation>
     </message>
     <message>
-        <source>ROTATION_AROUND_Y_X2Z</source>
-        <translation>Y軸周りに回転(X軸からZ軸へ)</translation>
+      <source>ROTATION_AROUND_Y_X2Z</source>
+      <translation>Y軸周りに回転(X軸からZ軸へ)</translation>
     </message>
     <message>
-        <source>ROTATION_AROUND_Z_Y2X</source>
-        <translation>Z軸周りに回転(Y軸からX軸へ)</translation>
+      <source>ROTATION_AROUND_Z_Y2X</source>
+      <translation>Z軸周りに回転(Y軸からX軸へ)</translation>
     </message>
     <message>
-        <source>ROTATION_AROUND_X_Z2Y</source>
-        <translation>X軸周りに回転(Z軸からY軸へ)</translation>
+      <source>ROTATION_AROUND_X_Z2Y</source>
+      <translation>X軸周りに回転(Z軸からY軸へ)</translation>
     </message>
     <message>
-        <source>ROTATION_AROUND_Y_Z2X</source>
-        <translation>Y軸周りに回転(Z軸からX軸へ)</translation>
+      <source>ROTATION_AROUND_Y_Z2X</source>
+      <translation>Y軸周りに回転(Z軸からX軸へ)</translation>
     </message>
     <message>
-        <source>ROTATION_AROUND_Z_X2Y</source>
-        <translation>Z軸周りに回転(X軸からY軸へ)</translation>
+      <source>ROTATION_AROUND_Z_X2Y</source>
+      <translation>Z軸周りに回転(X軸からY軸へ)</translation>
     </message>
     <message>
-        <source>ALONG_XY</source>
-        <translation>XY平面に平行</translation>
+      <source>ALONG_XY</source>
+      <translation>XY平面に平行</translation>
     </message>
     <message>
-        <source>ALONG_YZ</source>
-        <translation>YZ平面に平行</translation>
+      <source>ALONG_YZ</source>
+      <translation>YZ平面に平行</translation>
     </message>
     <message>
-        <source>ALONG_ZX</source>
-        <translation>ZX平面に平行</translation>
+      <source>ALONG_ZX</source>
+      <translation>ZX平面に平行</translation>
     </message>
     <message>
-        <source>ABSOLUTE</source>
-        <translation>絶対</translation>
+      <source>ABSOLUTE</source>
+      <translation>絶対</translation>
     </message>
     <message>
-        <source>RELATIVE</source>
-        <translation>相対</translation>
+      <source>RELATIVE</source>
+      <translation>相対</translation>
     </message>
     <message>
-        <source>BTN_DISABLE_ALL</source>
-        <translation>すべて無効</translation>
+      <source>BTN_DISABLE_ALL</source>
+      <translation>すべて無効</translation>
     </message>
     <message>
-        <source>PREVIEW</source>
-        <translation>プレビュー</translation>
+      <source>PREVIEW</source>
+      <translation>プレビュー</translation>
     </message>
     <message>
-        <source>RESET</source>
-        <translation>リセット</translation>
+      <source>RESET</source>
+      <translation>リセット</translation>
     </message>
     <message>
-        <source>INVERT</source>
-        <translation>反転</translation>
+      <source>INVERT</source>
+      <translation>反転</translation>
     </message>
     <message>
-        <source>BASE_POINT</source>
-        <translation>基準点</translation>
+      <source>BASE_POINT</source>
+      <translation>基準点</translation>
     </message>
     <message>
-        <source>DIRECTION</source>
-        <translation>方向</translation>
+      <source>DIRECTION</source>
+      <translation>方向</translation>
     </message>
     <message>
-        <source>PARAMETERS</source>
-        <translation>パラメータ</translation>
+      <source>PARAMETERS</source>
+      <translation>パラメータ</translation>
     </message>
-</context>
+  </context>
 </TS>
index 79c863e0646a711743f0b644c5ca2458ee03f44e..5c018abada7ad3479025d9dfa6a61fa503e66a7d 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!DOCTYPE TS>
-<TS>
+<TS version="2.0" language="ja" sourcelanguage="en">
   <context>
     <name>OB_Browser</name>
     <message>
index df128be766b36eaa57cc039234c0f87d26446b08..ef7abf737554ee7dd4f78e548849ee1faeebc4b6 100755 (executable)
@@ -529,7 +529,7 @@ bool Plot2d::existMarker( const int rtti, const QwtPlot* thePlot, const QwtSymbo
       if ( anItem && anItem->rtti() == rtti ) {
        QwtPlotCurve* crv = dynamic_cast<QwtPlotCurve*>( anItem );
        if ( crv ) {
-         QwtSymbol::Style aStyle = crv->symbol().style();
+         QwtSymbol::Style aStyle = crv->symbol()->style();
          QColor           aColor = crv->pen().color();
          Qt::PenStyle     aLine  = crv->pen().style();
          ok = closeColors( aColor, color ) && aStyle == typeMarker && aLine == typeLine;
index 3ce359999f3bcb07eaeaf18d66a7fc2da0714186..56fa70e4c33b26bf28a2254d8fb421becb23491a 100755 (executable)
@@ -37,7 +37,9 @@
 #endif
 
 #include <qwt_symbol.h>
-#include <Qt>
+#include <QString>
+#include <QColor>
+#include <QPixmap>
 
 class QPainter;
 class QwtPlot;
index e769da386b4b9ec205df1235d2048c9c0a8a0c7f..539547ebf76e545bc97ebb7d9a6624be66809285 100755 (executable)
@@ -165,18 +165,18 @@ void Plot2d_AnalyticalCurve::updatePlotItem()
   aCurve->setSelected(isSelected());
 
   aCurve->setPen( QPen(aColor , lineW, ps ) );
-  aCurve->setSymbol( QwtSymbol( ms, QBrush( aColor ), 
-                               QPen( aColor ), 
-                               QSize( markerS , markerS ) ) );
+  aCurve->setSymbol( new QwtSymbol( ms, QBrush( aColor ),
+                                    QPen( aColor ),
+                                    QSize( markerS , markerS ) ) );
 
   aCurve->setLegendPen(QPen(getColor(), getLineWidth(), ps ));
-  aCurve->setLegendSymbol( QwtSymbol( ms, QBrush( getColor() ), 
-                                     QPen( getColor() ), 
-                                     QSize( getMarkerSize() , getMarkerSize() )));
+  aCurve->setLegendSymbol( new QwtSymbol( ms, QBrush( getColor() ),
+                                          QPen( getColor() ),
+                                          QSize( getMarkerSize() , getMarkerSize() )));
 
   double *x, *y;
   long nb = getData( &x, &y );
-  aCurve->setData( x, y, nb );
+  aCurve->setSamples( x, y, nb );
   aCurve->setTitle(getName());
 }
 
@@ -213,10 +213,10 @@ void Plot2d_AnalyticalCurve::calculate() {
 */
 bool Plot2d_AnalyticalCurve::checkCurve( const QwtPlot* thePlot) {
   if( !myExpression.isEmpty() && thePlot ) {
-       const QwtScaleDiv* div = thePlot->axisScaleDiv(QwtPlot::xBottom);
-       setRangeBegin(div->lowerBound());
-       setRangeEnd(div->upperBound());
-       calculate();
+    const QwtScaleDiv div = thePlot->axisScaleDiv(QwtPlot::xBottom);
+    setRangeBegin(div.lowerBound());
+    setRangeEnd(div.upperBound());
+    calculate();
   }
   return myState == Plot2d_AnalyticalCurve::StateOk;
 }
index 8e029c32b8d96147650ec3011bd9518d848df690..4b7f8878eea113c3b29816a2434f86234a0b071c 100755 (executable)
@@ -135,19 +135,19 @@ void Plot2d_Curve::updatePlotItem( QwtPlotItem* theItem )
   aCurve->setSelected(isSelected());
 
   aCurve->setPen( QPen(aColor , lineW, ps ) );
-  aCurve->setSymbol( QwtSymbol( ms, QBrush( aColor ), 
-                               QPen( aColor ), 
-                               QSize( markerS , markerS ) ) );
+  aCurve->setSymbol( new QwtSymbol( ms, QBrush( aColor ), 
+                                    QPen( aColor ),
+                                    QSize( markerS , markerS ) ) );
 
   aCurve->setLegendPen(QPen(getColor(), getLineWidth(), ps ));
-  aCurve->setLegendSymbol( QwtSymbol( ms, QBrush( getColor() ), 
-                                     QPen( getColor() ), 
-                                     QSize( getMarkerSize() , getMarkerSize() )));
+  aCurve->setLegendSymbol( new QwtSymbol( ms, QBrush( getColor() ),
+                                          QPen( getColor() ),
+                                          QSize( getMarkerSize() , getMarkerSize() )));
   
   double *x, *y, *min, *max;
   long nb = getData( &x, &y );
   if(nb > 0 && x && y) {
-    aCurve->setData( x, y, nb );
+    aCurve->setSamples( x, y, nb );
     delete [] x;
     delete [] y;
     QList<int> idx;
@@ -160,7 +160,7 @@ void Plot2d_Curve::updatePlotItem( QwtPlotItem* theItem )
       aCurve->clearDeviationData();
     }
   } else {
-    aCurve->setData( NULL, NULL, 0 );
+    aCurve->setSamples( NULL, NULL, 0 );
   }
 }
 
index 06e2ef1fd0cf00d86437a36540ee3d15ff42ee9b..d17361bb8f305159b459787afdc092c2e13be47a 100644 (file)
@@ -135,22 +135,20 @@ void Plot2d_Histogram::setData( const QList<double>& theXVals,
 /*!
   Gets data
 */
-QwtIntervalData Plot2d_Histogram::getData() const
+QwtIntervalSeriesData Plot2d_Histogram::getData() const
 {
   pointList aPoints = getPointList();
   int aSize = aPoints.size();
 
-  QwtArray<QwtDoubleInterval> anIntervals( aSize );
-  QwtArray<double> aValues( aSize );
+  QwtArray<QwtIntervalSample> anIntervals( aSize );
   double aX;
   double aWidth = myWidth <= 0 ? myDefWidth : myWidth; // VSR: width is either manually assigned or auto-calculated
   for ( int i = 0; i < aSize; i++ ) {
     aX = aPoints[i].x;
-    anIntervals[i] = QwtDoubleInterval( aX - aWidth/2, aX + aWidth/2 );
-    aValues[i] = aPoints[i].y;
+    anIntervals[i] = QwtIntervalSample( aPoints[i].y, aX - aWidth/2, aX + aWidth/2 );
   }
 
-  return QwtIntervalData( anIntervals, aValues );
+  return QwtIntervalSeriesData( anIntervals );
 }
 
 /*!
index f5d5370a1f70f61ab8d7748d0ba211d02bfac39d..0e4b319e64ad4b0fe9cdf58ed263480adb6bc3f0 100644 (file)
@@ -28,7 +28,7 @@
 #include "Plot2d.h"
 #include "Plot2d_Object.h"
 
-#include <qwt_interval_data.h>
+#include <qwt_series_data.h>
 
 class PLOT2D_EXPORT Plot2d_Histogram : public Plot2d_Object
 {
@@ -39,30 +39,30 @@ public:
   virtual ~Plot2d_Histogram();
   Plot2d_Histogram& operator= ( const Plot2d_Histogram& );
 
-  virtual int          rtti();
-  virtual QwtPlotItem* createPlotItem();
-  virtual void         autoFill( const QwtPlot* );
-  virtual void         updatePlotItem( QwtPlotItem* );
+  virtual int           rtti();
+  virtual QwtPlotItem*  createPlotItem();
+  virtual void          autoFill( const QwtPlot* );
+  virtual void          updatePlotItem( QwtPlotItem* );
 
-  void                 setData( const QList<double>&, const QList<double>& );
-  QwtIntervalData      getData() const;
+  void                  setData( const QList<double>&, const QList<double>& );
+  QwtIntervalSeriesData getData() const;
 
-  void                 setColor( const QColor& );
-  QColor               getColor() const;
+  void                  setColor( const QColor& );
+  QColor                getColor() const;
 
-  void                 setWidth( const double );
-  double               getWidth( const bool ) const;
+  void                  setWidth( const double );
+  double                getWidth( const bool ) const;
 
-  static double        getMinInterval( const QList<double>& );
+  static double         getMinInterval( const QList<double>& );
 
 protected:
-  QColor               getNextColor( const QwtPlot* );
-  bool                 existColor( const QwtPlot*, const QColor& );
+  QColor                getNextColor( const QwtPlot* );
+  bool                  existColor( const QwtPlot*, const QColor& );
 
 private:
-  QColor               myColor;
-  double               myWidth;
-  double               myDefWidth;
+  QColor                myColor;
+  double                myWidth;
+  double                myDefWidth;
 };
 
 #endif // PLOT2D_HISTOGRAM_H
index bb11956b4a25da1eb14ecddc52f20a99d3d0bce4..3315c46c2b124a1ce612c370783a7f4b71fa21b1 100755 (executable)
 
 #include "Plot2d_Object.h"
 
-#ifndef NO_SUIT
-#include <SUIT_Session.h>
-#include <SUIT_ResourceMgr.h>
-#endif
-
 // Static members
 QColor Plot2d_Object::mySelectionColor;
 QColor Plot2d_Object::myHighlightedLegendTextColor;
 
-/*
- * Read colors from the resource manager.
-*/
-void Plot2d_Object::initColors() {
-#ifndef NO_SUIT
-  SUIT_Session* session = SUIT_Session::session();
-  if(!session)
-    return;
-
-  SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
-  if(resMgr) {
-    mySelectionColor = resMgr->colorValue( "Plot2d", "SelectionColor", QColor(80,80,80) );
-    myHighlightedLegendTextColor = resMgr->colorValue( "Plot2d", "SelectedLegendFontColor", QColor(255,255,255) );
-  }
-#else
-  mySelectionColor = QColor(80,80,80);
-  myHighlightedLegendTextColor = QColor(255,255,255);
-#endif
-}
 
 /*!
   Constructor
@@ -127,7 +103,7 @@ void Plot2d_Object::updatePlotItem( QwtPlotItem* theItem )
     return;
 
   if ( theItem->yAxis() != getYAxis() || theItem->xAxis() != getXAxis() ) {
-    theItem->setAxis( getXAxis(), getYAxis() );
+    theItem->setAxes( getXAxis(), getYAxis() );
 
     QwtPlot* aPlot = theItem->plot();
     if ( aPlot ) {
index a0c4740f415142dddc07f0f85ad914b99524c65c..5820a2a19c91c00185bba3771738d95063b959b8 100755 (executable)
@@ -105,8 +105,6 @@ public:
   void                 setSelected(const bool);
   bool                 isSelected() const;
   
-  static void initColors();
-  
   static void   setSelectionColor(const QColor& c);
   static QColor selectionColor();
 
index b477a08f6d8dab90f0b92fa29b9d24f121b20026..a2222caa553ce03cfc55d44cd2c3ead0d106032c 100644 (file)
 
 #include "Plot2d_PlotItems.h"
 #include "Plot2d_Object.h"
+#include "Plot2d_ViewFrame.h"
 
 #include <QPainter>
 #include <QPalette>
 #include <QLayout>
 #include <QLine>
 #include <QVariant>
+#include <QStyleOption>
+#include <QPaintEvent>
 #include <qwt_plot.h>
 #include <qwt_painter.h>
 #include <qwt_scale_map.h>
 #include <qwt_legend.h>
-#include <qwt_legend_item.h>
+#include <qwt_legend_label.h>
 #include <qwt_plot_dict.h>
 
+const int SPACING = 10;
+const int SYMBOL_SIZE = 13;
+
 const char* yAxisLeft[] = {
   "12 12 2 1",
   "  c None",
@@ -72,44 +78,69 @@ const char* yAxisRight[] = {
   "            "};
 
 /*!
-  Constructor of Plot2d_QwtLegendItem
+  Constructor of Plot2d_QwtLegendLabel
 */
-Plot2d_QwtLegendItem::Plot2d_QwtLegendItem( QWidget* parent ) :
-  QwtLegendItem( parent ),
+Plot2d_QwtLegendLabel::Plot2d_QwtLegendLabel( QWidget* parent ) :
+  QwtLegendLabel( parent ),
   myYAxisIdentifierMode( IM_None ),
-  myIsSelected(false)
+  myIsSelected(false),
+  mySymbol( new QwtSymbol() ),
+  mySymbolType(0),
+  myPen( QPen() )
 {
   myYAxisLeftIcon = yAxisLeft;
   myYAxisRightIcon = yAxisRight;
   int anIconWidth = qMax( myYAxisLeftIcon.width(), myYAxisRightIcon.width() );
+  setSpacing( SPACING );
 
   mySpacingCollapsed = spacing();
-  mySpacingExpanded = anIconWidth - mySpacingCollapsed;
+  mySpacingExpanded = anIconWidth + mySpacingCollapsed;
 }
 
 /*!
-  Destructor of Plot2d_QwtLegendItem
+  Destructor of Plot2d_QwtLegendLabel
 */
-Plot2d_QwtLegendItem::~Plot2d_QwtLegendItem()
+Plot2d_QwtLegendLabel::~Plot2d_QwtLegendLabel()
 {
 }
 
 /*!
   Set Y axis identifier displaying mode
 */
-void Plot2d_QwtLegendItem::setYAxisIdentifierMode( const int theMode )
+void Plot2d_QwtLegendLabel::setYAxisIdentifierMode( const int theMode )
 {
   myYAxisIdentifierMode = theMode;
   setSpacing( theMode == IM_None ? mySpacingCollapsed : mySpacingExpanded );
 }
 
 /*!
-  Redefined method of drawing identifier of legend item
+  Paint the identifier to a given rect.
+  \param painter Painter
+  \param rect Rect where to paint
 */
-void Plot2d_QwtLegendItem::drawIdentifier( QPainter* painter, const QRect& rect ) const
+void Plot2d_QwtLegendLabel::drawIdentifier( QPainter* painter, const QRect& rect )
 {
-  QwtLegendItem::drawIdentifier( painter, rect );
+  if ( rect.isEmpty() )
+    return;
 
+  if( myPen.style() != Qt::NoPen ) {
+    painter->save();
+    painter->setPen(myPen);
+    QwtPainter::drawLine( painter, rect.left() - 2, rect.center().y() + mySymbolType * 4,
+                                   rect.right() + 2, rect.center().y() + mySymbolType * 4 );
+    painter->restore();
+  }
+  if ( mySymbol->style() != QwtSymbol::NoSymbol )
+  {
+    QRect symbolRect;
+    symbolRect.setSize( QSize( SYMBOL_SIZE, SYMBOL_SIZE ) );
+    symbolRect.moveCenter( QPoint( rect.center().x(), rect.center().y() - mySymbolType * 4 ) );
+    painter->save();
+    painter->setBrush( mySymbol->brush() );
+    painter->setPen( mySymbol->pen() );
+    mySymbol->drawSymbol( painter, symbolRect );
+    painter->restore();
+  }
   if( myYAxisIdentifierMode != IM_None ) {
     QPixmap aPixmap( myYAxisIdentifierMode == IM_Left ? yAxisLeft : yAxisRight );
     painter->save();
@@ -121,19 +152,22 @@ void Plot2d_QwtLegendItem::drawIdentifier( QPainter* painter, const QRect& rect
 /*!
   Update highliting on the item.
 */
-void Plot2d_QwtLegendItem::updateHighlit() {
+void Plot2d_QwtLegendLabel::updateHighlit() {
   QwtText txt = text();
-  if(isSelected()) {
+  if( isSelected() ) {
     QColor highlightColor = Plot2d_Object::selectionColor();
-    if(highlightColor != txt.backgroundBrush().color()) {
-      txt.setBackgroundBrush(highlightColor);
+    if( highlightColor != txt.backgroundBrush().color() ) {
+      txt.setBackgroundBrush( highlightColor  );
       setText(txt);
     }
-  } else if( QWidget* parent = qobject_cast<QWidget*>(this->parent()->parent()) ) {
-    QPalette aPal = parent->palette();
-    if(aPal.color(QPalette::Background) != txt.backgroundBrush().color()) {
-      txt.setBackgroundBrush(aPal.color(QPalette::Background));
-      setText(txt);
+  }
+  else if( this->parent() ) {
+    if(QWidget* parent = qobject_cast<QWidget*>( this->parent()->parent() ) ) {
+      QPalette aPal = parent->palette();
+      if( aPal.color( QPalette::Background) != txt.backgroundBrush().color() ) {
+        txt.setBackgroundBrush( aPal.color( QPalette::Background ) );
+        setText( txt );
+      }
     }
   }
 }
@@ -141,14 +175,14 @@ void Plot2d_QwtLegendItem::updateHighlit() {
 /*!
   Sets selected property.
 */
-void Plot2d_QwtLegendItem::setSelected(const bool on) {
+void Plot2d_QwtLegendLabel::setSelected(const bool on) {
   myIsSelected = on;
 }
 
 /*!
   Gets selected property.
 */
-bool Plot2d_QwtLegendItem::isSelected() const {
+bool Plot2d_QwtLegendLabel::isSelected() const {
   return myIsSelected;
 }
 
@@ -156,17 +190,79 @@ bool Plot2d_QwtLegendItem::isSelected() const {
 /*
   Draw text of the item.
 */
-void  Plot2d_QwtLegendItem::drawText(QPainter * painter, const QRect &rect) {
+void  Plot2d_QwtLegendLabel::drawText( QPainter * painter, const QRectF &rect ) {
   painter->setPen( isSelected() ? Plot2d_Object::highlightedLegendTextColor() :
-                  getColorFromPalette( QPalette::Text) );
+                   getColorFromPalette( QPalette::Text) );
 
-  QwtLegendItem::drawText( painter, rect );
+  QwtTextLabel::drawText( painter, rect );
+}
+
+/*!
+  Sets symbol.
+*/
+void Plot2d_QwtLegendLabel::setSymbol( const QwtSymbol* theSymbol )
+{
+  mySymbol = new QwtSymbol( theSymbol->style(), theSymbol->brush(),
+                            theSymbol->pen(), theSymbol->size() );
+}
+
+/*!
+  Sets symbol type 0(marker on line) or 1(marker above line).
+*/
+void Plot2d_QwtLegendLabel::setSymbolType( const int theType )
+{
+  mySymbolType = theType;
+}
+
+/*!
+  Sets pen.
+*/
+void Plot2d_QwtLegendLabel::setPen (const QPen& thePen )
+{
+  myPen = thePen;
+}
+
+/*!
+  Redefined method paintEvent of QwtLegendLabel
+*/
+void Plot2d_QwtLegendLabel::paintEvent( QPaintEvent *e )
+{
+  const QRect cr = contentsRect();
+
+  int ButtonFrame = 6;
+  QPainter painter( this );
+  painter.setClipRegion( e->region() );
+
+  if ( isDown() )
+  {
+    qDrawWinButton( &painter, 0, 0, width(), height(),
+                    palette(), true );
+  }
+
+  painter.save();
+  painter.setClipRect( cr );
+
+  drawContents( &painter );
+
+  QRect iconRect = cr;
+  if ( !icon().isNull() )
+  {
+    if ( itemMode() != QwtLegendData::ReadOnly )
+      iconRect.setX( iconRect.x() + ButtonFrame );
+      iconRect.setSize( QSize( icon().size().width() + spacing() ,
+                                  icon().size().height() + spacing() ) );
+      iconRect.moveCenter( QPoint( iconRect.center().x(), cr.center().y() ) );
+  }
+
+  drawIdentifier( &painter, iconRect );
+
+  painter.restore();
 }
 
 /*
   Get color from the legend pallete by 'role' flag.
 */
-QColor Plot2d_QwtLegendItem::getColorFromPalette(QPalette::ColorRole role) {
+QColor Plot2d_QwtLegendLabel::getColorFromPalette(QPalette::ColorRole role) {
   QWidget* pw = parentWidget();
   QColor  col = palette().color( role );
   while( pw ) {
@@ -242,72 +338,63 @@ void Plot2d_QwtPlotCurve::setYAxisIdentifierEnabled( const bool on )
 /*!
   Redefined method, which updates legend of the curve
 */
-void Plot2d_QwtPlotCurve::updateLegend( QwtLegend* legend ) const
+void Plot2d_QwtPlotCurve::updateLegend( const QwtPlotItem* thePlotItem,
+                                        const QList<QwtLegendData>& theLegendData )
 {
-  if ( !legend )
+  if ( !thePlotItem || !thePlotItem->plot() )
     return;
 
-  QWidget* widget = legend->find( this );
-
-  if ( testItemAttribute(QwtPlotItem::Legend) ) {
-
-    if ( widget == NULL ) {
-      widget = legendItem();
-      if ( widget ) {
-       if ( widget->inherits("QwtLegendItem") ) {
-         QwtLegendItem *label = (QwtLegendItem *)widget;
-         label->setItemMode(legend->itemMode());
-
-         if ( plot() ) {
-           QObject::connect(label, SIGNAL(clicked()),
-                            plot(), SLOT(legendItemClicked()));
-           QObject::connect(label, SIGNAL(checked(bool)),
-                            plot(), SLOT(legendItemChecked(bool)));
-         }
-       }
-       legend->contentsWidget()->layout()->addWidget(widget);
-       legend->insert(this, widget);
-      }
-    }
-
-    QwtPlotCurve::updateLegend( legend );
-
+  if ( !testItemAttribute( QwtPlotItem::Legend ) )
+    return;
 
-    if( Plot2d_QwtLegendItem* anItem = dynamic_cast<Plot2d_QwtLegendItem*>( widget ) ) {
-      int aMode = Plot2d_QwtLegendItem::IM_None;
-      if( myYAxisIdentifierEnabled )
-       aMode = myYAxis == QwtPlot::yRight ?
-         Plot2d_QwtLegendItem::IM_Right :
-         Plot2d_QwtLegendItem::IM_Left;
-      anItem->setYAxisIdentifierMode( aMode );
-      if(isSelected()) {
-       anItem->setCurvePen(legendPen());
-       anItem->setSymbol(legendSymbol());
-      }
-      anItem->setSelected(isSelected());
-      anItem->updateHighlit();
-    }
+  QwtPlotCurve::updateLegend( thePlotItem, theLegendData );
+
+  const QVariant itemInfo = thePlotItem->plot()->itemToInfo( const_cast< QwtPlotItem *>( thePlotItem ) );
+  QwtLegend* legend = dynamic_cast<QwtLegend*>( thePlotItem->plot()->legend() );
+  QWidget* widget = legend->legendWidget( itemInfo );
+  QwtLegendLabel* label = dynamic_cast<QwtLegendLabel*>( widget );
+  if( Plot2d_QwtLegendLabel* anItem = (Plot2d_QwtLegendLabel*)label ) {
+    int aMode = Plot2d_QwtLegendLabel::IM_None;
+    if( myYAxisIdentifierEnabled )
+      aMode = myYAxis == QwtPlot::yRight ?
+              Plot2d_QwtLegendLabel::IM_Right :
+              Plot2d_QwtLegendLabel::IM_Left;
+    anItem->setYAxisIdentifierMode( aMode );
+
+    anItem->setSymbol( legendSymbol() );
+    if( Plot2d_Plot2d* plot = dynamic_cast<Plot2d_Plot2d*>( thePlotItem->plot() ) )
+      anItem->setSymbolType( plot->getLegendSymbolType() );
+    anItem->setPen( legendPen() );
+
+    anItem->setSelected( isSelected() );
+    anItem->updateHighlit();
+    anItem->repaint();
   }
 }
 
 /*!
-  Redefined method, which creates and returns legend item of the curve
+  Redefined method, which updates and calls QwtPlot::autoRefresh() for the parent plot
 */
-QWidget* Plot2d_QwtPlotCurve::legendItem() const
+void Plot2d_QwtPlotCurve::itemChanged()
 {
-  return new Plot2d_QwtLegendItem;
+  if ( plot() )
+    updateLegend( this, legendData() );
+
+  QwtPlotItem::itemChanged();
 }
 
 /*!
   Redefined method, which draw a set of points of a curve.
 */
-void Plot2d_QwtPlotCurve::draw(QPainter *painter,
-                               const QwtScaleMap &xMap, const QwtScaleMap &yMap,
-                               int from, int to) const
+void Plot2d_QwtPlotCurve::drawSeries( QPainter *painter,
+                                      const QwtScaleMap &xMap,
+                                      const QwtScaleMap &yMap,
+                                      const QRectF &canvasRect,
+                                      int from, int to) const
 {
   if (to < 0)
     to = dataSize() - 1;
-  QwtPlotCurve::draw(painter, xMap, yMap, from, to);
+  QwtPlotCurve::drawSeries(painter, xMap, yMap, canvasRect, from, to);
 
   //draw deviation data
   if(hasDeviationData()) {
@@ -321,8 +408,9 @@ void Plot2d_QwtPlotCurve::draw(QPainter *painter,
     painter->setPen(p);
     for (int i = from; i <= to; i++) {
       if(!myDeviationData->values(i,min,max)) continue;
-      xi = x(i);
-      yi = y(i);
+      const QPointF sample = data()->sample( i );
+      xi = sample.x();
+      yi = sample.y();
       xp = xMap.transform(xi);
       ytop = yMap.transform(yi + max);
       ybtm = yMap.transform(yi - min);
@@ -406,7 +494,9 @@ void Plot2d_QwtPlotCurve::clearDeviationData()
   Constructor.
 */
 Plot2d_SelectableItem::Plot2d_SelectableItem():
-  myIsSelected(false)
+  myIsSelected(false),
+  myLegendSymbol( new QwtSymbol() ),
+  myLegendPen( QPen() )
 {
 }
 
@@ -448,15 +538,19 @@ QPen Plot2d_SelectableItem::legendPen() const {
 /*!
   Sets legend symbol property.
 */
-void Plot2d_SelectableItem::setLegendSymbol(const QwtSymbol& s) {
-  myLegendSymbol = s;
+void Plot2d_SelectableItem::setLegendSymbol( const QwtSymbol* s ) {
+  myLegendSymbol->setStyle( s->style() );
+  myLegendSymbol->setBrush( s->brush() );
+  myLegendSymbol->setPen( s->pen() );
+  myLegendSymbol->setSize( s->size() );
 }
 
 /*!
   Sets legend symbol property.
 */
-QwtSymbol Plot2d_SelectableItem::legendSymbol() const {
-  return myLegendSymbol;
+QwtSymbol* Plot2d_SelectableItem::legendSymbol() const {
+  return new QwtSymbol( myLegendSymbol->style(), myLegendSymbol->brush(),
+                        myLegendSymbol->pen(), myLegendSymbol->size() );
 }
 
 /*!
@@ -521,16 +615,16 @@ double Plot2d_HistogramQwtItem::baseline() const
 /*!
   Sets data to object
 */
-void Plot2d_HistogramQwtItem::setData( const QwtIntervalData& theData )
+void Plot2d_HistogramQwtItem::setData( const QwtIntervalSeriesData& theData )
 {
-  myData = theData;
+  myData.setSamples( theData.samples() );
   itemChanged();
 }
 
 /*!
   Returns data from object
 */
-const QwtIntervalData& Plot2d_HistogramQwtItem::data() const
+const QwtIntervalSeriesData& Plot2d_HistogramQwtItem::data() const
 {
   return myData;
 }
@@ -618,7 +712,7 @@ bool Plot2d_HistogramQwtItem::testHistogramAttribute( HistogramAttribute theAttr
 void Plot2d_HistogramQwtItem::draw( QPainter* thePainter,
                                    const QwtScaleMap& theXMap,
                                    const QwtScaleMap& theYMap,
-                                   const QRect& ) const
+                                   const QRectF& ) const
 {
   thePainter->setPen( QPen( myColor ) );
 
@@ -627,19 +721,19 @@ void Plot2d_HistogramQwtItem::draw( QPainter* thePainter,
 
   for ( int i = 0; i < (int)myData.size(); i++ ) {
     if ( myAttributes & Plot2d_HistogramQwtItem::Xfy ) {
-      const int x2 = theXMap.transform( myData.value( i ) );
+      const int x2 = theXMap.transform( myData.sample(i).value );
       if ( x2 == x0 )
         continue;
-      int y1 = theYMap.transform( myData.interval( i ).minValue() );
-      int y2 = theYMap.transform( myData.interval( i ).maxValue() );
+      int y1 = theYMap.transform( myData.sample( i ).interval.minValue() );
+      int y2 = theYMap.transform( myData.sample( i ).interval.maxValue() );
       if ( y1 > y2 )
         qSwap( y1, y2 );
 
       if ( i < (int)myData.size() - 2 ) {
-        const int yy1 = theYMap.transform( myData.interval(i+1).minValue() );
-        const int yy2 = theYMap.transform( myData.interval(i+1).maxValue() );
+        const int yy1 = theYMap.transform( myData.sample(i+1).interval.minValue() );
+        const int yy2 = theYMap.transform( myData.sample(i+1).interval.maxValue() );
         if ( y2 == qwtMin( yy1, yy2 ) ) {
-          const int xx2 = theXMap.transform( myData.interval(i+1).minValue() );
+          const int xx2 = theXMap.transform( myData.sample(i+1).interval.minValue() );
           if ( xx2 != x0 && ( ( xx2 < x0 && x2 < x0 ) ||
                               ( xx2 > x0 && x2 > x0 ) ) ) {
             // One pixel distance between neighboured bars
@@ -650,19 +744,19 @@ void Plot2d_HistogramQwtItem::draw( QPainter* thePainter,
       drawBar( thePainter, Qt::Horizontal, QRect( x0, y1, x2 - x0, y2 - y1 ) );
     }
     else {
-      const int y2 = theYMap.transform( myData.value( i ) );
+      const int y2 = theYMap.transform( myData.sample( i ).value );
       if ( y2 == y0 )
         continue;
-      int x1 = theXMap.transform( myData.interval( i ).minValue() );
-      int x2 = theXMap.transform( myData.interval( i ).maxValue() );
+      int x1 = theXMap.transform( myData.sample( i ).interval.minValue() );
+      int x2 = theXMap.transform( myData.sample( i ).interval.maxValue() );
       if ( x1 > x2 )
         qSwap( x1, x2 );
 
       if ( i < (int)myData.size() - 2 ) {
-        const int xx1 = theXMap.transform( myData.interval(i+1).minValue() );
-        const int xx2 = theXMap.transform( myData.interval(i+1).maxValue() );
+        const int xx1 = theXMap.transform( myData.sample(i+1).interval.minValue() );
+        const int xx2 = theXMap.transform( myData.sample(i+1).interval.maxValue() );
         if ( x2 == qwtMin( xx1, xx2 ) ) {
-          const int yy2 = theYMap.transform( myData.value(i+1) );
+          const int yy2 = theYMap.transform( myData.sample(i+1).value );
           if ( yy2 != y0 && ( ( yy2 < y0 && y2 < y0 ) ||
                               ( yy2 > y0 && y2 > y0 ) ) ) {
             // One pixel distance between neighboured bars
@@ -756,28 +850,35 @@ QList<QRect> Plot2d_HistogramItem::getBars() const
 /*!
   Set to legend item symbol with color of item
 */
-void Plot2d_HistogramItem::updateLegend( QwtLegend* theLegend ) const
+void Plot2d_HistogramItem::updateLegend( QwtPlotItem* thePlotItem,
+                                         QList<QwtLegendData>& theLegendData )
 {
-  if ( !theLegend )
+  if ( !thePlotItem || !thePlotItem->plot() )
     return;
 
-  Plot2d_HistogramQwtItem::updateLegend( theLegend );
+  Plot2d_HistogramQwtItem::updateLegend( thePlotItem, theLegendData );
 
-  QWidget* theWidget = theLegend->find( this );
-  if ( !theWidget || !theWidget->inherits( "QwtLegendItem" ) )
+  const QVariant itemInfo = thePlotItem->plot()->itemToInfo( const_cast< QwtPlotItem *>( thePlotItem ) );
+  QwtLegend *legend = dynamic_cast<QwtLegend *>( thePlotItem->plot()->legend() );
+  QWidget* widget = legend->legendWidget( itemInfo );
+
+  if ( !widget || !widget->inherits( "QwtLegendItem" ) )
     return;
 
-  Plot2d_QwtLegendItem* anItem = ( Plot2d_QwtLegendItem* )theWidget;
-  QFontMetrics aFMetrics( anItem->font() );
-  int aSize = aFMetrics.height();
-  QwtSymbol aSymbol( QwtSymbol::Rect, QBrush( legendPen().color() ),
-                     QPen( legendPen().color() ), QSize( aSize, aSize ) );
-  anItem->setSymbol( aSymbol );
-  anItem->setIdentifierMode( theLegend->identifierMode()
-                            | QwtLegendItem::ShowSymbol );
-  anItem->setSelected(isSelected());
-  anItem->updateHighlit();
-  anItem->update();
+  QwtLegendLabel* label = dynamic_cast<QwtLegendLabel*>( widget );
+  if( Plot2d_QwtLegendLabel* anItem = (Plot2d_QwtLegendLabel*)( label ) ) {
+    QFontMetrics aFMetrics( anItem->font() );
+    int aSize = aFMetrics.height();
+    QwtSymbol* aSymbol = new QwtSymbol( QwtSymbol::Rect, QBrush( legendPen().color() ),
+                                        QPen( legendPen().color() ), QSize( aSize, aSize ) );
+    anItem->setSymbol( aSymbol );
+    if( Plot2d_Plot2d* plot = dynamic_cast<Plot2d_Plot2d*>( thePlotItem->plot() ) )
+      anItem->setSymbolType( plot->getLegendSymbolType() );
+    anItem->setSelected( isSelected() );
+    anItem->updateHighlit();
+    anItem->update();
+    anItem->repaint();
+  }
 }
 
 /*!
@@ -786,7 +887,7 @@ void Plot2d_HistogramItem::updateLegend( QwtLegend* theLegend ) const
 void Plot2d_HistogramItem::draw( QPainter* thePainter,
                                 const QwtScaleMap& theXMap,
                                 const QwtScaleMap& theYMap,
-                                const QRect& ) const
+                                const QRectF& ) const
 {
   // nds: clear list of bar items
   Plot2d_HistogramItem* anItem = (Plot2d_HistogramItem*)this;
@@ -796,23 +897,23 @@ void Plot2d_HistogramItem::draw( QPainter* thePainter,
   const int x0 = theXMap.transform( baseline() );
   const int y0 = theYMap.transform( baseline() );
 
-  const QwtIntervalData& iData = data();
+  const QwtIntervalSeriesData& iData = data();
 
   for ( int i = 0; i < (int)iData.size(); i++ ) {
     if ( testHistogramAttribute( Plot2d_HistogramItem::Xfy ) ) {
-      const int x2 = theXMap.transform( iData.value( i ) );
+      const int x2 = theXMap.transform( iData.sample(i).value );
       if ( x2 == x0 )
         continue;
-      int y1 = theYMap.transform( iData.interval( i ).minValue() );
-      int y2 = theYMap.transform( iData.interval( i ).maxValue() );
+      int y1 = theYMap.transform( iData.sample(i).interval.minValue() );
+      int y2 = theYMap.transform( iData.sample(i).interval.maxValue() );
       if ( y1 > y2 )
         qSwap( y1, y2 );
 
       if ( i < (int)iData.size() - 2 ) {
-        const int yy1 = theYMap.transform( iData.interval(i+1).minValue() );
-        const int yy2 = theYMap.transform( iData.interval(i+1).maxValue() );
+        const int yy1 = theYMap.transform( iData.sample(i+1).interval.minValue() );
+        const int yy2 = theYMap.transform( iData.sample(i+1).interval.maxValue() );
         if ( y2 == qwtMin( yy1, yy2 ) ) {
-          const int xx2 = theXMap.transform( iData.interval(i+1).minValue() );
+          const int xx2 = theXMap.transform( iData.sample(i+1).interval.minValue() );
           if ( xx2 != x0 && ( ( xx2 < x0 && x2 < x0 ) ||
                               ( xx2 > x0 && x2 > x0 ) ) ) {
             // One pixel distance between neighboured bars
@@ -826,19 +927,19 @@ void Plot2d_HistogramItem::draw( QPainter* thePainter,
       anItem->myBarItems.append( aRect );
     }
     else {
-      const int y2 = theYMap.transform( iData.value( i ) );
+      const int y2 = theYMap.transform( iData.sample(i).value );
       if ( y2 == y0 )
         continue;
-      int x1 = theXMap.transform( iData.interval( i ).minValue() );
-      int x2 = theXMap.transform( iData.interval( i ).maxValue() );
+      int x1 = theXMap.transform( iData.sample(i).interval.minValue() );
+      int x2 = theXMap.transform( iData.sample(i).interval.maxValue() );
       if ( x1 > x2 )
         qSwap( x1, x2 );
 
       if ( i < (int)iData.size() - 2 ) {
-        const int xx1 = theXMap.transform( iData.interval(i+1).minValue() );
-        const int xx2 = theXMap.transform( iData.interval(i+1).maxValue() );
+        const int xx1 = theXMap.transform( iData.sample(i+1).interval.minValue() );
+        const int xx2 = theXMap.transform( iData.sample(i+1).interval.maxValue() );
         if ( x2 == qwtMin( xx1, xx2 ) ) {
-          const int yy2 = theYMap.transform( iData.value(i+1) );
+          const int yy2 = theYMap.transform( iData.sample(i+1).value );
           if ( yy2 != y0 && ( ( yy2 < y0 && y2 < y0 ) ||
                               ( yy2 > y0 && y2 > y0 ) ) ) {
             // One pixel distance between neighboured bars
@@ -870,15 +971,6 @@ bool Plot2d_HistogramItem::isCrossItems() const
   return myCrossed;
 }
 
-/*!
-  Redefined method, which creates and returns legend item of the curve
-*/
-QWidget* Plot2d_HistogramItem::legendItem() const
-{
-  return new Plot2d_QwtLegendItem;
-}
-
-
 /*!
   Draws bar of histogram and on it bars of histograms with lower height.
 */
@@ -931,3 +1023,29 @@ int Plot2d_HistogramItem::getCrossedTop( const QRect& theRect ) const
   }
   return aRes;
 }
+
+Plot2d_QwtLegend::Plot2d_QwtLegend( QWidget *parent ):
+QwtLegend( parent )
+{
+  setAutoFillBackground(true);
+}
+
+Plot2d_QwtLegend::~Plot2d_QwtLegend()
+{
+}
+
+/*!
+  Redefined method, which create a widget to be inserted into the legend.
+*/
+QWidget *Plot2d_QwtLegend::createWidget( const QwtLegendData &data ) const
+{
+  Q_UNUSED( data );
+
+  Plot2d_QwtLegendLabel *label = new Plot2d_QwtLegendLabel();
+  label->setItemMode( defaultItemMode() );
+
+  connect( label, SIGNAL( clicked() ), SLOT( itemClicked() ) );
+  connect( label, SIGNAL( checked( bool ) ), SLOT( itemChecked( bool ) ) );
+
+  return label;
+}
index 65f4a2884c4f2dccf17dd82d2c9b0de587e0c813..fdc95111be71b0fc9812f36f4efb6a920a656859 100644 (file)
 
 #include "Plot2d.h"
 
-#include <qwt_legend_item.h>
+#include <qwt_legend_label.h>
+#include <qwt_legend.h>
 #include <qwt_plot_item.h>
 #include <qwt_plot_curve.h>
-#include <qwt_interval_data.h>
 #include <qwt_plot.h>
+#include <qwt_series_data.h>
+#include <qwt_compat.h>
 
-class PLOT2D_EXPORT Plot2d_QwtLegendItem : public QwtLegendItem
+class PLOT2D_EXPORT Plot2d_QwtLegendLabel : public QwtLegendLabel
 {
 public:
   enum YAxisIdentifierMode { IM_None = 0, IM_Left, IM_Right };
 
 public:
-  Plot2d_QwtLegendItem( QWidget* = 0 );
-  virtual ~Plot2d_QwtLegendItem();
+  Plot2d_QwtLegendLabel( QWidget* = 0 );
+  virtual ~Plot2d_QwtLegendLabel();
 
 public:
   void             setYAxisIdentifierMode( const int );
   void             updateHighlit();
-  void             setSelected(const bool on);
+  void             setSelected( const bool on );
   bool             isSelected() const;
-  QColor           getColorFromPalette(QPalette::ColorRole role);  
+  QColor           getColorFromPalette( QPalette::ColorRole role );
+  void             drawIdentifier( QPainter*, const QRect& );
+  void             setSymbol( const QwtSymbol* );
+  void             setSymbolType( const int );
+  void             setPen( const QPen& );
 
 protected:
-  virtual void     drawIdentifier( QPainter*, const QRect& ) const;
-  virtual void     drawText(QPainter *, const QRect &);
+  virtual void     drawText( QPainter*, const QRectF& );
+  virtual void     paintEvent( QPaintEvent* );
 
 private:
 
@@ -62,26 +68,29 @@ private:
   int              mySpacingCollapsed;
   int              mySpacingExpanded;
   bool             myIsSelected;
+  QwtSymbol*       mySymbol;
+  int              mySymbolType;
+  QPen             myPen;
 };
 
 class PLOT2D_EXPORT Plot2d_SelectableItem {
 public:
-    Plot2d_SelectableItem();
-    ~Plot2d_SelectableItem();
-  
-    void             setSelected( const bool );
-    bool             isSelected() const;
-    
-    void             setLegendPen( const QPen & );
-    QPen             legendPen() const;
-       
-    void             setLegendSymbol( const QwtSymbol& );
-    QwtSymbol        legendSymbol() const;
-    
+  Plot2d_SelectableItem();
+  ~Plot2d_SelectableItem();
+
+  void             setSelected( const bool );
+  bool             isSelected() const;
+
+  void             setLegendPen( const QPen& );
+  QPen             legendPen() const;
+
+  void             setLegendSymbol( const QwtSymbol* );
+  QwtSymbol*       legendSymbol() const;
+
 private:
   bool             myIsSelected;
   QPen             myLegendPen;
-  QwtSymbol        myLegendSymbol;
+  QwtSymbol*       myLegendSymbol;
 };
 
 class PLOT2D_EXPORT Plot2d_QwtPlotCurve : public QwtPlotCurve, public Plot2d_SelectableItem
@@ -92,27 +101,28 @@ public:
 
 public:
   virtual void     setYAxisIdentifierEnabled( const bool );
-  virtual void     draw(QPainter *p, 
-                        const QwtScaleMap &xMap, 
-                        const QwtScaleMap &yMap,
-                        int from, int to) const;
+  virtual void     drawSeries( QPainter* p,
+                               const QwtScaleMap& xMap,
+                               const QwtScaleMap& yMap,
+                               const QRectF& canvasRect,
+                               int from, int to) const;
 
-  void             setDeviationData(const double* min, const double* max, const QList<int> &idx);
+  void             setDeviationData( const double* min, const double* max, const QList<int>& idx );
   bool             hasDeviationData() const;
   void             clearDeviationData();
 
-
 protected:
-  virtual void     updateLegend( QwtLegend* ) const;
-  virtual QWidget* legendItem() const;
+  virtual void     updateLegend( const QwtPlotItem*,
+                                 const QList<QwtLegendData>& );
+  virtual void     itemChanged();
 
   QColor           deviationMarkerColor() const;
   int              deviationMarkerLineWidth() const;
   int              deviationMarkerTickSize() const;
 
 private:
-  QwtPlot::Axis        myYAxis;
-  bool                 myYAxisIdentifierEnabled;
+  QwtPlot::Axis    myYAxis;
+  bool             myYAxisIdentifierEnabled;
   
   class Plot2d_DeviationData;
   Plot2d_DeviationData* myDeviationData;
@@ -131,8 +141,8 @@ public:
   explicit Plot2d_HistogramQwtItem( const QwtText& );
   virtual ~Plot2d_HistogramQwtItem();
 
-  void                   setData( const QwtIntervalData& );
-  const QwtIntervalData& data() const;
+  void                   setData( const QwtIntervalSeriesData& );
+  const QwtIntervalSeriesData& data() const;
 
   void                   setColor( const QColor& );
   QColor                 color() const;
@@ -140,7 +150,7 @@ public:
   virtual QwtDoubleRect  boundingRect() const;
   virtual int            rtti() const;
   virtual void           draw( QPainter*, const QwtScaleMap&, 
-                              const QwtScaleMap&, const QRect& ) const;
+                               const QwtScaleMap&, const QRectF& ) const;
 
   void                   setBaseline( double );
   double                 baseline() const;
@@ -156,7 +166,7 @@ private:
 
 private:
   int                    myAttributes;
-  QwtIntervalData        myData;
+  QwtIntervalSeriesData  myData;
   QColor                 myColor;
   double                 myReference;
 };
@@ -168,25 +178,34 @@ public:
   explicit Plot2d_HistogramItem( const QwtText& );
   virtual ~Plot2d_HistogramItem();
 
-  QList<QRect>           getBars() const;
+  QList<QRect>     getBars() const;
 
-  virtual void           updateLegend( QwtLegend* ) const;
-  virtual void           draw( QPainter*, const QwtScaleMap&, 
-                              const QwtScaleMap&, const QRect& ) const;
+  virtual void     updateLegend( QwtPlotItem*,
+                                 QList<QwtLegendData>& );
+  virtual void     draw( QPainter*, const QwtScaleMap&,
+                         const QwtScaleMap&, const QRectF& ) const;
+
+  void             setCrossItems( bool theCross );
+  bool             isCrossItems() const;
 
-  void                   setCrossItems( bool theCross );
-  bool                   isCrossItems() const;
+protected:
+  void             drawRectAndLowers( QPainter*, Qt::Orientation,
+                                      const QRect& ) const;
+  int              getCrossedTop( const QRect& ) const;
 
 protected:
-  void                   drawRectAndLowers( QPainter*, Qt::Orientation,
-                                           const QRect& ) const;
-  int                    getCrossedTop( const QRect& ) const;
+  QList<QRect>     myBarItems;
+  bool             myCrossed;
+};
 
-  virtual QWidget*       legendItem() const;
+class PLOT2D_EXPORT Plot2d_QwtLegend : public QwtLegend
+{
+public:
+  explicit Plot2d_QwtLegend( QWidget *parent = NULL );
+  virtual ~Plot2d_QwtLegend();
 
 protected:
-  QList<QRect>           myBarItems;
-  bool                   myCrossed;
+  virtual QWidget* createWidget( const QwtLegendData& ) const;
 };
 
 #endif // PLOT2D_PLOTITEMS_H
index 9616b3f5d9aefd776a82152bdba68f9ce6571ee6..41c4f8dfd496ef2e0b2c131a949a43e7be756fc9 100755 (executable)
@@ -89,19 +89,6 @@ Plot2d_SetupViewDlg::Plot2d_SetupViewDlg( QWidget* parent,
   myCurveCombo->addItem( tr( "PLOT2D_CURVE_TYPE_LINES" ) );
   myCurveCombo->addItem( tr( "PLOT2D_CURVE_TYPE_SPLINE" ) );
 
-  // legend
-  myLegendCheck = new QCheckBox( tr( "PLOT2D_ENABLE_LEGEND" ), this );
-  myLegendCombo = new QComboBox( this );
-  myLegendFont = new QtxFontEdit( this );
-  myLegendColor = new QtxColorButton( this );
-  QLabel* aLegendFontLab = new QLabel( tr( "PLOT2D_LEGEND_FONT" ), this );
-  myLegendCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
-  myLegendCombo->setMinimumWidth( MIN_COMBO_WIDTH );
-  myLegendCombo->addItem( tr( "PLOT2D_LEGEND_POSITION_LEFT" ) );
-  myLegendCombo->addItem( tr( "PLOT2D_LEGEND_POSITION_RIGHT" ) );
-  myLegendCombo->addItem( tr( "PLOT2D_LEGEND_POSITION_TOP" ) );
-  myLegendCombo->addItem( tr( "PLOT2D_LEGEND_POSITION_BOTTOM" ) );
-
   // marker size
   QLabel* aMarkerLab  = new QLabel( tr( "PLOT2D_MARKER_SIZE_LBL" ), this );
   myMarkerSpin = new QSpinBox( this );
@@ -115,6 +102,68 @@ Plot2d_SetupViewDlg::Plot2d_SetupViewDlg( QWidget* parent,
   QLabel* aBGLab  = new QLabel( tr( "PLOT2D_BACKGROUND_COLOR_LBL" ), this );
   myBackgroundBtn = new QtxColorButton( this );
 
+  // selection color
+  QLabel* aSelectionLab  = new QLabel( tr( "PLOT2D_SELECTION_COLOR_LBL" ), this );
+  mySelectionBtn = new QtxColorButton( this );
+
+  QHBoxLayout* ViewerColorLayout = new QHBoxLayout;
+  ViewerColorLayout->addWidget( aBGLab );
+  ViewerColorLayout->addWidget( myBackgroundBtn );
+  ViewerColorLayout->addStretch();
+  ViewerColorLayout->addWidget( aSelectionLab );
+  ViewerColorLayout->addWidget( mySelectionBtn );
+  ViewerColorLayout->addStretch();
+
+  // legend
+  QGroupBox* aLegendGrp = new QGroupBox( tr( "PLOT2D_LEGEND_GROUP" ), this );
+  QGridLayout* aLegendLayout = new QGridLayout( aLegendGrp );
+  aLegendLayout->setMargin( MARGIN_SIZE ); aLegendLayout->setSpacing( SPACING_SIZE );
+  aLegendGrp->setLayout( aLegendLayout );
+
+  myLegendCheck = new QCheckBox( tr( "PLOT2D_ENABLE_LEGEND" ), this );
+
+  QLabel* aLegendPosition = new QLabel( tr( "PLOT2D_LEGEND_POSITION" ), this );
+  myLegendCombo = new QComboBox( this );
+  myLegendCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+  myLegendCombo->setMinimumWidth( MIN_COMBO_WIDTH );
+  myLegendCombo->addItem( tr( "PLOT2D_LEGEND_POSITION_LEFT" ) );
+  myLegendCombo->addItem( tr( "PLOT2D_LEGEND_POSITION_RIGHT" ) );
+  myLegendCombo->addItem( tr( "PLOT2D_LEGEND_POSITION_TOP" ) );
+  myLegendCombo->addItem( tr( "PLOT2D_LEGEND_POSITION_BOTTOM" ) );
+
+  QLabel* aLegendSymbolType = new QLabel( tr( "PLOT2D_LEGEND_SYMBOL_TYPE" ), this );
+  myLegendSymbolType = new QComboBox( this );
+  myLegendSymbolType->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+  myLegendSymbolType->setMinimumWidth( MIN_COMBO_WIDTH );
+  myLegendSymbolType->addItem( tr( "PLOT2D_MARKER_ON_LINE" ) );
+  myLegendSymbolType->addItem( tr( "PLOT2D_MARKER_ABOVE_LINE" ) );
+
+  QLabel* aLegendFontLab = new QLabel( tr( "PLOT2D_LEGEND_FONT" ), this );
+  myLegendFont = new QtxFontEdit( this );
+
+  QLabel* aLegendFontColor = new QLabel( tr( "PLOT2D_LEGEND_FONT_COLOR" ), this );
+  myLegendFontColor = new QtxColorButton( this );
+
+  QLabel* aSelectLegendFontColor = new QLabel( tr( "PLOT2D_SELECTED_LEGEND_FONT_COLOR" ), this );
+  mySelectedLegendFontColor = new QtxColorButton( this );
+
+  QHBoxLayout* FontLayout = new QHBoxLayout;
+  FontLayout->addWidget( aLegendFontColor );
+  FontLayout->addWidget( myLegendFontColor );
+  FontLayout->addStretch();
+  FontLayout->addWidget( aSelectLegendFontColor );
+  FontLayout->addWidget( mySelectedLegendFontColor );
+  FontLayout->addStretch();
+
+  aLegendLayout->addWidget( myLegendCheck,      0, 0 );
+  aLegendLayout->addWidget( aLegendPosition,    1, 0 );
+  aLegendLayout->addWidget( myLegendCombo,      1, 1 );
+  aLegendLayout->addWidget( aLegendSymbolType,  2, 0 );
+  aLegendLayout->addWidget( myLegendSymbolType, 2, 1 );
+  aLegendLayout->addWidget( aLegendFontLab,     3, 0 );
+  aLegendLayout->addWidget( myLegendFont,       3, 1 );
+  aLegendLayout->addLayout( FontLayout,         4, 0, 1, 2 );
+
   //Deviation marker parameters
   QGroupBox* aDeviationGrp = new QGroupBox( tr( "PLOT2D_DEVIATION_MARKER_TLT" ), this );
   QHBoxLayout* aDeviationLayout = new QHBoxLayout(aDeviationGrp);
@@ -375,30 +424,21 @@ Plot2d_SetupViewDlg::Plot2d_SetupViewDlg( QWidget* parent,
   btnLayout->addWidget( myHelpBtn );
 
   // layout widgets
-  topLayout->addWidget( myTitleCheck,  0,    0    );
-  topLayout->addWidget( myTitleEdit,   0, 1, 1, 3 );
-  topLayout->addWidget( myLegendCheck, 1,    0    );
-  topLayout->addWidget( myLegendCombo, 1,    1    );
-  topLayout->addWidget( aCurveLab,  1,    2    );
-  topLayout->addWidget( myCurveCombo,  1,     3    );
-  topLayout->addWidget( aLegendFontLab,2,    0    );
-  topLayout->addWidget( myLegendFont,     2,    1    );
-  topLayout->addWidget( myLegendColor,  2,    2    );
-
-  topLayout->addWidget( aMarkerLab,    3,    0    );
-  topLayout->addWidget( myMarkerSpin,  3,    1    );
-  QHBoxLayout* bgLayout = new QHBoxLayout;
-  bgLayout->addWidget( myBackgroundBtn ); bgLayout->addStretch();
-  topLayout->addWidget( aBGLab,        3,    2    );
-  topLayout->addLayout( bgLayout,      3,    3    );
-  topLayout->addWidget( aDeviationGrp,   4, 0, 1, 4 );
-  topLayout->addWidget( aNormalizeGrp,      5, 0, 1, 4 );
-  topLayout->addWidget( aScaleGrp,     6, 0, 1, 4 );
-  topLayout->addWidget( aTabWidget,    7, 0, 1, 4 );
-  topLayout->addWidget( myDefCheck,    8, 0, 1, 4 );
-  topLayout->setRowStretch( 9, 5 );
-
-  topLayout->addLayout( btnLayout,     10, 0, 1, 4 );
+  topLayout->addWidget( myTitleCheck,      0, 0       );
+  topLayout->addWidget( myTitleEdit,       0, 1, 1, 3 );
+  topLayout->addWidget( aCurveLab,         1, 0       );
+  topLayout->addWidget( myCurveCombo,      1, 1       );
+  topLayout->addWidget( aMarkerLab,        2, 0       );
+  topLayout->addWidget( myMarkerSpin,      2, 1       );
+  topLayout->addLayout( ViewerColorLayout, 3, 0, 1, 4 );
+  topLayout->addWidget( aLegendGrp,        4, 0, 1, 4 );
+  topLayout->addWidget( aDeviationGrp,     5, 0, 1, 4 );
+  topLayout->addWidget( aNormalizeGrp,     6, 0, 1, 4 );
+  topLayout->addWidget( aScaleGrp,         7, 0, 1, 4 );
+  topLayout->addWidget( aTabWidget,        8, 0, 1, 4 );
+  topLayout->addWidget( myDefCheck,        9, 0, 1, 4 );
+  topLayout->setRowStretch( 10, 5 );
+  topLayout->addLayout( btnLayout,         11, 0, 1, 4 );
 
   if ( !showDefCheck )
     myDefCheck->hide();
@@ -698,12 +738,15 @@ bool Plot2d_SetupViewDlg::getRMinNormMode()
   \param col legend font color
   \sa isLegendEnabled(), getLegendPos(), getLegendFont()
 */
-void Plot2d_SetupViewDlg::setLegend( bool enable, int pos, const QFont& fnt, const QColor& col )
+void Plot2d_SetupViewDlg::setLegend( bool enable, int pos, int symbolType,
+                                     const QFont& fnt, const QColor& fontColor, const QColor& selFontColor )
 {
   myLegendCheck->setChecked( enable );
   myLegendCombo->setCurrentIndex( pos );
+  myLegendSymbolType->setCurrentIndex( symbolType );
   myLegendFont->setCurrentFont( fnt );
-  myLegendColor->setColor( col );
+  myLegendFontColor->setColor( fontColor );
+  mySelectedLegendFontColor->setColor( selFontColor );
   onLegendChecked();
 }
 
@@ -727,6 +770,16 @@ int Plot2d_SetupViewDlg::getLegendPos()
   return myLegendCombo->currentIndex();
 }
 
+/*!
+  \brief Get legend symbol type.
+  \return legend symbol type: 0 (marker on line), 1 (marker above line)
+  \sa setLegend()
+*/
+int Plot2d_SetupViewDlg::getLegendSymbolType()
+{
+  return myLegendSymbolType->currentIndex();
+}
+
 /*!
   \brief Get legend font.
   \return legend font
@@ -744,7 +797,17 @@ QFont Plot2d_SetupViewDlg::getLegendFont()
 */
 QColor Plot2d_SetupViewDlg::getLegendColor()
 {
-  return myLegendColor->color();
+  return myLegendFontColor->color();
+}
+
+/*!
+  \brief Get selected legend font color.
+  \return selected legend font color
+  \sa setLegend()
+*/
+QColor Plot2d_SetupViewDlg::getSelectedLegendColor()
+{
+  return mySelectedLegendFontColor->color();
 }
 
 /*!
@@ -840,6 +903,26 @@ QColor Plot2d_SetupViewDlg::getBackgroundColor()
   return myBackgroundBtn->color();
 }
 
+/*!
+  \brief Set selection color.
+  \param color selection color
+  \sa getSelectionColor()
+*/
+void Plot2d_SetupViewDlg::setSelectionColor( const QColor& color )
+{
+  mySelectionBtn->setColor( color );
+}
+
+/*!
+  \brief Get selection color.
+  \return selection color
+  \sa setSelectionColor()
+*/
+QColor Plot2d_SetupViewDlg::getSelectionColor()
+{
+  return mySelectionBtn->color();
+}
+
 /*!
   \brief Set major grid parameters.
   \param enableX if \c true, horizontal major grid is enabled
index ea3e659a2a20e433c47897efb3beffd9804154ed..d6ecb76ebbcce6ba29d740eff2d1dd9f1bc50b4f 100755 (executable)
@@ -73,11 +73,13 @@ public:
   bool            getRMinNormMode();
   void            setRMinNormMode(const bool);
 
-  void            setLegend( bool, int, const QFont&, const QColor& );
+  void            setLegend( bool, int, int, const QFont&, const QColor&, const QColor& );
   bool            isLegendEnabled();
   int             getLegendPos();
+  int             getLegendSymbolType();
   QFont           getLegendFont();
   QColor          getLegendColor();
+  QColor          getSelectedLegendColor();
   
   void            setMarkerSize( const int );
   int             getMarkerSize();
@@ -85,6 +87,9 @@ public:
   void            setBackgroundColor( const QColor& );
   QColor          getBackgroundColor();
 
+  void            setSelectionColor( const QColor& );
+  QColor          getSelectionColor();
+
   void            setMajorGrid( bool, const int, bool, const int, bool, const int );
   void            getMajorGrid( bool&, int&, bool&, int&, bool&, int& );
   void            setMinorGrid( bool, const int, bool, const int, bool, const int );
@@ -133,7 +138,9 @@ private:
   QLineEdit*      myTitleYEdit;
   QLineEdit*      myTitleY2Edit;
   QtxColorButton* myBackgroundBtn;
-  QtxColorButton* myLegendColor;
+  QtxColorButton* mySelectionBtn;
+  QtxColorButton* myLegendFontColor;
+  QtxColorButton* mySelectedLegendFontColor;
   QtxFontEdit*    myLegendFont;
   QCheckBox*      myXGridCheck;
   QSpinBox*       myXGridSpin;
@@ -150,6 +157,7 @@ private:
   QComboBox*      myCurveCombo;
   QCheckBox*      myLegendCheck;
   QComboBox*      myLegendCombo;
+  QComboBox*      myLegendSymbolType;
   QSpinBox*       myMarkerSpin;
   QComboBox*      myXModeCombo;
   QComboBox*      myYModeCombo;
index f92e2b2bf75eea0e0059de069b5f38ee1f260ab0..a52a6ab9920cad7859601be58d22cd2b6482c500 100755 (executable)
@@ -74,6 +74,7 @@
 #include <qwt_scale_engine.h>
 #include <qwt_plot_zoomer.h>
 #include <qwt_curve_fitter.h>
+#include <qwt_plot_renderer.h>
 
 #include <stdlib.h>
 #include <limits>
@@ -181,10 +182,11 @@ Plot2d_ViewFrame::Plot2d_ViewFrame( QWidget* parent, const QString& title )
      : QWidget (parent, 0),
        myOperation( NoOpId ),
        myCurveType( 1 ),
-       myShowLegend( true ), myLegendPos( 1 ), myLegendFont("Helvetic",12),
-       myLegendColor(Qt::black),
+       myShowLegend( true ), myLegendPos( 1 ), myLegendSymbolType( 0 ), myLegendFont("Helvetic",12),
+       myLegendColor(Qt::black), mySelectedLegendFontColor( Qt::darkBlue ),
        myMarkerSize( DEFAULT_MARKER_SIZE ),
        myBackground( Qt::white ),
+       mySelectionColor( Qt::gray ),
        myTitle( "" ), myXTitle( "" ), myYTitle( "" ), myY2Title( "" ),
        myTitleEnabled( true ), myXTitleEnabled( true ),
        myYTitleEnabled( true ), myY2TitleEnabled (true),
@@ -206,18 +208,6 @@ Plot2d_ViewFrame::Plot2d_ViewFrame( QWidget* parent, const QString& title )
 
   aLayout->addWidget( myPlot );
 
-  //  createActions();
-  connect( myPlot, SIGNAL( legendClicked( QwtPlotItem* ) ),
-           this, SIGNAL( legendClicked( QwtPlotItem* ) ) );
-
-  // IPAL 21465
-  /*  connect( myPlot->axisWidget( QwtPlot::xBottom ), SIGNAL( scaleDivChanged() ),
-           myPlot, SLOT( onScaleDivChanged() ) );
-  connect( myPlot->axisWidget( QwtPlot::yLeft ), SIGNAL( scaleDivChanged() ),
-           myPlot, SLOT( onScaleDivChanged() ) );
-  if (mySecondY)
-    connect( myPlot->axisWidget( QwtPlot::yRight ), SIGNAL( scaleDivChanged() ),
-    myPlot, SLOT( onScaleDivChanged() ) );*/
 #ifndef NO_SUIT
   Init();
 #endif
@@ -236,7 +226,6 @@ void Plot2d_ViewFrame::Init()
   /* Initial Setup - get from the preferences */
   readPreferences();
 
-  myPlot->setMargin( 5 );
   setCurveType( myCurveType, false );
   setXGrid( myXGridMajorEnabled, myXGridMaxMajor, myXGridMinorEnabled, myXGridMaxMinor, false );
   setYGrid( myYGridMajorEnabled, myYGridMaxMajor, myYGridMinorEnabled, myYGridMaxMinor,
@@ -251,9 +240,12 @@ void Plot2d_ViewFrame::Init()
   setHorScaleMode( myXMode, false );
   setVerScaleMode( myYMode, false );
   setBackgroundColor( myBackground );
+  setSelectionColor( mySelectionColor );
   setLegendPos( myLegendPos );
+  setLegendSymbolType( myLegendSymbolType );
   setLegendFont( myLegendFont );
   setLegendFontColor( myLegendColor );
+  setSelectedLegendFontColor( mySelectedLegendFontColor );
   showLegend( myShowLegend, false );
   myPlot->replot();
 
@@ -272,6 +264,21 @@ void Plot2d_ViewFrame::Init()
   }
   myPlot->canvas()->installEventFilter( this );
 }
+void Plot2d_ViewFrame::SetPreference()
+{
+  readPreferences();
+  setBackgroundColor( myBackground );
+  setSelectionColor( mySelectionColor );
+  setCurveType( myCurveType, true );
+  setMarkerSize( myMarkerSize, true );
+  showLegend( myShowLegend, true );
+  setLegendPos( myLegendPos );
+  setLegendSymbolType( myLegendSymbolType );
+  setLegendFont( myLegendFont );
+  setLegendFontColor( myLegendColor );
+  setSelectedLegendFontColor( mySelectedLegendFontColor );
+  myPlot->replot();
+}
 /*!
   Gets window's central widget
 */
@@ -465,10 +472,13 @@ void Plot2d_ViewFrame::readPreferences()
 
   myShowLegend = resMgr->booleanValue( "Plot2d", "ShowLegend", myShowLegend );
   myLegendPos = resMgr->integerValue( "Plot2d", "LegendPos", myLegendPos );
+  myLegendSymbolType = resMgr->integerValue( "Plot2d", "LegendSymbolType", myLegendSymbolType );
   myLegendFont = resMgr->fontValue( "Plot2d", "LegendFont", myLegendFont );
   myLegendColor = resMgr->colorValue( "Plot2d", "LegendFontColor", myLegendColor );
+  mySelectedLegendFontColor = resMgr->colorValue( "Plot2d", "SelectedLegendFontColor", mySelectedLegendFontColor );
   myMarkerSize = resMgr->integerValue( "Plot2d", "MarkerSize", myMarkerSize );
   myBackground = resMgr->colorValue( "Plot2d", "Background", myBackground );
+  mySelectionColor = resMgr->colorValue( "Plot2d", "SelectionColor", mySelectionColor );
 
   myTitleEnabled = resMgr->booleanValue( "Plot2d", "ShowTitle", myTitleEnabled );
   myXTitleEnabled = resMgr->booleanValue( "Plot2d", "ShowHorTitle", myXTitleEnabled );
@@ -519,13 +529,19 @@ void Plot2d_ViewFrame::writePreferences()
   resMgr->setValue( "Plot2d", "CurveType", myCurveType );
   resMgr->setValue( "Plot2d", "ShowLegend", myShowLegend );
   resMgr->setValue( "Plot2d", "LegendPos", myLegendPos );
+  resMgr->setValue( "Plot2d", "LegendSymbolType", myLegendSymbolType );
   resMgr->setValue( "Plot2d", "LegendFont", myLegendFont );
   resMgr->setValue( "Plot2d", "LegendFontColor", myLegendColor );
+  resMgr->setValue( "Plot2d", "SelectedLegendFontColor", mySelectedLegendFontColor );
   resMgr->setValue( "Plot2d", "MarkerSize", myMarkerSize );
   resMgr->setValue( "Plot2d", "Background", myBackground );
+  resMgr->setValue( "Plot2d", "SelectionColor", mySelectionColor );
   resMgr->setValue( "Plot2d", "ShowTitle", myTitleEnabled );
   resMgr->setValue( "Plot2d", "ShowHorTitle", myXTitleEnabled );
   resMgr->setValue( "Plot2d", "ShowVerLeftTitle", myYTitleEnabled );
+  resMgr->setValue( "Plot2d", "DeviationMarkerColor", myPlot->property(PLOT2D_DEVIATION_COLOR).value<QColor>() );
+  resMgr->setValue( "Plot2d", "DeviationMarkerLineWidth", myPlot->property(PLOT2D_DEVIATION_LW).toInt() );
+  resMgr->setValue( "Plot2d", "DeviationMarkerTickSize", myPlot->property(PLOT2D_DEVIATION_TS).toInt() );
   if ( mySecondY )
     resMgr->setValue( "Plot2d", "ShowVerRightTitle", myY2TitleEnabled );
 
@@ -567,8 +583,8 @@ QString Plot2d_ViewFrame::getInfo( const QPoint& pnt )
   QwtValueList aTicks;
   bool xFound = false, yFound = false;
   double xCoord, yCoord;
-  const QwtScaleDiv* aXscale = myPlot->axisScaleDiv( QwtPlot::xBottom );
-  aTicks = aXscale->ticks( QwtScaleDiv::MajorTick );
+  const QwtScaleDiv& aXscale = myPlot->axisScaleDiv( QwtPlot::xBottom );
+  aTicks = aXscale.ticks( QwtScaleDiv::MajorTick );
   for ( i = 0; i < aTicks.count(); i++ ) {
     double majXmark = aTicks[i];
     int xmark = myPlot->transform( QwtPlot::xBottom, majXmark );
@@ -579,7 +595,7 @@ QString Plot2d_ViewFrame::getInfo( const QPoint& pnt )
     }
   }
   if ( !xFound ) {
-    aTicks = aXscale->ticks( QwtScaleDiv::MinorTick );
+    aTicks = aXscale.ticks( QwtScaleDiv::MinorTick );
     for ( i = 0; i < aTicks.count(); i++ ) {
       double minXmark = aTicks[i];
       int xmark = myPlot->transform( QwtPlot::xBottom, minXmark );
@@ -590,8 +606,8 @@ QString Plot2d_ViewFrame::getInfo( const QPoint& pnt )
       }
     }
   }
-  const QwtScaleDiv* aYscale = myPlot->axisScaleDiv( QwtPlot::yLeft );
-  aTicks = aYscale->ticks( QwtScaleDiv::MajorTick );
+  const QwtScaleDiv& aYscale = myPlot->axisScaleDiv( QwtPlot::yLeft );
+  aTicks = aYscale.ticks( QwtScaleDiv::MajorTick );
   for ( i = 0; i < aTicks.count(); i++ ) {
     double majYmark = aTicks[i];
     int ymark = myPlot->transform( QwtPlot::yLeft, majYmark );
@@ -602,7 +618,7 @@ QString Plot2d_ViewFrame::getInfo( const QPoint& pnt )
     }
   }
   if ( !yFound ) {
-    aTicks = aYscale->ticks( QwtScaleDiv::MinorTick );
+    aTicks = aYscale.ticks( QwtScaleDiv::MinorTick );
     for ( i = 0; i < aTicks.count(); i++ ) {
       double minYmark = aTicks[i];
       int ymark = myPlot->transform( QwtPlot::yLeft, minYmark );
@@ -626,8 +642,8 @@ QString Plot2d_ViewFrame::getInfo( const QPoint& pnt )
     bool yFound2 = false;
     double yCoord2;
 
-    const QwtScaleDiv* aYscale2 = myPlot->axisScaleDiv( QwtPlot::yRight );
-    aTicks = aYscale2->ticks( QwtScaleDiv::MajorTick );
+    const QwtScaleDiv& aYscale2 = myPlot->axisScaleDiv( QwtPlot::yRight );
+    aTicks = aYscale2.ticks( QwtScaleDiv::MajorTick );
     for ( i = 0; i < aTicks.count(); i++ ) {
       double majYmark = aTicks[i];
       int ymark = myPlot->transform( QwtPlot::yRight, majYmark );
@@ -638,7 +654,7 @@ QString Plot2d_ViewFrame::getInfo( const QPoint& pnt )
       }
     }
     if ( !yFound2 ) {
-      aTicks = aYscale2->ticks( QwtScaleDiv::MinorTick );
+      aTicks = aYscale2.ticks( QwtScaleDiv::MinorTick );
       for ( i = 0; i < aTicks.count(); i++ ) {
         double minYmark = aTicks[i];
         int ymark = myPlot->transform( QwtPlot::yRight, minYmark );
@@ -731,8 +747,8 @@ QVector< QVector<QwtPlotCurve *> > Plot2d_ViewFrame::displayPlot2dCurveList( con
                                                                              bool  displayLegend, const QList< bool >& sides)
 {
   // Consider the new legend's entries
-  // (PB: to update the legend we must remove it and put a new QwtLegend in the QwtPlot)
-  myPlot->insertLegend( (QwtLegend*)NULL); // we remove here, we shall put at the end
+  // (PB: to update the legend we must remove it and put a new QwtAbstractLegend in the QwtPlot)
+  myPlot->insertLegend( (QwtAbstractLegend*)NULL); // we remove here, we shall put at the end
 
   int nbAllCurves = curveList.size();
   int nbGroups    = nbAllCurves / groupSize;
@@ -875,9 +891,10 @@ QVector< QVector<QwtPlotCurve *> > Plot2d_ViewFrame::displayPlot2dCurveList( con
           QwtPlotCurve* plotCurve = dynamic_cast<QwtPlotCurve *>(getPlotObject(plot2dCurve));
           vectCurve[ig].push_back(plotCurve);
           // Modify the points' markers
-          QwtSymbol symbol(plotCurve->symbol()) ;
-          symbol.setStyle(symbolStyle1);
-          symbol.setPen(QPen(color1,lineWidth1));
+          QwtSymbol* symbol = new QwtSymbol(plotCurve->symbol()->style(), plotCurve->symbol()->brush(),
+                                            plotCurve->symbol()->pen(), plotCurve->symbol()->size()) ;
+          symbol->setStyle(symbolStyle1);
+          symbol->setPen(QPen(color1,lineWidth1));
           //symbol.setBrush( QBrush( color1));
           //QSize size = 0.5*(symbol.size());
           //symbol.setSize(size);
@@ -1002,7 +1019,7 @@ Plot2d_Curve* Plot2d_ViewFrame::createPlot2dCurve( QString & title,
   {
       if (!displayLegend)
         {
-          myPlot->insertLegend( (QwtLegend*)NULL);
+          myPlot->insertLegend( (QwtAbstractLegend*)NULL);
         }
       displayCurve( plot2dCurve);
 
@@ -1024,15 +1041,16 @@ Plot2d_Curve* Plot2d_ViewFrame::createPlot2dCurve( QString & title,
       }
 
       // Modify points' markers
-      QwtSymbol symbol (plotCurve->symbol()) ;
-      symbol.setStyle( markerKind);
+      QwtSymbol* symbol = new QwtSymbol( plotCurve->symbol()->style(), plotCurve->symbol()->brush(),
+                                            plotCurve->symbol()->pen(), plotCurve->symbol()->size() ) ;
+      symbol->setStyle( markerKind );
       //
       if (markerKind != QwtSymbol::NoSymbol)
       {
-          symbol.setPen( QPen( theColor, lineWidth));
-          symbol.setBrush( QBrush( theColor));
-          QSize size = 2.0*(symbol.size()); //0.5
-          symbol.setSize(size);
+        symbol->setPen( QPen( theColor, lineWidth));
+        symbol->setBrush( QBrush( theColor));
+        QSize size = 2.0*(symbol->size()); //0.5
+        symbol->setSize(size);
       }
 
       plotCurve->setSymbol( symbol);
@@ -1071,14 +1089,14 @@ QwtPlotCurve *Plot2d_ViewFrame::createSegment( double *X, double *Y, int nbPoint
                                                QColor & lineColor,
                                                QwtSymbol::Style markerKind, bool side)
 {
-  QwtPlotCurve* aPCurve = new QwtPlotCurve();
+  QwtPlotCurve* aPCurve = new QwtPlotCurve( QString::null );
 
-  aPCurve->setData( X, Y, nbPoint);
+  aPCurve->setSamples( X, Y, nbPoint);
 
   aPCurve->setPen( QPen( lineColor, lineWidth, lineKind));
-  QwtSymbol aSymbol;
-  aSymbol.setStyle( markerKind);
-  aPCurve->setSymbol( aSymbol);
+  QwtSymbol* aSymbol;
+  aSymbol->setStyle( markerKind );
+  aPCurve->setSymbol( aSymbol );
 
   // The segment must not have legend's entry
   aPCurve->setItemAttribute( QwtPlotItem::Legend, false);
@@ -1254,13 +1272,8 @@ QwtPlotItem* Plot2d_ViewFrame::displayObject( Plot2d_Object* object, bool update
       Plot2d_Curve* aCurve = dynamic_cast<Plot2d_Curve*>( object );
       if ( aCurve )
       {
-       //myMarkerSize = 1;
-        //aCurve->setMarkerSize( myMarkerSize );
-
-       if (aCurve->getMarkerSize() == 0)
-       {
-            aCurve->setMarkerSize( myMarkerSize );
-       }
+        if ( aCurve->getMarkerSize() == 0 )
+          aCurve->setMarkerSize( myMarkerSize );
 
         processFiltering(update);
         updatePlotItem( aCurve, anItem );
@@ -1409,10 +1422,12 @@ void Plot2d_ViewFrame::updateLegend( const Plot2d_Prs* prs )
   update legend
 */
 void Plot2d_ViewFrame::updateLegend() {
-  if ( myPlot->getLegend() ) {
-    ObjectDict::iterator it = myObjects.begin();
-    for( ; it != myObjects.end(); ++it )
-      it.key()->updateLegend(myPlot->getLegend());
+  const QwtPlotItemList& items = myPlot->itemList();
+  QwtPlotItemIterator it;
+  for ( it = items.begin(); it != items.end(); it++ ) {
+    QwtPlotItem* item = *it;
+    if ( item )
+      item->updateLegend( item, item->legendData() );
   }
 }
 
@@ -1422,14 +1437,7 @@ void Plot2d_ViewFrame::updateLegend() {
 */
 void Plot2d_ViewFrame::fitAll()
 {
-  // Postpone fitAll operation until QwtPlot geometry
-  // has been fully defined
-  if ( !myPlot->polished() ){
-    QApplication::postEvent( this, new QEvent( (QEvent::Type)FITALL_EVENT ) );
-    return;
-  }
-
-  // no need to set auto scaling, it wiil be disabled by setAxisScale() method call
+  // no need to set auto scaling, it will be disabled by setAxisScale() method call
   // myPlot->setAxisAutoScale( QwtPlot::yLeft );
   // myPlot->setAxisAutoScale( QwtPlot::xBottom );
   // myPlot->replot();
@@ -1708,9 +1716,11 @@ void Plot2d_ViewFrame::onSettings()
   if (mySecondY)
     dlg->setY2Title( myY2TitleEnabled, myY2Title );
   dlg->setCurveType( myCurveType );
-  dlg->setLegend( myShowLegend, myLegendPos, myLegendFont, myLegendColor );
+  dlg->setLegend( myShowLegend, myLegendPos, myLegendSymbolType, myLegendFont,
+                  myLegendColor, mySelectedLegendFontColor );
   dlg->setMarkerSize( myMarkerSize );
   dlg->setBackgroundColor( myBackground );
+  dlg->setSelectionColor( mySelectionColor );
   dlg->setScaleMode(myXMode, myYMode);
   dlg->setLMinNormMode(myNormLMin);
   dlg->setLMaxNormMode(myNormLMax);
@@ -1759,6 +1769,9 @@ void Plot2d_ViewFrame::onSettings()
     }
     if ( myLegendPos != dlg->getLegendPos() ) {
       setLegendPos( dlg->getLegendPos() );
+    }
+    if ( myLegendSymbolType != dlg->getLegendSymbolType() ) {
+      setLegendSymbolType( dlg->getLegendSymbolType() );
     }
        if ( myLegendFont != dlg->getLegendFont() ) {
       setLegendFont( dlg->getLegendFont() );
@@ -1766,6 +1779,9 @@ void Plot2d_ViewFrame::onSettings()
        if ( myLegendColor != dlg->getLegendColor() ) {
       setLegendFontColor( dlg->getLegendColor() );
     }
+    if ( mySelectedLegendFontColor != dlg->getSelectedLegendColor() ) {
+      setSelectedLegendFontColor( dlg->getSelectedLegendColor() );
+    }
 
     // marker size
     if ( myMarkerSize != dlg->getMarkerSize() ) {
@@ -1775,6 +1791,10 @@ void Plot2d_ViewFrame::onSettings()
     if ( myBackground != dlg->getBackgroundColor() ) {
       setBackgroundColor( dlg->getBackgroundColor() );
     }
+    // selection color
+    if ( mySelectionColor != dlg->getSelectionColor() ) {
+      setSelectionColor( dlg->getSelectionColor() );
+    }
     // grid
     bool aXGridMajorEnabled, aXGridMinorEnabled, aYGridMajorEnabled, aYGridMinorEnabled,
          aY2GridMajorEnabled, aY2GridMinorEnabled;
@@ -1850,9 +1870,9 @@ void Plot2d_ViewFrame::removeAnalyticalCurve( Plot2d_AnalyticalCurve* theCurve)
 void Plot2d_ViewFrame::updateAnalyticalCurve(Plot2d_AnalyticalCurve* c, bool updateView)
 {
   if(!c) return;
-  QwtScaleDiv* div = myPlot->axisScaleDiv(QwtPlot::xBottom);
-  c->setRangeBegin(div->lowerBound());
-  c->setRangeEnd(div->upperBound());
+  QwtScaleDiv div = myPlot->axisScaleDiv(QwtPlot::xBottom);
+  c->setRangeBegin(div.lowerBound());
+  c->setRangeEnd(div.upperBound());
   c->calculate();
   c->setMarkerSize(myMarkerSize);
   QwtPlotItem* item = c->plotItem();
@@ -1862,6 +1882,7 @@ void Plot2d_ViewFrame::updateAnalyticalCurve(Plot2d_AnalyticalCurve* c, bool upd
     if( c->isActive() ) {
       c->updatePlotItem();
       item->attach( myPlot );
+      item->itemChanged();
       item->show();
     }
     c->setAction(Plot2d_AnalyticalCurve::ActNothing);
@@ -2008,19 +2029,31 @@ void Plot2d_ViewFrame::showLegend( bool show, bool update )
 {
   myShowLegend = show;
   if ( myShowLegend ) {
-    QwtLegend* legend = myPlot->legend();
-    if ( !legend ) {
-      legend = new QwtLegend( myPlot );
+    QwtAbstractLegend* absLegend = myPlot->legend();
+    QwtLegend* legend = 0;
+    if ( !absLegend ) {
+      legend = new Plot2d_QwtLegend( myPlot );
+      legend->setDefaultItemMode(QwtLegendData::Clickable);
+      connect( legend, SIGNAL( clicked (const QVariant&, int) ),
+               this, SIGNAL( clicked (const QVariant&, int) ) );
       legend->setFrameStyle( QFrame::Box | QFrame::Sunken );
     }
-    legend->setItemMode( QwtLegend::ClickableItem );
-    myPlot->insertLegend( legend );
-    setLegendPos( myLegendPos );
-    setLegendFont( myLegendFont );
-    setLegendFontColor( myLegendColor );
+    else {
+      legend = dynamic_cast<QwtLegend*>(absLegend);
+    }
+    if(legend) {
+      myPlot->insertLegend( legend );
+      setLegendPos( myLegendPos );
+      setLegendFont( myLegendFont );
+      setLegendFontColor( myLegendColor );
+    }
   }
   else
     myPlot->insertLegend( 0 );
+
+  if( show && update )
+    updateLegend();
+
   if ( update )
     myPlot->replot();
 }
@@ -2031,7 +2064,7 @@ void Plot2d_ViewFrame::showLegend( bool show, bool update )
 void Plot2d_ViewFrame::setLegendPos( int pos )
 {
   myLegendPos = pos;
-  QwtLegend* legend = myPlot->legend();
+  QwtAbstractLegend* legend = myPlot->legend();
   if ( legend ) {
     switch( pos ) {
     case 0:
@@ -2058,13 +2091,31 @@ int Plot2d_ViewFrame::getLegendPos() const
   return myLegendPos;
 }
 
+/*!
+  Sets legend symbol type : 0 - marker on line, 1 - marker above line
+*/
+void Plot2d_ViewFrame::setLegendSymbolType( int type )
+{
+  myLegendSymbolType = type;
+  myPlot->setLegendSymbolType( type );
+  updateLegend();
+}
+
+/*!
+  Gets legend symbol type : 0 - marker on line, 1 - marker above line
+*/
+int Plot2d_ViewFrame::getLegendSymbolType() const
+{
+  return myLegendSymbolType;
+}
+
 /*!
   Sets legend font
 */
 void Plot2d_ViewFrame::setLegendFont( const QFont& fnt )
 {
   myLegendFont = fnt;
-  QwtLegend* legend = myPlot->legend();
+  QwtAbstractLegend* legend = myPlot->legend();
   if ( legend ) {
     legend->setFont(fnt);
   }
@@ -2078,21 +2129,13 @@ QFont Plot2d_ViewFrame::getLegendFont() const
   return myLegendFont;
 }
 
-/*!
-  Gets legend font color
-*/
-QColor Plot2d_ViewFrame::getLegendFontColor() const
-{
-  return myLegendColor;
-}
-
 /*!
   Sets legend font color
 */
 void Plot2d_ViewFrame::setLegendFontColor( const QColor& col )
 {
   myLegendColor = col;
-  QwtLegend* legend = myPlot->legend();
+  QwtAbstractLegend* legend = myPlot->legend();
   if ( legend ) {
     QPalette pal = legend->palette();
     pal.setColor( QPalette::Text, col );
@@ -2100,6 +2143,31 @@ void Plot2d_ViewFrame::setLegendFontColor( const QColor& col )
   }
 }
 
+/*!
+  Gets legend font color
+*/
+QColor Plot2d_ViewFrame::getLegendFontColor() const
+{
+  return myLegendColor;
+}
+
+/*!
+  Sets selected legend font color
+*/
+void Plot2d_ViewFrame::setSelectedLegendFontColor( const QColor& col )
+{
+  mySelectedLegendFontColor = col;
+  Plot2d_Object::setHighlightedLegendTextColor( col );
+}
+
+/*!
+  Gets selected legend font color
+*/
+QColor Plot2d_ViewFrame::getSelectedLegendFontColor() const
+{
+  return mySelectedLegendFontColor;
+}
+
 /*!
   Sets new marker size
 */
@@ -2114,11 +2182,11 @@ void Plot2d_ViewFrame::setMarkerSize( const int size, bool update )
       QwtPlotCurve* crv = it.key();
       if ( crv )
       {
-        QwtSymbol aSymbol = crv->symbol();
-        aSymbol.setSize( myMarkerSize, myMarkerSize );
+        QwtSymbol* aSymbol = new QwtSymbol( crv->symbol()->style(), crv->symbol()->brush(),
+                                                   crv->symbol()->pen(), QSize( myMarkerSize, myMarkerSize ) );
         crv->setSymbol( aSymbol );
-       if(it.value())
-         it.value()->setMarkerSize( myMarkerSize );
+        if( it.value() )
+             it.value()->setMarkerSize( myMarkerSize );
       }
     }
     if ( update )
@@ -2153,6 +2221,7 @@ void Plot2d_ViewFrame::setBackgroundColor( const QColor& color )
   }
   Repaint();
 }
+
 /*!
   Gets background color
 */
@@ -2160,6 +2229,24 @@ QColor Plot2d_ViewFrame::backgroundColor() const
 {
   return myBackground;
 }
+
+/*!
+  Sets selection color
+*/
+void Plot2d_ViewFrame::setSelectionColor( const QColor& color )
+{
+  mySelectionColor = color;
+  Plot2d_Object::setSelectionColor( color );
+}
+
+/*!
+  Gets selection color
+*/
+QColor Plot2d_ViewFrame::selectionColor() const
+{
+  return mySelectionColor;
+}
+
 /*!
   Sets hor.axis grid parameters
 */
@@ -2176,8 +2263,8 @@ void Plot2d_ViewFrame::setXGrid( bool xMajorEnabled, const int xMajorMax,
   myPlot->setAxisMaxMinor( QwtPlot::xBottom, myXGridMaxMinor );
 
   QwtPlotGrid* grid = myPlot->grid();
-  if ( myPlot->axisScaleDiv( QwtPlot::xBottom ) )
-    grid->setXDiv( *myPlot->axisScaleDiv( QwtPlot::xBottom ) );
+  if ( !myPlot->axisScaleDiv( QwtPlot::xBottom ).isEmpty() )
+    grid->setXDiv( myPlot->axisScaleDiv( QwtPlot::xBottom ) );
   grid->enableX( myXGridMajorEnabled );
   grid->enableXMin( myXGridMinorEnabled );
 
@@ -2213,8 +2300,8 @@ void Plot2d_ViewFrame::setYGrid( bool yMajorEnabled, const int yMajorMax,
   }
 
   QwtPlotGrid* grid = myPlot->grid();
-  if ( myPlot->axisScaleDiv( QwtPlot::yLeft ) )
-    grid->setYDiv( *myPlot->axisScaleDiv( QwtPlot::yLeft ) );
+  if ( !myPlot->axisScaleDiv( QwtPlot::yLeft ).isEmpty() )
+    grid->setYDiv( myPlot->axisScaleDiv( QwtPlot::yLeft ) );
 
   if (mySecondY) {
     if (myYGridMajorEnabled) {
@@ -2222,8 +2309,8 @@ void Plot2d_ViewFrame::setYGrid( bool yMajorEnabled, const int yMajorMax,
       grid->enableYMin( myYGridMinorEnabled );
     }
     else if (myY2GridMajorEnabled) {
-      if ( myPlot->axisScaleDiv( QwtPlot::yRight ) )
-        grid->setYDiv( *myPlot->axisScaleDiv( QwtPlot::yRight ) );
+      if ( !myPlot->axisScaleDiv( QwtPlot::yRight ).isEmpty() )
+        grid->setYDiv( myPlot->axisScaleDiv( QwtPlot::yRight ) );
       grid->enableY( myY2GridMajorEnabled );
       grid->enableYMin( myY2GridMinorEnabled );
     }
@@ -2341,6 +2428,12 @@ void Plot2d_ViewFrame::setHorScaleMode( const int mode, bool update )
 
   myXMode = mode;
 
+  // set bounds of logarithmic scale
+  if( myXMode != 0 ) {
+    myPlot->setAxisScale( QwtPlot::xBottom, 1.0, 1e5 );
+    myPlot->updateAxes();
+  }
+
   myPlot->setLogScale(QwtPlot::xBottom, myXMode != 0);
 
   if ( update )
@@ -2377,9 +2470,21 @@ void Plot2d_ViewFrame::setVerScaleMode( const int mode, bool update )
   }
 
   myYMode = mode;
+
+  // set bounds of logarithmic scale
+  if( myYMode != 0 ){
+    myPlot->setAxisScale( QwtPlot::yLeft, 1.0, 1e5 );
+    myPlot->updateAxes();
+  }
+
   myPlot->setLogScale(QwtPlot::yLeft, myYMode != 0);
-  if (mySecondY)
+  if (mySecondY) {
+    if( myYMode != 0 ){
+      myPlot->setAxisScale( QwtPlot::yRight, 1.0, 1e5 );
+      myPlot->updateAxes();
+    }
     myPlot->setLogScale( QwtPlot::yRight, myYMode != 0 );
+  }
 
   if ( update )
     fitAll();
@@ -2866,7 +2971,7 @@ void Plot2d_ViewFrame::setEnableAxis( QwtPlot::Axis theAxis, bool isEnable )
 class Plot2d_QwtPlotZoomer : public QwtPlotZoomer
 {
 public:
-  Plot2d_QwtPlotZoomer( int xAxis, int yAxis, QwtPlotCanvas* canvas )
+  Plot2d_QwtPlotZoomer( int xAxis, int yAxis, QWidget* canvas )
   : QwtPlotZoomer( xAxis, yAxis, canvas )
   {
     qApp->installEventFilter( this );
@@ -2881,7 +2986,6 @@ public:
 */
 Plot2d_Plot2d::Plot2d_Plot2d( QWidget* parent )
   : QwtPlot( parent ),
-    myIsPolished( false ),
     myPicker( 0 )
 {
   // Create alternative scales
@@ -2890,7 +2994,6 @@ Plot2d_Plot2d::Plot2d_Plot2d( QWidget* parent )
   setAxisScaleDraw( QwtPlot::yRight,  new Plot2d_ScaleDraw() );
 
   myPlotZoomer = new Plot2d_QwtPlotZoomer( QwtPlot::xBottom, QwtPlot::yLeft, canvas() );
-  myPlotZoomer->setSelectionFlags( QwtPicker::DragSelection | QwtPicker::CornerToCorner );
   myPlotZoomer->setTrackerMode( QwtPicker::AlwaysOff );
   myPlotZoomer->setRubberBand( QwtPicker::RectRubberBand );
   myPlotZoomer->setRubberBandPen( QColor( Qt::green ) );
@@ -2905,7 +3008,7 @@ Plot2d_Plot2d::Plot2d_Plot2d( QWidget* parent )
   myScaleDraw = NULL;
 // grid
   myGrid = new QwtPlotGrid();
-  QPen aMajPen = myGrid->majPen();
+  QPen aMajPen = myGrid->majorPen();
   aMajPen.setStyle( Qt::DashLine );
   myGrid->setPen( aMajPen );
 
@@ -2935,7 +3038,7 @@ Plot2d_Plot2d::~Plot2d_Plot2d()
 void Plot2d_Plot2d::setLogScale( int axisId, bool log10 )
 {
   if ( log10 )
-    setAxisScaleEngine( axisId, new QwtLog10ScaleEngine() );
+    setAxisScaleEngine( axisId, new QwtLogScaleEngine() );
   else
     setAxisScaleEngine( axisId, new QwtLinearScaleEngine() );
 }
@@ -2972,7 +3075,7 @@ void Plot2d_Plot2d::replot()
 /*!
   Get legend
 */
-QwtLegend* Plot2d_Plot2d::getLegend()
+QwtAbstractLegend* Plot2d_Plot2d::getLegend()
 {
 #if QWT_VERSION < 0x040200
   return d_legend;
@@ -3004,12 +3107,14 @@ void Plot2d_Plot2d::defaultPicker()
   myPlotZoomer->setMousePattern( QwtEventPattern::MouseSelect1,
                                  Qt::RightButton, Qt::ControlModifier ); // zooming button
   for ( int i = QwtEventPattern::MouseSelect2; i < QwtEventPattern::MouseSelect6; i++ )
-    myPlotZoomer->setMousePattern( i, Qt::NoButton, Qt::NoButton );
+    myPlotZoomer->setMousePattern( (QwtEventPattern::MousePatternCode)i, Qt::NoButton,
+                                      Qt::NoModifier );
 }
 
 void Plot2d_Plot2d::setPickerMousePattern( int button, int state )
 {
-  myPlotZoomer->setMousePattern( QwtEventPattern::MouseSelect1, button, state );
+  myPlotZoomer->setMousePattern( QwtEventPattern::MouseSelect1, (Qt::MouseButton)button,
+                                        (Qt::KeyboardModifiers)state );
 }
 
 /*!
@@ -3023,11 +3128,11 @@ void Plot2d_Plot2d::setPicker( Plot2d_QwtPlotPicker *picker)
 /*!
  * Create marker and tooltip associed with a point
  */
-QwtPlotMarker* Plot2d_Plot2d::createMarkerAndTooltip( QwtSymbol symbol,
-                                            double    X,
-                                            double    Y,
-                                            QString & tooltip,
-                                            Plot2d_QwtPlotPicker *picker)
+QwtPlotMarker* Plot2d_Plot2d::createMarkerAndTooltip( QwtSymbol* symbol,
+                                                      double    X,
+                                                      double    Y,
+                                                      QString & tooltip,
+                                                      Plot2d_QwtPlotPicker *picker)
 {
   QwtPlotMarker* aPlotMarker = new QwtPlotMarker();
 
@@ -3054,11 +3159,6 @@ QwtPlotMarker* Plot2d_Plot2d::createMarkerAndTooltip( QwtSymbol symbol,
   return aPlotMarker;
 }
 
-bool Plot2d_Plot2d::polished() const
-{
-  return myIsPolished;
-}
-
 QwtPlotGrid* Plot2d_Plot2d::grid() const
 {
   return myGrid;
@@ -3069,44 +3169,6 @@ QwtPlotZoomer* Plot2d_Plot2d::zoomer() const
   return myPlotZoomer;
 }
 
-/*!
-  Slot: checks the current labels format and change it if needed
-*/
-void Plot2d_Plot2d::onScaleDivChanged()
-{
-  QwtScaleWidget* aSW = 0;
-  if ( ( aSW = dynamic_cast<QwtScaleWidget*>(sender()) ) ) {
-    int axisId = -1;
-    switch ( aSW->alignment() ) {
-    case QwtScaleDraw::BottomScale:
-      axisId = QwtPlot::xBottom;
-      break;
-    case QwtScaleDraw::LeftScale:
-      axisId = QwtPlot::yLeft;
-      break;
-    case QwtScaleDraw::RightScale:
-      axisId = QwtPlot::yRight;
-      break;
-    default:
-      break;
-    }
-
-    if ( axisId >= 0 ) {
-      QwtScaleMap map = canvasMap(axisId);
-      double aDist = fabs(map.s2()-map.s1()) / (axisMaxMajor(axisId)*axisMaxMinor(axisId));
-
-      QString aDistStr;
-      aDistStr.sprintf("%e",aDist);
-      int aPrecision = aDistStr.right(aDistStr.length()-aDistStr.indexOf('e')-2).toInt();
-
-      QwtScaleDraw* aQwtSD = axisScaleDraw(axisId);
-      Plot2d_ScaleDraw* aPlot2dSD = dynamic_cast<Plot2d_ScaleDraw*>(aQwtSD);
-      if ( ( !aPlot2dSD && aPrecision > 6 ) || ( aPlot2dSD && aPlot2dSD->precision() != aPrecision ) )
-        setAxisScaleDraw( axisId, new Plot2d_ScaleDraw(*aQwtSD, 'f', aPrecision) );
-    }
-  }
-}
-
 /*!
   Updates identifiers of Y axis type in the legend.
 */
@@ -3131,19 +3193,10 @@ void Plot2d_Plot2d::updateYAxisIdentifiers()
     if ( Plot2d_QwtPlotCurve* aPCurve = dynamic_cast<Plot2d_QwtPlotCurve*>( item ) )
       aPCurve->setYAxisIdentifierEnabled( enableYLeft && enableYRight );
     if ( item && item->isVisible() && legend() )
-      item->updateLegend( legend() );
+      item->updateLegend( item, item->legendData() );
   }
 }
 
-/*!
-  Sets the flag saying that QwtPlot geometry has been fully defined.
-*/
-void Plot2d_Plot2d::polish()
-{
-  QwtPlot::polish();
-  myIsPolished = true;
-}
-
 // Methods to manage axis graduations
 
 /* Create definition and graduations of axes
@@ -3348,6 +3401,20 @@ void Plot2d_Plot2d::clearSeparationLineList()
   mySeparationLineList.clear();
 }
 
+/* Set type of legend symbol
+ */
+void Plot2d_Plot2d::setLegendSymbolType( const int type )
+{
+  myLegendSymbolType = type;
+}
+
+/* Get type of legend symbol
+ */
+int Plot2d_Plot2d::getLegendSymbolType()
+{
+  return myLegendSymbolType;
+}
+
 /*!
   Creates presentation of object
   Default implementation is empty
@@ -3369,8 +3436,12 @@ void Plot2d_ViewFrame::copyPreferences( Plot2d_ViewFrame* vf )
   myCurveType = vf->myCurveType;
   myShowLegend = vf->myShowLegend;
   myLegendPos = vf->myLegendPos;
+  myLegendSymbolType = vf->myLegendSymbolType;
+  myLegendFont = vf->myLegendFont;
+  mySelectedLegendFontColor = vf->mySelectedLegendFontColor;
   myMarkerSize = vf->myMarkerSize;
   myBackground = vf->myBackground;
+  mySelectionColor = vf->mySelectionColor;
   myTitle = vf->myTitle;
   myXTitle = vf->myXTitle;
   myYTitle = vf->myYTitle;
@@ -3507,22 +3578,24 @@ bool Plot2d_ViewFrame::print( const QString& file, const QString& format ) const
 
     if( pd )
     {
-      myPlot->print( *pd );
+      QwtPlotRenderer* pr = new QwtPlotRenderer();
+      pr->renderTo( myPlot, *pd );
       res = true;
       delete pd;
     }
   }
   return res;
 #endif
+
 }
 
 /**
  * Print Plot2d window
  */
-void Plot2d_ViewFrame::printPlot( QPainter* p, const QRect& rect,
-                                  const QwtPlotPrintFilter& filter ) const
+void Plot2d_ViewFrame::printPlot( QPainter* p, const QRectF& rect) const
 {
-  myPlot->print( p, rect, filter );
+  QwtPlotRenderer* pr = new QwtPlotRenderer();
+  pr->render( myPlot, p, rect );
 }
 
 /*!
@@ -3939,7 +4012,7 @@ void Plot2d_ViewFrame::updatePlotItem(Plot2d_Object* theObject, QwtPlotItem* the
         xNew[j] = itTmp.value().at(j).first;
         yNew[j] = itTmp.value().at(j).second;
       }
-      cu->setData(xNew, yNew,j);
+      cu->setSamples(xNew, yNew,j);
       delete [] xNew;
       delete [] yNew;
       if(aNormAlgo->getNormalizationMode() != Plot2d_NormalizeAlgorithm::NormalizeNone) {
@@ -3957,7 +4030,7 @@ void Plot2d_ViewFrame::updatePlotItem(Plot2d_Object* theObject, QwtPlotItem* the
  */
 QwtPlotCanvas* Plot2d_ViewFrame::getPlotCanvas() const
 {
-  return myPlot ? myPlot->canvas() : 0;
+  return myPlot ? (QwtPlotCanvas*)myPlot->canvas() : 0;
 }
 
 /*!
@@ -4108,21 +4181,13 @@ Plot2d_ScaleDraw::Plot2d_ScaleDraw( char f, int prec )
   invalidateCache();
 }
 
-Plot2d_ScaleDraw::Plot2d_ScaleDraw( const QwtScaleDraw& scaleDraw, char f, int prec )
-  : QwtScaleDraw(scaleDraw),
-    myFormat(f),
-    myPrecision(prec)
-{
-  invalidateCache();
-}
-
 QwtText Plot2d_ScaleDraw::label( double value ) const
 {
-  QwtScaleMap m = map();
+  QwtScaleMap m = scaleMap();
   QString str1 = QwtScaleDraw::label( m.s1() ).text();
   QString str2 = QwtScaleDraw::label( m.s2() ).text();
   if ( str1 == str2 ) {
-    double aDist = fabs(map().s2()-map().s1())/5;
+    double aDist = fabs(scaleMap().s2()-scaleMap().s1())/5;
     int precision = 0;
     while (aDist < 1 ) {
       precision++;
@@ -4206,9 +4271,13 @@ void Plot2d_AxisScaleDraw::draw( QPainter* painter, const QPalette & palette) co
   major_ticks.clear();
 
   major_ticks.append( myTicks);
-  myPlot->axisScaleDiv(QwtPlot::xBottom)->setTicks(QwtScaleDiv::MajorTick,  major_ticks);
-  myPlot->axisScaleDiv(QwtPlot::xBottom)->setTicks(QwtScaleDiv::MediumTick, medium_ticks);
-  myPlot->axisScaleDiv(QwtPlot::xBottom)->setTicks(QwtScaleDiv::MinorTick,  minor_ticks);
+
+  QwtScaleDiv aScaleDiv = myPlot->axisScaleDiv( QwtPlot::xBottom );
+  aScaleDiv.setTicks( QwtScaleDiv::MajorTick,  major_ticks );
+  aScaleDiv.setTicks( QwtScaleDiv::MediumTick, medium_ticks );
+  aScaleDiv.setTicks( QwtScaleDiv::MinorTick,  minor_ticks );
+  myPlot->setAxisScaleDiv( QwtPlot::xBottom, aScaleDiv );
+
   QwtScaleDraw *scale = myPlot->axisScaleDraw(QwtPlot::xBottom);
   ((Plot2d_AxisScaleDraw*)(scale))->applyTicks();
 
@@ -4282,9 +4351,11 @@ void Plot2d_AxisScaleDraw::applyTicks()
   medium_ticks.clear();
   minor_ticks.clear();
 
-  myPlot->axisScaleDiv(QwtPlot::xBottom)->setTicks(QwtScaleDiv::MajorTick, myTicks);
-  myPlot->axisScaleDiv(QwtPlot::xBottom)->setTicks(QwtScaleDiv::MediumTick, medium_ticks);
-  myPlot->axisScaleDiv(QwtPlot::xBottom)->setTicks(QwtScaleDiv::MinorTick, minor_ticks);
+  QwtScaleDiv aQwtScaleDiv = myPlot->axisScaleDiv( QwtPlot::xBottom );
+  aQwtScaleDiv.setTicks( QwtScaleDiv::MajorTick, myTicks );
+  aQwtScaleDiv.setTicks( QwtScaleDiv::MediumTick, medium_ticks );
+  aQwtScaleDiv.setTicks( QwtScaleDiv::MinorTick, minor_ticks );
+  myPlot->setAxisScaleDiv( QwtPlot::xBottom, aQwtScaleDiv );
 
   QwtScaleDiv* aScaleDiv = (QwtScaleDiv*) &scaleDiv();
 
@@ -4315,7 +4386,7 @@ void Plot2d_AxisScaleDraw::drawLabel( QPainter* painter, double value) const
       //const char *c_label = std_label.c_str();
       //std::cout << "    deviceLabel= |" << c_label << "|" << std::endl;
 
-      QPoint p = labelPosition( value );
+      QPointF p = labelPosition( value );
       p += QPoint(0, DEVICE_BY);
       QFont  prevf = painter->font();
       //QColor prevc = (painter->pen()).color();
@@ -4359,13 +4430,11 @@ const double Plot2d_QwtPlotPicker::BOUND_HV_SIZE = 0.2;
 
 Plot2d_QwtPlotPicker::Plot2d_QwtPlotPicker( int            xAxis,
                                             int            yAxis,
-                                            int            selectionFlags,
                                             RubberBand     rubberBand,
                                             DisplayMode    trackerMode,
                                             QwtPlotCanvas *canvas)
 : QwtPlotPicker( xAxis,
                  yAxis,
-                 selectionFlags,
                  rubberBand,
                  trackerMode,
                  canvas)    // of drawing zone QwtPlot
@@ -4388,20 +4457,30 @@ Plot2d_QwtPlotPicker::~Plot2d_QwtPlotPicker()
 
 /* Return the tooltip associated with a point when the mouse cursor pass near
  */
-QwtText Plot2d_QwtPlotPicker::trackerText( const QwtDoublePoint & pos ) const
+QwtText Plot2d_QwtPlotPicker::trackerText( const QPoint & pos ) const
 {
   for (QList<QwtPlotMarker* >::const_iterator pMarkerIt = pMarkers.begin();pMarkerIt != pMarkers.end(); ++pMarkerIt )
     {
       QwtPlotMarker* pMarker = *pMarkerIt;
       if ( pMarker != NULL )
         {
-          const QwtSymbol &symb=pMarker->symbol();
-          const QSize& sz=symb.size();
+          const QwtSymbolsymb=pMarker->symbol();
+          const QSize& sz=symb->size();
           const QwtScaleMap yMapRef=plot()->canvasMap(QwtPlot::yLeft);
           const QwtScaleMap xMap=plot()->canvasMap(pMarker->xAxis());
           const QwtScaleMap yMap=plot()->canvasMap(pMarker->yAxis());
           QwtDoubleRect  bound0=pMarker->boundingRect();
-          QRect bound00=pMarker->transform(xMap,yMap,bound0);
+          int x1 = qRound(xMap.transform(bound0.left()));
+          int x2 = qRound(xMap.transform(bound0.right()));
+          int y1 = qRound(yMap.transform(bound0.top()));
+          int y2 = qRound(yMap.transform(bound0.bottom()));
+         
+          if ( x2 < x1 )
+            qSwap(x1, x2);
+          if ( y2 < y1 )
+            qSwap(y1, y2);
+         
+          QRect bound00=QRect(x1, y1, x2 - x1 + 1, y2 - y1 + 1);
           QPoint toto(xMap.transform(pos.x()),yMapRef.transform(pos.y()));
           bound00.setX(bound00.x()-sz.width());
           bound00.setY(bound00.y()-sz.height());
index c8ea7bd2fa67a8c71763de29c9007718ff684481..0a6f202142d46a1b3fff34900a1af81cda4b792a 100755 (executable)
@@ -39,6 +39,8 @@
 #include <qwt_scale_draw.h>
 #include <qwt_plot_marker.h>
 #include <qwt_plot_picker.h>
+#include <qwt_plot_canvas.h>
+#include <qwt_legend.h>
 
 #include <iostream>
 #include <ostream>
@@ -74,6 +76,7 @@ public:
   virtual ~Plot2d_ViewFrame();
 
   void Init();
+  void SetPreference();
 
   enum ObjectType { MainTitle, XTitle, YTitle, Y2Title, XAxis, YAxis, Y2Axis };
 
@@ -186,14 +189,20 @@ public:
   void           showLegend( bool, bool = true );
   void           setLegendPos( int );
   int            getLegendPos() const;
+  void           setLegendSymbolType( int );
+  int            getLegendSymbolType() const;
   void           setLegendFont( const QFont& );
   QFont          getLegendFont() const;
   void           setLegendFontColor( const QColor& );
   QColor         getLegendFontColor() const;
+  void           setSelectedLegendFontColor( const QColor& );
+  QColor         getSelectedLegendFontColor() const;
   void           setMarkerSize( const int, bool = true  );
   int            getMarkerSize() const;
   virtual void   setBackgroundColor( const QColor& );
   QColor         backgroundColor() const;
+  virtual void   setSelectionColor( const QColor& );
+  QColor         selectionColor() const;
   void           setXGrid( bool, const int, bool, const int, bool = true );
   void           setYGrid( bool, const int, bool, const int,
                           bool, const int, bool, const int, bool = true );
@@ -232,8 +241,7 @@ public:
   void           setEnableAxis( QwtPlot::Axis, bool );
 
   virtual bool   print( const QString&, const QString& ) const;
-  void           printPlot( QPainter*, const QRect&,
-                           const QwtPlotPrintFilter& = QwtPlotPrintFilter() ) const;
+  void           printPlot( QPainter*, const QRectF& ) const;
 
   QString        getVisualParameters();
   void           setVisualParameters( const QString& );
@@ -294,7 +302,7 @@ signals:
   void           vpNormRModeChanged();
   void           vpCurveChanged();
   void           contextMenuRequested( QContextMenuEvent* );
-  void           legendClicked( QwtPlotItem* );
+  void           clicked (const QVariant&, int );
 
 protected:
   Plot2d_Plot2d*      myPlot;
@@ -304,10 +312,13 @@ protected:
   int                 myCurveType;
   bool                myShowLegend;
   int                 myLegendPos;
+  int                 myLegendSymbolType;
   QFont               myLegendFont;
   QColor              myLegendColor;
+  QColor              mySelectedLegendFontColor;
   int                 myMarkerSize;
   QColor              myBackground;
+  QColor              mySelectionColor;
   QString             myTitle, myXTitle, myYTitle, myY2Title;
   bool                myTitleEnabled, myXTitleEnabled, myYTitleEnabled, myY2TitleEnabled;
   bool                myXGridMajorEnabled, myYGridMajorEnabled, myY2GridMajorEnabled;
@@ -343,26 +354,27 @@ public:
   Plot2d_Plot2d( QWidget* );
   virtual ~Plot2d_Plot2d();
 
-  void           setLogScale( int, bool );
+  void               setLogScale( int, bool );
 
-  void           replot();
-  QwtLegend*     getLegend();
-  QSize          sizeHint() const;
-  QSize          minimumSizeHint() const;
-  void           defaultPicker();
-  void           setPickerMousePattern( int, int = Qt::NoButton );
-  void           setPicker( Plot2d_QwtPlotPicker *picker);
+  void               replot();
+  QwtAbstractLegend* getLegend();
+  QSize              sizeHint() const;
+  QSize              minimumSizeHint() const;
+  void               defaultPicker();
+  void               setPickerMousePattern( int, int = Qt::NoButton );
+  void               setPicker( Plot2d_QwtPlotPicker *picker);
   Plot2d_QwtPlotPicker* getPicker() { return myPicker; }
   Plot2d_AxisScaleDraw* getScaleDraw() { return myScaleDraw; }
   QList<QwtPlotMarker*> getSeparationLineList() { return mySeparationLineList; }
   void clearSeparationLineList();
-  QwtPlotMarker *createMarkerAndTooltip( QwtSymbol symbol,
-                               double    X,
-                               double    Y,
-                               QString & tooltip,
-                               Plot2d_QwtPlotPicker *picker);
+  void setLegendSymbolType( const int );
+  int  getLegendSymbolType();
+  QwtPlotMarker *createMarkerAndTooltip( QwtSymbol* symbol,
+                                         double    X,
+                                         double    Y,
+                                         QString & tooltip,
+                                         Plot2d_QwtPlotPicker *picker);
 
-  bool           polished() const;
   QwtPlotGrid*   grid() const;
   QwtPlotZoomer* zoomer() const;
 
@@ -380,17 +392,9 @@ public:
 
   void createSeparationLine( double Xpos);
 
-
-public slots:
-  virtual void   polish();
-
-protected slots:
-  void           onScaleDivChanged();
-
 protected:
   QwtPlotGrid*   myGrid;
   QList<QColor>  myColors;
-  bool           myIsPolished;
   QwtPlotZoomer* myPlotZoomer;
   Plot2d_AxisScaleDraw* myScaleDraw;
   // The point picker associated with the graphic view
@@ -398,13 +402,13 @@ protected:
 private:
   // List of verticals segments between two curves
   QList<QwtPlotMarker*> mySeparationLineList;
+  int myLegendSymbolType;
 };
 
 class Plot2d_ScaleDraw: public QwtScaleDraw
 {
 public:
   Plot2d_ScaleDraw( char f = 'g', int prec = 6 );
-  Plot2d_ScaleDraw( const QwtScaleDraw& scaleDraw, char f = 'g', int prec = 6 );
 
   virtual QwtText label( double value ) const;
 
@@ -486,7 +490,6 @@ public:
 
   Plot2d_QwtPlotPicker( int            xAxis,
                         int            yAxis,
-                        int            selectionFlags,
                         RubberBand     rubberBand,
                         DisplayMode    trackerMode,
                         QwtPlotCanvas *canvas);
@@ -502,7 +505,7 @@ public:
 
 protected:
 
-  virtual QwtText trackerText( const QwtDoublePoint & pos ) const;
+  virtual QwtText trackerText( const QPoint & pos ) const;
 
 };
 
index 5e3a18b04fca2de82a96dfae6a5532ef51a02104..1ee5059e47353da727c3bd82e5f4407f5b651494 100755 (executable)
@@ -66,8 +66,8 @@ bool Plot2d_ViewManager::insertView( SUIT_ViewWindow* theView )
 
     Plot2d_ViewFrame* aViewFrame = view->getViewFrame();
     Plot2d_Viewer* aViewer = getPlot2dModel();
-    connect( aViewFrame, SIGNAL( legendClicked( QwtPlotItem* ) ), 
-             aViewer, SLOT( onLegendClicked( QwtPlotItem* ) ) );
+    connect( aViewFrame, SIGNAL( clicked(const QVariant&, int) ),
+             aViewer, SLOT( onClicked(const QVariant&, int) ) );
   }
   return res;
 }
index d7c4d242810d83b81218a9f8be0ce0d6f2ab7ac0..23e5893f068baa3df32d7160cf99beb75469a132 100755 (executable)
@@ -40,7 +40,8 @@ Plot2d_Viewer::Plot2d_Viewer(bool theAutoDel)
 {
   myPrs = 0;
   myAutoDel = theAutoDel;
-  Plot2d_Object::initColors();
+  Plot2d_Object::setSelectionColor( QColor(80,80,80) );
+  Plot2d_Object::setHighlightedLegendTextColor( QColor(255,255,255) );
 }
 
 /*!
@@ -219,7 +220,7 @@ void Plot2d_Viewer::onCloneView( Plot2d_ViewFrame* clonedVF, Plot2d_ViewFrame* n
 /*
   SLOT: called when clicked item in the legend from Plot2d_ViewManager
  */
-void Plot2d_Viewer::onLegendClicked( QwtPlotItem* plotItem )
+void Plot2d_Viewer::onClicked(const QVariant& itemInfo, int index)
 {
 }
 
index d8326c8f87570e2c169e4cfe75865b39094bf9bd..34ffd843aaff7f4c1c2fa4064436155fab239b49 100755 (executable)
@@ -62,7 +62,7 @@ protected slots:
   void         onDumpView();
   void         onShowToolbar();
   virtual void onCloneView( Plot2d_ViewFrame*, Plot2d_ViewFrame* );
-  virtual void onLegendClicked( QwtPlotItem* );
+  virtual void onClicked( const QVariant&, int );
 
 private:
   Plot2d_Prs* myPrs;
index c222b1660a8af5c1a6e5be021b74a4510773ce5a..98ce2d862c220e0f1565cf3599d998bb137777a2 100755 (executable)
@@ -864,7 +864,7 @@ void Plot2d_ViewWindow::onPrintView()
   }
 
   QMap< QwtPlotCurve*, QPen > aCurvToPen;
-  QMap< QwtPlotCurve*, QwtSymbol > aCurvToSymbol;
+  QMap< QwtPlotCurve*, QwtSymbol* > aCurvToSymbol;
 
   if ( needColorCorrection )
   {
@@ -889,12 +889,12 @@ void Plot2d_ViewWindow::onPrintView()
       aCurve->setPen( aPen );
 
       // symbol
-      QwtSymbol aSymbol = aCurve->symbol();
+      QwtSymbol* aSymbol = const_cast<QwtSymbol*>( aCurve->symbol() );
       aCurvToSymbol[ aCurve ] = aSymbol;
-      aPen = aSymbol.pen();
+      aPen = aSymbol->pen();
       aPen.setColor( QColor( 0, 0, 0 ) );
       aPen.setWidthF( 1.5 );
-      aSymbol.setPen( aPen );
+      aSymbol->setPen( aPen );
 
       aCurve->setSymbol( aSymbol );
     }
index 3f7bea97e4f6644865e51b28e1796664b583d159..ff29205857c08b5da5218e5549ad72612a423414 100644 (file)
         <source>PLOT2D_BACKGROUND_COLOR_LBL</source>
         <translation>Background color:</translation>
     </message>
+    <message>
+        <source>PLOT2D_SELECTION_COLOR_LBL</source>
+        <translation>Selection color:</translation>
+    </message>
     <message>
         <source>PLOT2D_DEVIATION_MARKER_TLT</source>
         <translation>Deviation marker</translation>
@@ -565,6 +569,34 @@ Logarithmic scale for ordinate axis is not allowed.</translation>
         <source>PLOT2D_ENABLE_MAIN_TITLE</source>
         <translation>Main title</translation>
     </message>
+    <message>
+        <source>PLOT2D_LEGEND_GROUP</source>
+        <translation>Legend</translation>
+    </message>
+    <message>
+        <source>PLOT2D_LEGEND_POSITION</source>
+        <translation>Legend position:</translation>
+    </message>
+    <message>
+        <source>PLOT2D_LEGEND_SYMBOL_TYPE</source>
+        <translation>Symbol type:</translation>
+    </message>
+    <message>
+        <source>PLOT2D_MARKER_ABOVE_LINE</source>
+        <translation>Marker above line</translation>
+    </message>
+    <message>
+        <source>PLOT2D_MARKER_ON_LINE</source>
+        <translation>Marker on line</translation>
+    </message>
+    <message>
+        <source>PLOT2D_LEGEND_FONT_COLOR</source>
+        <translation>Legend font color:</translation>
+    </message>
+    <message>
+        <source>PLOT2D_SELECTED_LEGEND_FONT_COLOR</source>
+        <translation>Highlighted legend font color:</translation>
+    </message> 
     <message>
         <source>TOT_PLOT2D_CURVES_LINES</source>
         <translation>Draw lines</translation>
index e4796f09a9274da8f31e8a0506c902d53772d4b1..adf71c2728195de9fbf5999f06523e9f86c6508a 100755 (executable)
     <message>
         <source>TOT_PLOT2D_ANALYTICAL_CURVES</source>
         <translation>Courbes analytiques</translation>
-    </message>     
+    </message>
     <message>
         <source>TOT_PLOT2D_NORMALIZE_MODE_LMAX</source>
         <translation>Axe Y gauche: Normaliser sur le maximum global</translation>
-    </message>    
+    </message>
     <message>
         <source>TOT_PLOT2D_NORMALIZE_MODE_LMIN</source>
         <translation>Axe Y gauche: Normaliser sur le minimum global</translation>
-    </message>    
+    </message>
     <message>
         <source>TOT_PLOT2D_NORMALIZE_MODE_RMAX</source>
         <translation>Axe Y droite: Normaliser sur le maximum global</translation>
-    </message>    
+    </message>
     <message>
         <source>TOT_PLOT2D_NORMALIZE_MODE_RMIN</source>
         <translation>Axe Y droite: Normaliser sur le minimum global</translation>
-    </message>     
+    </message>
     <message>
         <source>PLOT2D_CURVE_TYPE_LINES</source>
         <translation>Lignes</translation>
         <source>PLOT2D_BACKGROUND_COLOR_LBL</source>
         <translation>Couleur d&apos;arrière-plan:</translation>
     </message>
+    <message>
+        <source>PLOT2D_SELECTION_COLOR_LBL</source>
+        <translation>Couleur de sélection:</translation>
+    </message>
     <message>
         <source>PLOT2D_DEVIATION_MARKER_TLT</source>
         <translation>Marqueur de déviation</translation>
@@ -419,19 +423,19 @@ L&apos;échelle logarithmique de l&apos;ordonnée n&apos;est pas permise.</trans
     </message>
     <message>
         <source>PRP_PLOT2D_NORMALIZE_MODE_LMAX</source>
-        <translation>Bascule la vue vers le mode de normalisation sur le maximum pour l'axe Y gauche</translation>
+        <translation>Bascule la vue vers le mode de normalisation sur le maximum pour l&apos;axe Y gauche</translation>
     </message>
     <message>
         <source>PRP_PLOT2D_NORMALIZE_MODE_LMIN</source>
-        <translation>Bascule la vue vers le mode de normalisation sur le minimum pour l'axe Y gauche</translation>
+        <translation>Bascule la vue vers le mode de normalisation sur le minimum pour l&apos;axe Y gauche</translation>
     </message>
     <message>
         <source>PRP_PLOT2D_NORMALIZE_MODE_RMAX</source>
-        <translation>Bascule la vue vers le mode de normalisation sur le maximum pour l'axe Y droite</translation>
+        <translation>Bascule la vue vers le mode de normalisation sur le maximum pour l&apos;axe Y droite</translation>
     </message>
     <message>
         <source>PRP_PLOT2D_NORMALIZE_MODE_RMIN</source>
-        <translation>Bascule la vue vers le mode de normalisation sur le minimum pour l'axe Y droite</translation>
+        <translation>Bascule la vue vers le mode de normalisation sur le minimum pour l&apos;axe Y droite</translation>
     </message>
     <message>
         <source>PRP_PLOT2D_SETTINGS</source>
@@ -565,6 +569,34 @@ L&apos;échelle logarithmique de l&apos;ordonnée n&apos;est pas permise.</trans
         <source>PLOT2D_ENABLE_MAIN_TITLE</source>
         <translation>Titre principal</translation>
     </message>
+    <message>
+        <source>PLOT2D_LEGEND_GROUP</source>
+        <translation>Légende</translation>
+    </message>
+    <message>
+        <source>PLOT2D_LEGEND_POSITION</source>
+        <translation>Position de la Légende:</translation>
+    </message>
+    <message>
+        <source>PLOT2D_LEGEND_SYMBOL_TYPE</source>
+        <translation>Type de symbole:</translation>
+    </message>
+    <message>
+        <source>PLOT2D_MARKER_ABOVE_LINE</source>
+        <translation>Marqueur dessus de la ligne</translation>
+    </message>
+    <message>
+        <source>PLOT2D_MARKER_ON_LINE</source>
+        <translation>Marqueur sur la ligne</translation>
+    </message>
+    <message>
+        <source>PLOT2D_LEGEND_FONT_COLOR</source>
+        <translation>Couleur de police de la légende:</translation>
+    </message>
+    <message>
+        <source>PLOT2D_SELECTED_LEGEND_FONT_COLOR</source>
+        <translation>Couleur de surlignement de la légende:</translation>
+    </message>
     <message>
         <source>TOT_PLOT2D_CURVES_LINES</source>
         <translation>Dessiner des lignes</translation>
@@ -696,7 +728,7 @@ L&apos;échelle logarithmique de l&apos;ordonnée n&apos;est pas permise.</trans
     <name>Plot2d_AnalyticalCurveDlg</name>
     <message>
         <source>AC_OK_BTN</source>
-        <translation type="unfinished">Ok</translation>
+        <translation>Ok</translation>
     </message>
     <message>
         <source>ANALYTICAL_CURVE_TLT</source>
@@ -705,15 +737,15 @@ L&apos;échelle logarithmique de l&apos;ordonnée n&apos;est pas permise.</trans
     <message>
         <source>AC_CURVE_PARAMS</source>
         <translation>Paramètres de la courbe</translation>
-    </message>    
+    </message>
     <message>
         <source>AC_CURVE_PROPS</source>
         <translation>Propriétés de la courbe</translation>
-    </message>        
+    </message>
     <message>
         <source>AC_FORMULA</source>
         <translation>y(x) = </translation>
-    </message>            
+    </message>
     <message>
         <source>AC_NB_INTERVALS</source>
         <translation>Nb. intervalles</translation>
@@ -741,19 +773,19 @@ L&apos;échelle logarithmique de l&apos;ordonnée n&apos;est pas permise.</trans
     <message>
         <source>AC_ADD_BTN</source>
         <translation>Ajouter une courbe</translation>
-    </message>                
+    </message>
     <message>
         <source>AC_REM_BTN</source>
         <translation>Supprimer une courbe</translation>
-    </message>                    
+    </message>
     <message>
         <source>AC_UPD_BTN</source>
         <translation>Mettre à jour la courbe</translation>
-    </message>                    
+    </message>
     <message>
         <source>AC_APPLY_BTN</source>
         <translation>Appliquer</translation>
-    </message>                    
+    </message>
     <message>
         <source>AC_CANT_CALCULATE</source>
         <translation>La courbe ne peut pas être calculée. 
index 052384f1a6e3132d050f781eb3790cf05c61ebf5..c9f34f528f9a7615e9bf4779ea3128a9c413b5d3 100644 (file)
@@ -1,12 +1,8 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!DOCTYPE TS>
-<TS>
+<TS version="2.0" language="ja" sourcelanguage="en">
   <context>
     <name>@default</name>
-    <message>
-        <source>PDF_FILES</source>
-        <translation type="unfinished">PDF files (*.pdf)</translation>
-    </message>
     <message>
       <source>PLOT2D_CURVE_TYPE_LBL</source>
       <translation>曲線の種類:</translation>
       <source>ENCAPSULATED_POSTSCRIPT_FILES</source>
       <translation>カプセル化された PostScript (*.eps) ファイル</translation>
     </message>
+    <message>
+      <source>PDF_FILES</source>
+      <translation>PDF files (*.pdf)</translation>
+    </message>
     <message>
       <source>DSC_GLOBALPAN_VIEW</source>
       <translation>ビューの新しい中心地の選択</translation>
       <source>PLOT2D_BACKGROUND_COLOR_LBL</source>
       <translation>背景色:</translation>
     </message>
+    <message>
+      <source>PLOT2D_SELECTION_COLOR_LBL</source>
+      <translation>選択色:</translation>
+    </message>
     <message>
       <source>PLOT2D_DEVIATION_MARKER_TLT</source>
       <translation>バイパス マーカー</translation>
       <source>PLOT2D_ENABLE_MAIN_TITLE</source>
       <translation>主なタイトル</translation>
     </message>
+    <message>
+      <source>PLOT2D_LEGEND_GROUP</source>
+      <translation>凡例</translation>
+    </message>
+    <message>
+      <source>PLOT2D_LEGEND_POSITION</source>
+      <translation>凡例の位置</translation>
+    </message>
+    <message>
+      <source>PLOT2D_LEGEND_SYMBOL_TYPE</source>
+      <translation>シンボルタイプ:</translation>
+    </message>
+    <message>
+      <source>PLOT2D_MARKER_ABOVE_LINE</source>
+      <translation>線の上のマーカー</translation>
+    </message>
+    <message>
+      <source>PLOT2D_MARKER_ON_LINE</source>
+      <translation>線上のマーカー</translation>
+    </message>
+    <message>
+      <source>PLOT2D_LEGEND_FONT_COLOR</source>
+      <translation>凡例フォントの色:</translation>
+    </message>
+    <message>
+      <source>PLOT2D_SELECTED_LEGEND_FONT_COLOR</source>
+      <translation>ハイライト凡例フォントの色:</translation>
+    </message>
     <message>
       <source>TOT_PLOT2D_CURVES_LINES</source>
       <translation>線を描く</translation>
index 851da035c26e57d83a1c8bedf1024c9158b194ba..adb5a6d7ae9b72da5b2098272464734ee04d20ed 100644 (file)
@@ -190,6 +190,9 @@ PyConsole_Editor::PyConsole_Editor( PyConsole_Interp* theInterp,
 */
 PyConsole_Editor::~PyConsole_Editor()
 {
+  myInterp->destroy();
+  delete myInterp;
+  myInterp = 0;
 }
 
 /*!
index 81fc033a386fed2bfdf41bdfd78c718581243faf..8915f07656c90eef32e14f840f735a86a2d49e6c 100644 (file)
@@ -73,7 +73,7 @@ int PyConsole_EnhInterp::runDirCommand(const QString & dirArgument, const QStrin
       if (dirArgument.trimmed() != "")
         cmd = dirArgument + ".";
       cmd += _last_matches[0] + ".__doc__";
-      PyObject * str = PyRun_String(cmd.toStdString().c_str(), Py_eval_input, _g, _g);
+      PyObject * str = PyRun_String(cmd.toStdString().c_str(), Py_eval_input, _context, _context);
       if (!str || str == Py_None || !PyString_Check(str))
         {
           if (!str)
@@ -104,7 +104,7 @@ int PyConsole_EnhInterp::runDirAndExtract(const QString& dirArgument,
 {
   QRegExp re("^[A-Z].+_[A-Z]+[a-z]+.+$");  // discard SWIG static method, e.g. MEDCouplingUMesh_Blabla
   QString command("dir(" + dirArgument + ")");
-  PyObject * plst = PyRun_String(command.toStdString().c_str(), Py_eval_input, _g, _g);
+  PyObject * plst = PyRun_String(command.toStdString().c_str(), Py_eval_input, _context, _context);
   if(!plst || plst == Py_None) {
     if(!plst)
       PyErr_Clear();
index ee04ddb161f83b2a50159443683a047da970ed9b..c4b208180bb5c4a8d1c23cfe21bd4606afda42f9 100644 (file)
   \class PyConsole_Interp
   \brief Python interpreter to be embedded to the SALOME study's GUI.
 
-  Python interpreter is created one per SALOME study.
+  There is only one Python interpreter for the whole SALOME environment.
 
-  Call initialize method defined in the base class PyInterp_Interp,
-  to intialize interpreter after instance creation.
+  Call the initialize() method defined in the base class PyInterp_Interp,
+  to initialize the interpreter after instance creation.
 
   The method initialize() calls virtuals methods
   - initPython()  to initialize global Python interpreter
-  - initState()   to initialize embedded interpreter state
+  //- initState()   to initialize embedded interpreter state (OBSOLETE)
   - initContext() to initialize interpreter internal context
   - initRun()     to prepare interpreter for running commands
-
-  /EDF-CCAR/
-  When SALOME uses multi Python interpreter feature, 
-  every study has its own interpreter and thread state (_tstate = Py_NewInterpreter()).
-  This is fine because every study has its own modules (sys.modules) stdout and stderr.
-
-  <b>But</b> some Python modules must be imported only once. In multi interpreter 
-  context Python modules (*.py) are imported several times.
-  For example, the PyQt module must be imported only once because 
-  it registers classes in a C module.
-
-  It's quite the same with omniorb modules (internals and generated with omniidl).
-
-  This problem is handled with "shared modules" defined in salome_shared_modules.py.
-  These "shared modules" are imported only once and only copied in all 
-  the other interpreters.
-
-  <b>But</b> it's not the only problem. Every interpreter has its own 
-  __builtin__ module. That's fine but if we have copied some modules 
-  and imported others problems may arise with operations that are not allowed
-  in restricted execution environment. So we must impose that all interpreters
-  have identical __builtin__ module.
 */
 
 /*!
@@ -83,42 +61,6 @@ PyConsole_Interp::~PyConsole_Interp()
 {
 }
  
-/*!
-  \brief Initialize internal Python interpreter state.
-
-  When calling initState the GIL is not held
-  It must not be held on exit
-
-  \return \c true on success
-*/
-bool PyConsole_Interp::initState()
-{
-  PyEval_AcquireLock();
-  _tstate = Py_NewInterpreter(); // create an interpreter and save current state
-  PySys_SetArgv(PyInterp_Interp::_argc,PyInterp_Interp::_argv); // initialize sys.argv
-  
-  if(!builtinmodule) // PAL18041: deepcopy function don't work in Salome
-  {
-    //builtinmodule is static member of PyInterp class
-    //If it is not NULL (initialized to the builtin module of the main interpreter
-    //all the sub interpreters will have the same builtin
-    //_interp is a static member and is the main interpreter
-    //The first time we initialized it to the builtin of main interpreter
-    builtinmodule=PyDict_GetItemString(_interp->modules, "__builtin__");
-  }
-
-  //If builtinmodule has been initialized all the sub interpreters
-  // will have the same __builtin__ module
-  if(builtinmodule){ 
-    PyObject *m = PyImport_GetModuleDict();
-    PyDict_SetItemString(m, "__builtin__", builtinmodule);
-    _tstate->interp->builtins = PyModule_GetDict(builtinmodule);
-    Py_INCREF(_tstate->interp->builtins);
-  }
-  PyEval_ReleaseThread(_tstate);
-  return true;
-}
-
 /*!
   \brief Initialize python interpeter context.
 
@@ -135,10 +77,7 @@ bool PyConsole_Interp::initContext()
     PyErr_Print();
     return false;
   }  
-  _g = PyModule_GetDict(m);          // get interpreter dictionnary context
-
-  if(builtinmodule){
-    PyDict_SetItemString(_g, "__builtins__", builtinmodule); // assign singleton __builtin__ module
-  }
+  PyObject* global_dict = PyModule_GetDict(m);          // get interpreter dictionnary context
+  _context = PyDict_Copy(global_dict);
   return true;
 }
index 254cc81463e3bb9d900f7c34c912cc424d947bfa..d122db0a6cd307f8130156a48df753938c79db23 100644 (file)
@@ -39,7 +39,6 @@ public:
   ~PyConsole_Interp();
 
 protected:
-  virtual bool initState();
   virtual bool initContext();  
 };
 
index c8d0fb17dfc6ba55960e96c698db9e11941f6c58..dde0da06bddca9533ee8f63b5959df4c74dcacd1 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!DOCTYPE TS>
-<TS>
+<TS version="2.0" language="ja" sourcelanguage="en">
   <context>
     <name>PyConsole_Console</name>
     <message>
index 6f5af57bfa9ead484d95c3dd2bdd3615f101f4d8..73898b53dfff115b721d53c78be82c60853b8c3f 100755 (executable)
@@ -96,11 +96,11 @@ void PyInterp_Request::setListener( QObject* o )
 
 void PyInterp_LockRequest::safeExecute()
 {
-  if ( getInterp() ){
-    PyLockWrapper aLock = getInterp()->GetLockWrapper();
+  //if ( getInterp() ){  // No need to have an interpreter now! we can simply run in a empty context
+    PyLockWrapper aLock; // Acquire GIL
     //ProcessVoidEvent( new PyInterp_ExecuteEvent( this ) );
     execute();
-  }
+  //}
 }
 
 PyInterp_Event::~PyInterp_Event()
index 2f8a1db3e45810598076a9d20689e49c1f62469b..ba1a386fdb1c4a3de2dad8778017e613059715df 100644 (file)
@@ -39,9 +39,6 @@
 #define TOP_HISTORY_PY   "--- top of history ---"
 #define BEGIN_HISTORY_PY "--- begin of history ---"
 
-// a map to store python thread states that have been created for a given system thread (key=thread id,value=thread state)
-std::map<long,PyThreadState*> currentThreadMap;
-
 /*!
   \class PyLockWrapper
   \brief Python GIL wrapper.
@@ -49,16 +46,10 @@ std::map<long,PyThreadState*> currentThreadMap;
 
 /*!
   \brief Constructor. Automatically acquires GIL.
-  \param theThreadState python thread state
 */
-PyLockWrapper::PyLockWrapper(PyThreadState* theThreadState):
-  myThreadState(theThreadState),
-  mySaveThreadState(0)
+PyLockWrapper::PyLockWrapper()
 {
-  if (myThreadState->interp == PyInterp_Interp::_interp)
-    _savestate = PyGILState_Ensure();
-  else
-    PyEval_AcquireThread(myThreadState);
+  _gil_state = PyGILState_Ensure();
 }
 
 /*!
@@ -66,51 +57,15 @@ PyLockWrapper::PyLockWrapper(PyThreadState* theThreadState):
 */
 PyLockWrapper::~PyLockWrapper()
 {
-  if (myThreadState->interp == PyInterp_Interp::_interp)
-    PyGILState_Release(_savestate);
-  else
-    PyEval_ReleaseThread(myThreadState);
-}
-
-/*!
-  \brief Get Python GIL wrapper.
-  \return GIL lock wrapper (GIL is automatically acquired here)
-*/
-PyLockWrapper PyInterp_Interp::GetLockWrapper()
-{
-  if (_tstate->interp == PyInterp_Interp::_interp)
-    return _tstate;
-
-  // If we are here, we have a secondary python interpreter. Try to get a thread state synchronized with the system thread
-  long currentThreadid=PyThread_get_thread_ident(); // the system thread id
-  PyThreadState* theThreadState;
-  if(currentThreadMap.count(currentThreadid) != 0)
-    {
-      //a thread state exists for this thread id
-      PyThreadState* oldThreadState=currentThreadMap[currentThreadid];
-      if(_tstate->interp ==oldThreadState->interp)
-        {
-          //The old thread state has the same python interpreter as this one : reuse the threadstate
-          theThreadState=oldThreadState;
-        }
-      else
-        {
-          //The old thread state has not the same python interpreter as this one : delete the old threadstate and create a new one
-          PyEval_AcquireLock();
-          PyThreadState_Clear(oldThreadState);
-          PyThreadState_Delete(oldThreadState);
-          PyEval_ReleaseLock();
-          theThreadState=PyThreadState_New(_tstate->interp);
-          currentThreadMap[currentThreadid]=theThreadState;
-        }
-    }
-  else
-    {
-      // no old thread state for this thread id : create a new one
-      theThreadState=PyThreadState_New(_tstate->interp);
-      currentThreadMap[currentThreadid]=theThreadState;
-    }
-  return theThreadState;
+//  if (myThreadState->interp == PyInterp_Interp::_interp)
+//    PyGILState_Release(_savestate);
+//  else
+//    PyEval_ReleaseThread(myThreadState);
+
+  /* The destructor can never be called concurrently by two threads since it is called
+   * when the GIL is held - the below test should never run concurrently in two threads.
+   */
+  PyGILState_Release(_gil_state);
 }
 
 /*
@@ -232,9 +187,9 @@ static PyStdOut* newPyStdOut( bool iscerr )
 
 int   PyInterp_Interp::_argc   = 1;
 char* PyInterp_Interp::_argv[] = {(char*)""};
-PyObject*           PyInterp_Interp::builtinmodule = NULL;
-PyThreadState*      PyInterp_Interp::_gtstate      = NULL;
-PyInterpreterState* PyInterp_Interp::_interp       = NULL;
+//PyObject*           PyInterp_Interp::builtinmodule = NULL;
+//PyThreadState*      PyInterp_Interp::_gtstate      = NULL;
+//PyInterpreterState* PyInterp_Interp::_interp       = NULL;
 
 /*!
   \brief Basic constructor.
@@ -243,10 +198,12 @@ PyInterpreterState* PyInterp_Interp::_interp       = NULL;
   must call virtual method initalize().
 */
 PyInterp_Interp::PyInterp_Interp():
-  _tstate(0), _vout(0), _verr(0), _g(0)
+  _vout(0), _verr(0), _context(0)
 {
 }
 
+
+
 /*!
   \brief Destructor.
 */
@@ -271,20 +228,21 @@ void PyInterp_Interp::initialize()
   _history.clear();       // start a new list of user's commands
   _ith = _history.begin();
 
-  initPython();
-  // Here the global lock is released
+  initPython();  // This also inits the multi-threading for Python (but w/o acquiring GIL)
 
-  initState();
+  //initState(); // [ABN] OBSOLETE
 
-  PyEval_AcquireThread(_tstate);
+  // ---- The rest of the initialisation process is done hodling the GIL
+  PyLockWrapper lck;
 
   initContext();
 
-  // used to interpret & compile commands
+  // used to interpret & compile commands - this is really imported here
+  // and only added again (with PyImport_AddModule) later on
   PyObjWrapper m(PyImport_ImportModule("codeop"));
   if(!m) {
     PyErr_Print();
-    PyEval_ReleaseThread(_tstate);
+    PyEval_ReleaseLock();
     return;
   }
 
@@ -294,17 +252,22 @@ void PyInterp_Interp::initialize()
 
   // All the initRun outputs are redirected to the standard output (console)
   initRun();
-  PyEval_ReleaseThread(_tstate);
+}
+
+void PyInterp_Interp::destroy()
+{
+  PyLockWrapper lck;
+  closeContext();
 }
 
 /*!
   \brief Initialize Python interpreter.
 
-  In case if Python is not initialized, it sets program name, initializes the interpreter, sets program arguments,
-  initializes threads.
-  Otherwise, it just obtains the global interpreter and thread states. This is important for light SALOME configuration,
+  In case if Python is not initialized, it sets program name, initializes the single true Python
+  interpreter, sets program arguments, and initializes threads.
+  Otherwise, does nothing. This is important for light SALOME configuration,
   as in full SALOME this is done at SalomeApp level.
-  \sa SalomeApp_PyInterp class
+  \sa SalomeApp_PyInterp class and main() in SALOME_Session_Server
  */
 void PyInterp_Interp::initPython()
 {
@@ -313,30 +276,22 @@ void PyInterp_Interp::initPython()
     Py_SetProgramName(_argv[0]);
     Py_Initialize(); // Initialize the interpreter
     PySys_SetArgv(_argc, _argv);
-    PyEval_InitThreads(); // Create (and acquire) the interpreter lock
-  }
 
-  if ( _interp == NULL )
-    _interp = PyThreadState_Get()->interp;
-  if (PyType_Ready(&PyStdOut_Type) < 0) {
-    PyErr_Print();
+    PyEval_InitThreads(); // Create (and acquire) the Python global interpreter lock (GIL)
+    PyEval_ReleaseLock();
   }
-  if ( _gtstate == NULL )
-    _gtstate = PyEval_SaveThread(); // Release global thread state
 }
 
 /*!
   \brief Get embedded Python interpreter banner.
   \return banner string
  */
-std::string PyInterp_Interp::getbanner()
+std::string PyInterp_Interp::getbanner() const
 {
- // Should we take the lock ?
- // PyEval_RestoreThread(_tstate);
+  PyLockWrapper lck;
   std::string aBanner("Python ");
   aBanner = aBanner + Py_GetVersion() + " on " + Py_GetPlatform() ;
   aBanner = aBanner + "\ntype help to get general information on environment\n";
-  //PyEval_SaveThread();
   return aBanner;
 }
 
@@ -350,24 +305,17 @@ std::string PyInterp_Interp::getbanner()
 */
 bool PyInterp_Interp::initRun()
 {
-  //
-  // probably all below code isn't required
-  //
-  /*
-  PySys_SetObject("stderr",_verr);
-  PySys_SetObject("stdout",_vout);
-
-  //PyObject *m = PyImport_GetModuleDict();
-
-  PySys_SetObject("stdout",PySys_GetObject("__stdout__"));
-  PySys_SetObject("stderr",PySys_GetObject("__stderr__"));
-  */
   return true;
 }
 
+void PyInterp_Interp::closeContext()
+{
+}
+
 /*!
   \brief Compile Python command and evaluate it in the
-         python dictionary context if possible.
+         python dictionary context if possible. This is not thread-safe.
+         This is the caller's responsability to make this thread-safe.
   \internal
   \param command Python command string
   \param context Python context (dictionary)
@@ -396,12 +344,7 @@ static int run_command(const char *command, PyObject *context)
     return 1;
   }
   else {
-    // Complete and correct text. We evaluate it.
-    //#if PY_VERSION_HEX < 0x02040000 // python version earlier than 2.4.0
-    //    PyObjWrapper r(PyEval_EvalCode(v,context,context));
-    //#else
     PyObjWrapper r(PyEval_EvalCode((PyCodeObject *)(void *)v,context,context));
-    //#endif
     if(!r) {
       // Execution error. We return -1
       PyErr_Print();
@@ -433,7 +376,7 @@ void replaceAll(std::string& str, const std::string& from, const std::string& to
   \return -1 on fatal error, 1 if command is incomplete and 0
          if command is executed successfully
  */
-static int compile_command(const char *command,PyObject *context)
+static int compile_command(const char *command, PyObject *context)
 {
   // First guess if command is execution of a script with args, or a simple Python command
   std::string singleCommand = command;
@@ -466,7 +409,8 @@ static int compile_command(const char *command,PyObject *context)
 }
 
 /*!
-  \brief Run Python command.
+  \brief Run Python command - the command has to fit on a single line (no \n!).
+  Use ';' if you need multiple statements evaluated at once.
   \param command Python command
   \return command status
 */
@@ -476,8 +420,17 @@ int PyInterp_Interp::run(const char *command)
   return simpleRun(command);
 }
 
+/**
+ * Called before a command is run (when calling run() method). Not thread-safe. Caller's responsability
+ * to acquire GIL if needed.
+ */
+int PyInterp_Interp::beforeRun()
+{
+  return 0;
+}
+
 /*!
-  \brief Run Python command (used internally).
+  \brief Run Python command (used internally). Not thread-safe. GIL acquisition is caller's responsability.
   \param command Python command
   \param addToHistory if \c true (default), the command is added to the commands history
   \return command status
@@ -489,19 +442,22 @@ int PyInterp_Interp::simpleRun(const char *command, const bool addToHistory)
     _ith = _history.end();
   }
 
-  // We come from C++ to enter Python world
-  // We need to acquire the Python global lock
-  //PyLockWrapper aLock(_tstate); // san - lock is centralized now
+  // Current stdout and stderr are saved
+  PyObject * oldOut = PySys_GetObject((char*)"stdout");
+  PyObject * oldErr = PySys_GetObject((char*)"stderr");
+  // Keep them alive (PySys_GetObject returned a *borrowed* ref!)
+  Py_INCREF(oldOut);
+  Py_INCREF(oldErr);
 
-  // Reset redirected outputs before treatment
+  // Redirect outputs to SALOME Python console before treatment
   PySys_SetObject((char*)"stderr",_verr);
   PySys_SetObject((char*)"stdout",_vout);
 
-  int ier = compile_command(command,_g);
+  int ier = compile_command(command,_context);
 
-  // Outputs are redirected on standards outputs (console)
-  PySys_SetObject((char*)"stdout",PySys_GetObject((char*)"__stdout__"));
-  PySys_SetObject((char*)"stderr",PySys_GetObject((char*)"__stderr__"));
+  // Outputs are redirected to what they were before
+  PySys_SetObject((char*)"stdout",oldOut);
+  PySys_SetObject((char*)"stderr",oldErr);
 
   return ier;
 }
index 6c22da317a102f5a528bf9a4d233b4dd16acd7a5..766f02a5e72ded74c206ecd05e13ac568f71d19d 100644 (file)
 #include <list>
 #include <string>
 
+/**
+ * Utility class wrappin the Python GIL acquisition. This makes use of the high level
+ * API (PyGILState_Ensure and PyGILState_Release), and is hence compatible with only
+ * one running Python interpreter (no call to Py_NewInterpreter()).
+ * When the class is instanciated the lock is acquired. It is released at destruction time.
+ * Copy construction (and hence assignation) is forbidden.
+ */
 class PYINTERP_EXPORT PyLockWrapper
 {
-  PyThreadState* myThreadState;
-  PyThreadState* mySaveThreadState;
-  PyGILState_STATE _savestate;
+  PyGILState_STATE _gil_state;
 public:
-  PyLockWrapper(PyThreadState* theThreadState);
+  PyLockWrapper();
   ~PyLockWrapper();
+
+private:
+  // "Rule of 3" - Forbid usage of copy operator and copy-constructor
+  PyLockWrapper(const PyLockWrapper & another);
+  const PyLockWrapper & operator=(const PyLockWrapper & another);
 };
 
 typedef void PyOutChanged(void* data,char * c);
 
+/**
+ * Main class representing a *virtual* Python interpreter. There is really only one true
+ * Python interpreter in the whole application (no call to Py_NewInterpreter),
+ * but the use of different execution contexts allow
+ * to split the execution lines, and hence to emulate (relatively) independent interpreters.
+ * This has some consequences: modules imported in one context are not re-imported in another context
+ * (only there namespace is made available when importing in another context).
+ * See also class PyConsole_Interp.
+ */
 class PYINTERP_EXPORT PyInterp_Interp
 {
 public:
   static int _argc;
   static char* _argv[];
-  static PyObject *builtinmodule;
-  static PyThreadState *_gtstate;
-  static PyInterpreterState *_interp;
   
   PyInterp_Interp();
   virtual ~PyInterp_Interp();
   
   void initialize();
+  void destroy();
 
   virtual int run(const char *command); 
 
-  PyLockWrapper GetLockWrapper();
+  // [ABN] - the PyLockWrapper is no more attached to the interpreter
+  // PyLockWrapper GetLockWrapper() const;
 
-  std::string getbanner()
+  std::string getbanner() const;
   void setverrcb(PyOutChanged*,void*);
   void setvoutcb(PyOutChanged*,void*);
 
   const char * getPrevious();
-  const char * getNext();    
+  const char * getNext();
 
 protected:
-  PyThreadState * _tstate;
+  /** Redirection of stdout and stderr */
   PyObject * _vout;
   PyObject * _verr;
-  PyObject * _g;
+  /** Execution context (local and global variables) */
+  PyObject * _context;
   PyObject * _codeop;
   std::list<std::string> _history;
   std::list<std::string>::iterator _ith;
 
-  virtual int beforeRun() { return 0; }
+  virtual int beforeRun();
   int simpleRun(const char* command, const bool addToHistory = true);
 
-  virtual bool initRun();
   virtual void initPython();
-  virtual bool initState() = 0;
-  virtual bool initContext() = 0;  
+  /** OBSOLETE - should'nt be called anymore */
+  //virtual bool initState() = 0;
+
+  /** Initialize execution context. Must set the member _context, and return True on success. */
+  virtual bool initContext() = 0;
+  virtual bool initRun();
+  virtual void closeContext();
 };
 
+/**
+ * Utility class to properly handle the reference counting required on Python objects.
+ */
 class PYINTERP_EXPORT PyObjWrapper
 {
   PyObject* myObject;
index 07a1c14b7260084f207ed4c5442ac58ab5222545..4ceacd3e0160fb7c28c484d4f72c3e33ed697b3f 100644 (file)
@@ -88,7 +88,7 @@ class PYINTERP_EXPORT PyInterp_LockRequest : public PyInterp_Request
 {
 public:
 
-  PyInterp_LockRequest( PyInterp_Interp* interp, QObject* listener = 0, bool sync = false )
+  PyInterp_LockRequest( PyInterp_Interp* interp, QObject* listener=0, bool sync=false )
     : PyInterp_Request( listener, sync ), myInterp( interp )
   {}
 
index 02f4cc087992709cf992c50f9359973411a7753e..5bd6c28e3996dba14a279f5583567ebed14d7dd4 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!DOCTYPE TS>
-<TS>
+<TS version="2.0" language="ja" sourcelanguage="en">
   <context>
     <name>QDS_Datum</name>
     <message>
index 31cb87fc44b2125a0401937ac455b017d56a10bf..d3c2aa09886e3cc147263455fac25344a10a76f1 100644 (file)
 
 #include <stdlib.h>
 
+/* XPM for the default pixmap */
+static const char* pixmap_not_found_xpm[] = {
+"16 16 3 1",
+"       c None",
+".      c #000000",
+"+      c #A80000",
+"                ",
+"                ",
+"    .     .     ",
+"   .+.   .+.    ",
+"  .+++. .+++.   ",
+"   .+++.+++.    ",
+"    .+++++.     ",
+"     .+++.      ",
+"    .+++++.     ",
+"   .+++.+++.    ",
+"  .+++. .+++.   ",
+"   .+.   .+.    ",
+"    .     .     ",
+"                ",
+"                ",
+"                "};
+
 /*!
   \class QtxResourceMgr::Resources
   \internal
@@ -2523,10 +2546,11 @@ QString QtxResourceMgr::sectionsToken() const
 */
 QPixmap QtxResourceMgr::defaultPixmap() const
 {
-  QPixmap res;
-  if ( myDefaultPix && !myDefaultPix->isNull() )
-    res = *myDefaultPix;
-  return res;
+  static QPixmap* defpx = 0;
+  if ( !defpx ) 
+    defpx = new QPixmap( pixmap_not_found_xpm );
+
+  return myDefaultPix ? *myDefaultPix : *defpx;
 }
 
 /*!
@@ -2863,7 +2887,6 @@ QString QtxResourceMgr::userFileName( const QString& appName, const bool /*for_l
 {
   QString fileName;
   QString pathName = QDir::homePath();
-
   QString cfgAppName = QApplication::applicationName();
   if ( !cfgAppName.isEmpty() )
     pathName = Qtx::addSlash( Qtx::addSlash( pathName ) + QString( ".config" ) ) + cfgAppName;
index 3beae0f420387e808b2420e71eca5726fb6eddf4..06eec21a418f11da51061843513371f649bb5c34 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!DOCTYPE TS>
-<TS>
+<TS version="2.0" language="ja" sourcelanguage="en">
   <context>
     <name>@default</name>
     <message>
index 85286c91b0211948ad6d5b1f16b1d166b785e720..167941da847083c4323b88c0a075884198db44b8 100755 (executable)
@@ -372,7 +372,7 @@ extern "C" SALOMEPY_EXPORT PyObject* libSalomePy_showTrihedron( PyObject* self,
     {
       if( SVTK_ViewWindow* aVTKViewWindow = GetVTKViewWindow( __Find ) ) {
         if ( aVTKViewWindow->isTrihedronDisplayed() != myShow )
-          aVTKViewWindow->onViewTrihedron();
+          aVTKViewWindow->onViewTrihedron(myShow);
       }
     }
   };
index 482060181055b430c0f389653b573489b66b77fa..4b73279a700c3c34c38c8323852d078342d20d0c 100644 (file)
@@ -29,6 +29,8 @@
 #include <SALOME_LifeCycleCORBA.hxx>
 #include <Container_init_python.hxx>
 
+#include <QCoreApplication>
+
 //
 // NB: Python requests.
 // General rule for Python requests created by Python-based GUI modules
@@ -64,14 +66,13 @@ PyMODINIT_FUNC INIT_FUNCTION();
 extern "C" {
   SALOME_PYQT_EXPORT CAM_Module* createModule()
   {
-    static bool alreadyInitialized = false;
+    QCoreApplication* app = QCoreApplication::instance();
+    bool alreadyInitialized = app && app->property( "salome_pyqt_gui_light_initialized" ).toBool();
 
     if ( !alreadyInitialized ) {
-      // call only once (see comment above) !
-      PyEval_RestoreThread( KERNEL_PYTHON::_gtstate);
+      PyLockWrapper lck; // GIL acquisition
       INIT_FUNCTION();
-      PyEval_ReleaseThread( KERNEL_PYTHON::_gtstate);
-      alreadyInitialized = !alreadyInitialized;
+      if ( app ) app->setProperty( "salome_pyqt_gui_light_initialized", true );
     }
 
     return new SALOME_PYQT_Module();
index 21567b75d7c2e298422be47e92ad7fbb5c753532..da7043dbd9a0e06e657a0bfbea63f61b999dcc4a 100644 (file)
 #include <Container_init_python.hxx>
 #endif
 
+#include <QCoreApplication>
+
 // Py_ssize_t for old Pythons
 // This code is as recommended by"
 // http://www.python.org/dev/peps/pep-0353/#conversion-guidelines
-#if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN)
-typedef int Py_ssize_t;
-# define PY_SSIZE_T_MAX INT_MAX
-# define PY_SSIZE_T_MIN INT_MIN
-#endif
+//#if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN)
+//typedef int Py_ssize_t;
+//# define PY_SSIZE_T_MAX INT_MAX
+//# define PY_SSIZE_T_MIN INT_MIN
+//#endif
 
 //
 // NB: Python requests.
@@ -80,26 +82,14 @@ extern "C"
 {
   SALOME_PYQT_LIGHT_EXPORT CAM_Module* createModule() 
   {
-    static bool alreadyInitialized = false;
+    QCoreApplication* app = QCoreApplication::instance();
+    bool alreadyInitialized = app && app->property( "salome_pyqt_gui_light_initialized" ).toBool();
 
     // make initialization only once (see comment above) !
     if ( !alreadyInitialized ) {
-      static PyThreadState* gtstate = 0;
-#ifndef GUI_DISABLE_CORBA
-      if ( SUIT_PYTHON::initialized )
-        gtstate = SUIT_PYTHON::_gtstate;
-      else
-        gtstate = KERNEL_PYTHON::_gtstate;
-#else
-      gtstate = SUIT_PYTHON::_gtstate;
-#endif
-      PyEval_RestoreThread( gtstate );
-
+      PyLockWrapper lck; // GIL acquisition
       INIT_FUNCTION();
-
-      PyEval_ReleaseThread( gtstate );
-
-      alreadyInitialized = !alreadyInitialized;
+      if ( app ) app->setProperty( "salome_pyqt_gui_light_initialized", true );
     }
 
     return new SALOME_PYQT_ModuleLight();
index 8dfe17f6f72c0eae53114f72943bda7fb0d4436f..ffcbf215826c9c1ca99031d553fbebe4bff22693 100644 (file)
@@ -71,9 +71,9 @@ public:
   // data model management
   QString         createObject( const QString& );
   QString         createObject( const QString&, 
-                               const QString&,
-                               const QString&,
-                               const QString& );
+                                const QString&,
+                                const QString&,
+                                const QString& );
 
   void            setName( const QString&, const QString& );
   QString         getName( const QString& ) const;
index b1c259a2b0112662b39b08970df9bccb962ca52e..bb72bb2b65604c85a365f80b8a9b91616f3dbd7d 100644 (file)
@@ -49,38 +49,9 @@ void SALOME_PYQT_PyInterp::initPython()
   * Do nothing
   * The initialization has been done in main
   */
-  MESSAGE("SALOME_PYQT_PyInterp::initPython");
-#ifndef GUI_DISABLE_CORBA
-  if(SUIT_PYTHON::initialized) {
-    ASSERT(SUIT_PYTHON::_gtstate); // initialisation in main
-    SCRUTE(SUIT_PYTHON::_gtstate);
-    _tstate = SUIT_PYTHON::_gtstate;
-  }
-  else {
-    ASSERT(KERNEL_PYTHON::_gtstate); // initialisation in main
-    SCRUTE(KERNEL_PYTHON::_gtstate);
-    _tstate = KERNEL_PYTHON::_gtstate;
-  }
-#else
-  SCRUTE(SUIT_PYTHON::_gtstate);
-  _tstate = SUIT_PYTHON::_gtstate;
-#endif
-}
-
-bool SALOME_PYQT_PyInterp::initState()
-{
- /*
-  * The GIL is assumed to not be held on the call
-  * The GIL is acquired in initState and will be held on initState exit
-  * It is the caller responsability to release the lock on exit if needed
-  */
-  PyEval_AcquireThread(_tstate);
-  SCRUTE(_tstate);
-  PyEval_ReleaseThread(_tstate);
-  return true;
+  MESSAGE("SALOME_PYQT_PyInterp::initPython - does nothing");
 }
 
-
 bool SALOME_PYQT_PyInterp::initContext()
 {
   /*
@@ -88,10 +59,7 @@ bool SALOME_PYQT_PyInterp::initContext()
    * It is the caller responsability to acquire the GIL before calling initContext
    * It will still be held on initContext exit
    */
-  _g = PyDict_New();          // create interpreter dictionnary context
-  PyObject *bimod = PyImport_ImportModule("__builtin__");
-  PyDict_SetItemString(_g, "__builtins__", bimod);
-  Py_DECREF(bimod); 
+  _context = PyDict_New();          // create interpreter dictionnary context
   return true;
 }
 
@@ -100,18 +68,15 @@ int SALOME_PYQT_PyInterp::run(const char *command)
   MESSAGE("compile");
   PyObject *code = Py_CompileString((char *)command,"PyGUI",Py_file_input);
   if(!code){
-    // Une erreur s est produite en general SyntaxError
+    // An error occured - normally here a SyntaxError
     PyErr_Print();
     return -1;
   }
-  //#if PY_VERSION_HEX < 0x02040000 // python version earlier than 2.4.0
-  //  PyObject *r = PyEval_EvalCode(code,_g,_g);
-  //#else
-  PyObject *r = PyEval_EvalCode((PyCodeObject *)code,_g,_g);
-  //#endif
+  PyObject *r = PyEval_EvalCode((PyCodeObject *)code,_context,_context);
+
   Py_DECREF(code);
   if(!r){
-    // Une erreur s est produite a l execution
+      // An error occured at execution
     PyErr_Print();
     return -1 ;
   }
index 958c35376d5ae64ac7f77a136868727ad3f0c12e..5857ffe8d81e8b17fd14f55051380bbd64a1a45f 100644 (file)
@@ -38,7 +38,6 @@ class SALOME_PYQT_LIGHT_EXPORT SALOME_PYQT_PyInterp : public PyInterp_Interp
   
  protected:
   virtual void initPython();
-  virtual bool initState();
   virtual bool initContext();
 };
 
index 0a90da4908fddaf8e2ed00303a292f67fb7e2888..4a21a408591b1eb287ef66e1b05e11faf242fa28 100644 (file)
@@ -228,9 +228,9 @@ public:
   XmlHandler( PyModuleHelper* helper, const QString& fileName );
   void             createActions();
   void             createPopup( QMenu* menu,
-                               const QString& context,
-                               const QString& parent,
-                               const QString& object );
+                                const QString& context,
+                                const QString& parent,
+                                const QString& object );
   void             activateMenus( bool );
 
 private:
@@ -238,11 +238,11 @@ private:
   QIcon            loadIcon( const QString& fileName );
 
   void             createMenu( QDomNode& parentNode,
-                              const int parentMenuId = -1,
-                              QMenu* parentPopup = 0 );
+                               const int parentMenuId = -1,
+                               QMenu* parentPopup = 0 );
   void             createToolBar( QDomNode& parentNode );
   void             insertPopupItems( QDomNode& parentNode,
-                                    QMenu* menu );
+                                     QMenu* menu );
 
 private:
   PyModuleHelper*  myHelper;
@@ -258,7 +258,7 @@ private:
   \param fileName path to the XML menu description file 
 */
 PyModuleHelper::XmlHandler::XmlHandler( PyModuleHelper*  helper,
-                                       const QString&   fileName )
+                                        const QString&   fileName )
 : myHelper( helper )
 {
   if ( !fileName.isEmpty() ) { 
@@ -305,9 +305,9 @@ void PyModuleHelper::XmlHandler::createActions()
   \param context popup menu object name
 */
 void PyModuleHelper::XmlHandler::createPopup( QMenu*         menu,
-                                             const QString& context,
-                                             const QString& parent,
-                                             const QString& object )
+                                              const QString& context,
+                                              const QString& parent,
+                                              const QString& object )
 {
   // get document element
   QDomElement aDocElem = myDoc.documentElement();
@@ -364,10 +364,10 @@ QIcon PyModuleHelper::XmlHandler::loadIcon( const QString& fileName )
   if ( module() && !fileName.isEmpty() ) {
       SUIT_ResourceMgr* resMgr = module()->getApp()->resourceMgr();
       QPixmap pixmap = resMgr->loadPixmap( module()->name(),
-                                          QApplication::translate( module()->name().toLatin1().data(), 
-                                                                   fileName.toLatin1().data() ) );
-    if ( !pixmap.isNull() )
-      icon = QIcon( pixmap );
+          QApplication::translate( module()->name().toLatin1().data(),
+                                   fileName.toLatin1().data() ) );
+      if ( !pixmap.isNull() )
+        icon = QIcon( pixmap );
   }
 
   return icon;
@@ -381,8 +381,8 @@ QIcon PyModuleHelper::XmlHandler::loadIcon( const QString& fileName )
   \param parentPopup parent popup menu (0 for top-level menu)
 */
 void PyModuleHelper::XmlHandler::createMenu( QDomNode& parentNode, 
-                                            const int parentMenuId, 
-                                            QMenu*    parentPopup )
+                                             const int parentMenuId,
+                                             QMenu*    parentPopup )
 {
   if ( !module() || parentNode.isNull() )
     return;
@@ -425,14 +425,14 @@ void PyModuleHelper::XmlHandler::createMenu( QDomNode& parentNode,
             if ( id != -1 ) {
               // create menu action
               QAction* action = module()->createAction( id,                     // ID
-                                                       tooltip,                // tooltip
-                                                       icon,                   // icon
-                                                       label,                  // menu text
-                                                       tooltip,                // status-bar text
-                                                       QKeySequence( accel ),  // keyboard accelerator
-                                                       module(),               // action owner
-                                                       toggle );               // toogled action
-             myHelper->connectAction( action );
+                                                        tooltip,                // tooltip
+                                                        icon,                   // icon
+                                                        label,                  // menu text
+                                                        tooltip,                // status-bar text
+                                                        QKeySequence( accel ),  // keyboard accelerator
+                                                        module(),               // action owner
+                                                        toggle );               // toogled action
+              myHelper->connectAction( action );
               module()->createMenu( action,   // action
                                     menuId,   // parent menu ID
                                     id,       // ID (same as for createAction())
@@ -496,17 +496,17 @@ void PyModuleHelper::XmlHandler::createToolBar( QDomNode& parentNode )
             // -1 action ID is not allowed : it means that <item-id> attribute is missed in the XML file!
             // also check if the action with given ID is already created
             if ( id != -1 ) {
-              // create toolbar action
-              QAction* action = module()->createAction( id,                     // ID
-                                                       tooltip,                // tooltip
-                                                       icon,                   // icon
-                                                       label,                  // menu text
-                                                       tooltip,                // status-bar text
-                                                       QKeySequence( accel ),  // keyboard accelerator
-                                                       module(),               // action owner
-                                                       toggle );               // toogled action
-             myHelper->connectAction( action );
-              module()->createTool( action, tbId, -1, pos );
+                // create toolbar action
+                QAction* action = module()->createAction( id,                     // ID
+                                                          tooltip,                // tooltip
+                                                          icon,                   // icon
+                                                          label,                  // menu text
+                                                          tooltip,                // status-bar text
+                                                          QKeySequence( accel ),  // keyboard accelerator
+                                                          module(),               // action owner
+                                                          toggle );               // toogled action
+                myHelper->connectAction( action );
+                module()->createTool( action, tbId, -1, pos );
             }
           }
           else if ( aTagName == "separatorTB" || aTagName == "separator" ) {
@@ -552,15 +552,15 @@ void PyModuleHelper::XmlHandler::insertPopupItems( QDomNode& parentNode, QMenu*
         // -1 action ID is not allowed : it means that <item-id> attribute is missed in the XML file!
         // also check if the action with given ID is already created
         if ( id != -1 ) {
-         QAction* action = module()->createAction( id,                     // ID
-                                                   tooltip,                // tooltip
-                                                   icon,                   // icon
-                                                   label,                  // menu text
-                                                   tooltip,                // status-bar text
-                                                   QKeySequence( accel ),  // keyboard accelerator
-                                                   module(),               // action owner
-                                                   toggle );               // toogled action
-         myHelper->connectAction( action );
+          QAction* action = module()->createAction( id,                     // ID
+                                                    tooltip,                // tooltip
+                                                    icon,                   // icon
+                                                    label,                  // menu text
+                                                    tooltip,                // status-bar text
+                                                    QKeySequence( accel ),  // keyboard accelerator
+                                                    module(),               // action owner
+                                                    toggle );               // toogled action
+          myHelper->connectAction( action );
           QAction* before = ( pos >= 0 && pos < actions.count() ) ? actions[ pos ] : 0;
           menu->insertAction( before, action );
         }
@@ -627,7 +627,7 @@ PyModuleHelper::~PyModuleHelper()
 {
   delete myXmlHandler;
   if ( myInterp && myPyModule ) {
-    PyLockWrapper aLock = myInterp->GetLockWrapper();
+    PyLockWrapper aLock; // Acquire GIL
     Py_XDECREF( myPyModule );
   }
 }
@@ -691,8 +691,8 @@ void PyModuleHelper::connectAction( QAction* a )
 {
   if ( myModule && a )
     QObject::connect( a, SIGNAL( triggered( bool ) ), 
-                     this, SLOT( actionActivated() ),
-                     Qt::UniqueConnection );
+                      this, SLOT( actionActivated() ),
+                      Qt::UniqueConnection );
 }
 
 /*!
@@ -747,11 +747,11 @@ QStringList PyModuleHelper::viewManagers() const
   \brief Initialization of the Python-based SALOME module.
   
   This method can be used for creation of the menus, toolbars and 
-  other such staff.
+  other such stuff.
   
   There are two ways to do this:
-  1) for obsolete modules implementatino this method first tries to read
-  <module>_<language>.xml resource file which contains a menu,
+  1) for obsolete modules, the implementation of this method first tries to read
+  the <module>_<language>.xml resource file which contains a menu,
   toolbars and popup menus description;
   2) new modules can create menus by direct calling of the
   corresponding methods of SalomePyQt Python API in the Python
@@ -759,7 +759,7 @@ QStringList PyModuleHelper::viewManagers() const
 
   \note SALOME supports two modes of modules loading:
   - immediate (all the modules are created and initialized 
-  immediately when the application object is created;
+  immediately when the application object is created);
   - postponed modules loading (used currently); in this mode
   the module is loaded only by explicit request.
   If postponed modules loading is not used, the active
@@ -798,10 +798,10 @@ void PyModuleHelper::initialize( CAM_Application* app )
   {
   public:
     InitializeReq( PyModuleHelper*  _helper,
-                  CAM_Application* _app )
+                   CAM_Application* _app )
       : PyInterp_Request( 0, true ), // this request should be processed synchronously (sync == true)
         myHelper( _helper ),
-       myApp( _app )
+        myApp( _app )
     {}
   protected:
     virtual void execute()
@@ -841,21 +841,21 @@ bool PyModuleHelper::activate( SUIT_Study* study )
   {
   public:
     ActivateReq( PyModuleHelper* _helper,
-                SUIT_Study*     _study,
-                bool            _customize )
-      : PyInterp_Request( 0, true ), // this request should be processed synchronously (sync == true)
-       myHelper( _helper ),
-        myStudy ( _study ),
-       myCustomize( _customize )
-    {}
+                 SUIT_Study*     _study,
+                 bool            _customize )
+  : PyInterp_Request( 0, true ), // this request should be processed synchronously (sync == true)
+    myHelper( _helper ),
+    myStudy ( _study ),
+    myCustomize( _customize )
+  {}
   protected:
     virtual void execute()
-    {
-      if ( !myCustomize )
-       myHelper->internalActivate( myStudy );  // first activation stage
-      else
-       myHelper->internalCustomize( myStudy ); // second activation stage
-    }
+      {
+        if ( !myCustomize )
+          myHelper->internalActivate( myStudy );  // first activation stage
+        else
+          myHelper->internalCustomize( myStudy ); // second activation stage
+      }
   private:
     PyModuleHelper* myHelper;
     SUIT_Study*     myStudy;
@@ -881,12 +881,12 @@ bool PyModuleHelper::activate( SUIT_Study* study )
     if ( myLastActivateStatus ) {
       // connect preferences changing signal
       connect( myModule->getApp(), SIGNAL( preferenceChanged( const QString&, const QString&, const QString& ) ),
-              this,               SLOT(   preferenceChanged( const QString&, const QString&, const QString& ) ) );
+               this,               SLOT(   preferenceChanged( const QString&, const QString&, const QString& ) ) );
       
       // connect active view change signal
       SUIT_Desktop* d = study->application()->desktop();
       connect( d,     SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
-              this,  SLOT( activeViewChanged( SUIT_ViewWindow* ) ) );
+               this,  SLOT( activeViewChanged( SUIT_ViewWindow* ) ) );
       // if active window exists, call activeViewChanged() function;
       // temporary solution: if a getActiveView() in SalomePyQt available
       // we no longer need this 
@@ -924,11 +924,11 @@ bool PyModuleHelper::deactivate( SUIT_Study* study )
   {
   public:
     DeactivateReq( PyInterp_Interp* _py_interp,
-                  PyModuleHelper*  _helper,
+                   PyModuleHelper*  _helper,
                    SUIT_Study*      _study )
       : PyInterp_LockRequest( _py_interp, 0, true ), // this request should be processed synchronously (sync == true)
         myHelper( _helper ),
-       myStudy ( _study )
+        myStudy ( _study )
     {}
   protected:
     virtual void execute()
@@ -950,7 +950,7 @@ bool PyModuleHelper::deactivate( SUIT_Study* study )
   // disconnect the SUIT_Desktop signal windowActivated()
   SUIT_Desktop* d = study->application()->desktop();
   disconnect( d,     SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
-             this,  SLOT( activeViewChanged( SUIT_ViewWindow* ) ) );
+              this,  SLOT( activeViewChanged( SUIT_ViewWindow* ) ) );
 
   // deactivate menus, toolbars, etc
   if ( myXmlHandler ) myXmlHandler->activateMenus( false );
@@ -1023,7 +1023,7 @@ void PyModuleHelper::modelClosed( SUIT_Study* study )
   \param parameter preference resources parameter name
 */
 void PyModuleHelper::preferencesChanged( const QString& section, 
-                                        const QString& parameter )
+                                         const QString& parameter )
 {
   FuncMsg fmsg( "PyModuleHelper::preferencesChanged()" );
 
@@ -1031,9 +1031,9 @@ void PyModuleHelper::preferencesChanged( const QString& section,
   {
   public:
     PrefChangeReq( PyInterp_Interp* _py_interp,
-                  PyModuleHelper*  _helper,
-                  const QString&   _section,
-                  const QString&   _parameter )
+                   PyModuleHelper*  _helper,
+                   const QString&   _section,
+                   const QString&   _parameter )
       : PyInterp_LockRequest( _py_interp, 0, true ), // this request should be processed synchronously (sync == true)
         myHelper ( _helper ),
         mySection( _section ),
@@ -1065,8 +1065,8 @@ void PyModuleHelper::preferencesChanged( const QString& section,
   \param parameter preference resources parameter name
 */
 void PyModuleHelper::preferenceChanged( const QString& module, 
-                                       const QString& section, 
-                                       const QString& parameter )
+                                        const QString& section,
+                                        const QString& parameter )
 {
   FuncMsg fmsg( "PyModuleHelper::preferenceChanged()" );
 
@@ -1094,10 +1094,10 @@ void PyModuleHelper::studyActivated( SUIT_Study* study )
   {
   public:
     StudyChangedReq( PyModuleHelper* _helper,
-                    SUIT_Study*     _study )
+                     SUIT_Study*     _study )
       : PyInterp_Request( 0, true ), // this request should be processed synchronously (sync == true)
         myHelper( _helper ), 
-       myStudy ( _study )
+        myStudy ( _study )
     {}
   protected:
     virtual void execute()
@@ -1130,8 +1130,8 @@ void PyModuleHelper::actionActivated()
   {
   public:
     ActionReq( PyInterp_Interp* _py_interp,
-              PyModuleHelper*  _helper,
-              int              _id )
+               PyModuleHelper*  _helper,
+               int              _id )
       : PyInterp_LockRequest( _py_interp, 0, true ), // this request should be processed synchronously (sync == true)
         myHelper( _helper ),
         myId    ( _id  )
@@ -1176,7 +1176,7 @@ void PyModuleHelper::contextMenu( const QString& context, QMenu* menu )
                     const QString&   _context,
                     QMenu*           _menu )
       : PyInterp_LockRequest( _py_interp, 0, true ), // this request should be processed synchronously (sync == true)
-       myHelper ( _helper ),
+        myHelper ( _helper ),
         myContext( _context ),
         myMenu   ( _menu )
     {}
@@ -1214,7 +1214,7 @@ void PyModuleHelper::createPreferences()
   {
   public:
     CreatePrefReq( PyInterp_Interp* _py_interp,
-                  PyModuleHelper*  _helper )
+                   PyModuleHelper*  _helper )
       : PyInterp_LockRequest( _py_interp, 0, true ), // this request should be processed synchronously (sync == true)
         myHelper( _helper )
     {}
@@ -1249,11 +1249,11 @@ void PyModuleHelper::activeViewChanged( SUIT_ViewWindow* view )
   {
   public:
     ActiveViewChangeReq( PyInterp_Interp* _py_interp,
-                        PyModuleHelper*  _helper, 
-                        SUIT_ViewWindow* _view )
+                         PyModuleHelper*  _helper,
+                         SUIT_ViewWindow* _view )
       : PyInterp_LockRequest( _py_interp, 0, true ),
         myHelper( _helper ),
-       myView( _view )
+        myView( _view )
     {}
   protected:
     virtual void execute()
@@ -1283,11 +1283,11 @@ void PyModuleHelper::tryCloseView( SUIT_ViewWindow* view )
   {
   public:
     TryCloseViewReq( PyInterp_Interp* _py_interp,
-                    PyModuleHelper*  _helper, 
-                    SUIT_ViewWindow* _view )
+                     PyModuleHelper*  _helper,
+                     SUIT_ViewWindow* _view )
       : PyInterp_LockRequest( _py_interp, 0, true ),
         myHelper( _helper ), 
-       myView( _view )
+        myView( _view )
     {}
   protected:
     virtual void execute()
@@ -1314,8 +1314,8 @@ void PyModuleHelper::closeView( SUIT_ViewWindow* view )
   {
   public:
     CloseViewReq( PyInterp_Interp* _py_interp,
-                 PyModuleHelper*  _helper, 
-                 SUIT_ViewWindow* _view )
+                  PyModuleHelper*  _helper,
+                  SUIT_ViewWindow* _view )
       : PyInterp_LockRequest( _py_interp, 0, true ),
         myHelper( _helper ),
        myView( _view )
@@ -1345,11 +1345,11 @@ void PyModuleHelper::cloneView( SUIT_ViewWindow* view )
   {
   public:
     CloneViewReq( PyInterp_Interp* _py_interp,
-                 PyModuleHelper*  _helper, 
-                 SUIT_ViewWindow* _view )
+                  PyModuleHelper*  _helper,
+                  SUIT_ViewWindow* _view )
       : PyInterp_LockRequest( _py_interp, 0, true ),
         myHelper( _helper ),
-       myView( _view )
+        myView( _view )
     {}
   protected:
     virtual void execute()
@@ -1383,8 +1383,8 @@ void PyModuleHelper::save( QStringList& files )
   {
   public:     
     SaveReq( PyInterp_Interp* _py_interp,
-            PyModuleHelper*  _helper,
-            QStringList&     _files )
+             PyModuleHelper*  _helper,
+             QStringList&     _files )
       : PyInterp_LockRequest( _py_interp, 0, true ), // this request should be processed synchronously (sync == true)
         myHelper( _helper ) ,
         myFiles( _files )
@@ -1420,9 +1420,9 @@ bool PyModuleHelper::load( const QStringList& files )
   {
   public:
     LoadReq( PyInterp_Interp* _py_interp,
-            PyModuleHelper*  _helper,
-            QStringList      _files,
-            bool&            _loaded )
+             PyModuleHelper*  _helper,
+             QStringList      _files,
+             bool&            _loaded )
       : PyInterp_LockRequest( _py_interp, 0, true ), // this request should be processed synchronously (sync == true)
         myHelper( _helper ) ,
         myFiles( _files ),
@@ -1466,8 +1466,8 @@ void PyModuleHelper::dumpPython( QStringList& files )
   {
   public:     
     DumpPythonReq( PyInterp_Interp* _py_interp,
-                  PyModuleHelper*  _helper,
-                  QStringList&     _files )
+                   PyModuleHelper*  _helper,
+                   QStringList&     _files )
       : PyInterp_LockRequest( _py_interp, 0, true ), // this request should be processed synchronously (sync == true)
         myHelper( _helper ) ,
         myFiles( _files )
@@ -1504,9 +1504,9 @@ bool PyModuleHelper::isDraggable( const SUIT_DataObject* what ) const
   {
   public:
     IsDraggableReq( PyInterp_Interp*     _py_interp,
-                   PyModuleHelper*      _helper,
-                   LightApp_DataObject* _data_object,
-                   bool&                _is_draggable )
+                    PyModuleHelper*      _helper,
+                    LightApp_DataObject* _data_object,
+                    bool&                _is_draggable )
       : PyInterp_LockRequest( _py_interp, 0, true ), // this request should be processed synchronously (sync == true)
         myHelper( _helper ) ,
         myDataObject( _data_object ),
@@ -1529,9 +1529,9 @@ bool PyModuleHelper::isDraggable( const SUIT_DataObject* what ) const
     // Executing the request synchronously
     if ( !PyInterp_Dispatcher::Get()->IsBusy() )
       PyInterp_Dispatcher::Get()->Exec( new IsDraggableReq( myInterp,
-                                                           const_cast<PyModuleHelper*>( this ),
-                                                           const_cast<LightApp_DataObject*>( data_object ),
-                                                           draggable ) );
+                                        const_cast<PyModuleHelper*>( this ),
+                                        const_cast<LightApp_DataObject*>( data_object ),
+                                        draggable ) );
   }
   
   return draggable;
@@ -1553,9 +1553,9 @@ bool PyModuleHelper::isDropAccepted( const SUIT_DataObject* where ) const
   {
   public:
     IsDropAcceptedReq( PyInterp_Interp*     _py_interp,
-                      PyModuleHelper*      _helper,
-                      LightApp_DataObject* _data_object,
-                      bool&                _is_drop_accepted )
+                       PyModuleHelper*      _helper,
+                       LightApp_DataObject* _data_object,
+                       bool&                _is_drop_accepted )
       : PyInterp_LockRequest( _py_interp, 0, true ), // this request should be processed synchronously (sync == true)
         myHelper( _helper ) ,
         myDataObject( _data_object ),
@@ -1578,9 +1578,9 @@ bool PyModuleHelper::isDropAccepted( const SUIT_DataObject* where ) const
     // Executing the request synchronously
     if ( !PyInterp_Dispatcher::Get()->IsBusy() )
       PyInterp_Dispatcher::Get()->Exec( new IsDropAcceptedReq( myInterp,
-                                                              const_cast<PyModuleHelper*>( this ),
-                                                              const_cast<LightApp_DataObject*>( data_object ),
-                                                              dropAccepted ) );
+                                         const_cast<PyModuleHelper*>( this ),
+                                         const_cast<LightApp_DataObject*>( data_object ),
+                                         dropAccepted ) );
   }
 
   return dropAccepted;
@@ -1594,7 +1594,7 @@ bool PyModuleHelper::isDropAccepted( const SUIT_DataObject* where ) const
   \param action current drop action (copy or move)
 */
 void PyModuleHelper::dropObjects( const DataObjectList& what, SUIT_DataObject* where,
-                                 const int row, Qt::DropAction action )
+                                  const int row, Qt::DropAction action )
 {
   FuncMsg fmsg( "PyModuleHelper::dropObjects()" );
 
@@ -1603,17 +1603,17 @@ void PyModuleHelper::dropObjects( const DataObjectList& what, SUIT_DataObject* w
   {
   public:
     DropObjectsReq( PyInterp_Interp*      _py_interp,
-                   PyModuleHelper*       _helper,
-                   const DataObjectList& _what,
-                   SUIT_DataObject*      _where,
-                   const int             _row,
-                   Qt::DropAction        _action )
+                    PyModuleHelper*       _helper,
+                    const DataObjectList& _what,
+                    SUIT_DataObject*      _where,
+                    const int             _row,
+                    Qt::DropAction        _action )
       : PyInterp_LockRequest( _py_interp, 0, true ), // this request should be processed synchronously (sync == true)
         myHelper( _helper ) ,
         myWhat( _what ),
-       myWhere( _where ),
-       myRow( _row ),
-       myAction ( _action )
+        myWhere( _where ),
+        myRow( _row ),
+        myAction ( _action )
     {}
   protected:
     virtual void execute()
@@ -1647,10 +1647,10 @@ QString PyModuleHelper::engineIOR() const
   public:
     EngineIORReq( PyInterp_Interp* _py_interp,
                   PyModuleHelper*  _helper,
-                 QString&         _ior )
+                  QString&         _ior )
       : PyInterp_LockRequest( _py_interp, 0, true ), // this request should be processed synchronously (sync == true)
         myHelper( _helper ),
-       myIOR( _ior )
+        myIOR( _ior )
     {}
   protected:
     virtual void execute()
@@ -1667,8 +1667,8 @@ QString PyModuleHelper::engineIOR() const
   if ( anIOR.isEmpty() ) {
     // post request
     PyInterp_Dispatcher::Get()->Exec( new EngineIORReq( myInterp, 
-                                                       const_cast<PyModuleHelper*>( this ),
-                                                       anIOR ) );
+                                      const_cast<PyModuleHelper*>( this ),
+                                      anIOR ) );
   }
 
   return anIOR;
@@ -1708,7 +1708,7 @@ void PyModuleHelper::initInterp( int studyId )
     // import 'salome' module and call 'salome_init' method;
     // do it only once on interpreter creation
     // ... first get python lock
-    PyLockWrapper aLock = myInterp->GetLockWrapper();
+    PyLockWrapper aLock; // Acquire GIL
     // ... then import a module
     PyObjWrapper aMod = PyImport_ImportModule( "salome" );
     if ( !aMod ) {
@@ -1732,7 +1732,7 @@ void PyModuleHelper::initInterp( int studyId )
   \brief Import Python GUI module and store reference to the module.
   \internal
 
-  Attention! initInterp() should be called first!!!
+  Warning! initInterp() should be called first!!!
 */
 void PyModuleHelper::importModule()
 {
@@ -1747,7 +1747,7 @@ void PyModuleHelper::importModule()
 
   // import Python GUI module and put it in <myPyModule> attribute
   // ... first get python lock
-  PyLockWrapper aLock = myInterp->GetLockWrapper();
+  PyLockWrapper aLock; // Acquire GIL
   // ... then import a module
   QString aMod = QString( "%1GUI" ).arg( myModule->name() );
   try {
@@ -1787,7 +1787,7 @@ void PyModuleHelper::setWorkSpace()
 
   // call setWorkSpace() method
   // ... first get python lock
-  PyLockWrapper aLock = myInterp->GetLockWrapper();
+  PyLockWrapper aLock; // Acquire GIL
 
   // ... then try to import SalomePyQt module. If it's not possible don't go on.
   PyObjWrapper aQtModule( PyImport_ImportModule( "SalomePyQt" ) );
@@ -1865,7 +1865,7 @@ void PyModuleHelper::internalInitialize( CAM_Application* app )
 
   // then call Python module's initialize() method
   // ... first get python lock
-  PyLockWrapper aLock = myInterp->GetLockWrapper();
+  PyLockWrapper aLock; // Acquire GIL
 
   // ... (the Python module is already imported)
   // ... finally call Python module's initialize() method
@@ -1969,7 +1969,7 @@ void PyModuleHelper::internalActivate( SUIT_Study* study )
   }
 
   // get python lock
-  PyLockWrapper aLock = myInterp->GetLockWrapper();
+  PyLockWrapper aLock; // Acquire GIL
 
   // call Python module's activate() method (for the new modules)
   if ( PyObject_HasAttrString( myPyModule , (char*)"activate" ) ) {
@@ -2024,7 +2024,7 @@ void PyModuleHelper::internalCustomize( SUIT_Study* study )
   setWorkSpace();
 
   // get python lock
-  PyLockWrapper aLock = myInterp->GetLockWrapper();
+  PyLockWrapper aLock; // Acquire GIL
 
   if ( IsCallOldMethods ) {
     // call Python module's setSettings() method (obsolete)
@@ -2166,7 +2166,7 @@ void PyModuleHelper::internalStudyChanged( SUIT_Study* study )
   setWorkSpace();
 
   // get python lock
-  PyLockWrapper aLock = myInterp->GetLockWrapper();
+  PyLockWrapper aLock; // Acquire GIL
 
   // call Python module's activeStudyChanged() method
   if ( PyObject_HasAttrString( myPyModule, (char*)"activeStudyChanged" ) ) {
@@ -2552,7 +2552,7 @@ bool PyModuleHelper::internalIsDraggable( LightApp_DataObject* what )
 
   if ( PyObject_HasAttrString(myPyModule , (char*)"isDraggable") ) {
     PyObjWrapper res( PyObject_CallMethod( myPyModule, (char*)"isDraggable",
-                                          (char*)"s", what->entry().toLatin1().constData() ) );
+                      (char*)"s", what->entry().toLatin1().constData() ) );
     if( !res || !PyBool_Check( res )) {
       PyErr_Print();
       draggable = false;
@@ -2584,7 +2584,7 @@ bool PyModuleHelper::internalIsDropAccepted( LightApp_DataObject* where )
 
   if ( PyObject_HasAttrString(myPyModule , (char*)"isDropAccepted") ) {
     PyObjWrapper res( PyObject_CallMethod( myPyModule, (char*)"isDropAccepted",
-                                          (char*)"s", where->entry().toLatin1().constData() ) );
+                      (char*)"s", where->entry().toLatin1().constData() ) );
     if( !res || !PyBool_Check( res )) {
       PyErr_Print();
       dropAccepted = false;
@@ -2606,7 +2606,7 @@ bool PyModuleHelper::internalIsDropAccepted( LightApp_DataObject* where )
   \param action current drop action (copy or move)
 */
 void PyModuleHelper::internalDropObjects( const DataObjectList& what, SUIT_DataObject* where,
-                                         const int row, Qt::DropAction action )
+                                          const int row, Qt::DropAction action )
 {
   FuncMsg fmsg( "--- PyModuleHelper::internalDropObjects()" );
 
@@ -2631,10 +2631,10 @@ void PyModuleHelper::internalDropObjects( const DataObjectList& what, SUIT_DataO
   PyObjWrapper sipList( sipBuildResult( 0, "D", theList, sipType_QStringList, NULL) );
 #endif
   if ( PyObject_HasAttrString(myPyModule, (char*)"dropObjects") ) {
-    PyObjWrapper res( PyObject_CallMethod( myPyModule, (char*)"dropObjects", (char*)"Osii",
-                                          sipList.get(),
-                                          whereObject->entry().toLatin1().constData(),
-                                          row, action ) );
+      PyObjWrapper res( PyObject_CallMethod( myPyModule, (char*)"dropObjects", (char*)"Osii",
+                        sipList.get(),
+                        whereObject->entry().toLatin1().constData(),
+                        row, action ) );
     
     if( !res ) {
       PyErr_Print();
@@ -2663,13 +2663,13 @@ QString PyModuleHelper::internalEngineIOR() const
     if ( PyObject_HasAttrString( myPyModule , "engineIOR" ) ) {
       PyObjWrapper res( PyObject_CallMethod( myPyModule, (char*)"engineIOR", (char*)"" ) );
       if ( !res ) {
-       PyErr_Print();
+          PyErr_Print();
       }
       else {
-       // parse the return value, result chould be string
-       if ( PyString_Check( res ) ) {
-         ior = PyString_AsString( res );
-       }
+        // parse the return value, result chould be string
+        if ( PyString_Check( res ) ) {
+          ior = PyString_AsString( res );
+        }
       }
     }
   }
@@ -2688,24 +2688,24 @@ void PyModuleHelper::connectView( SUIT_ViewWindow* view )
   // Connect tryCloseView() and deleteView() signals
   if ( viewMgr ) {
     connect( viewMgr, SIGNAL( tryCloseView( SUIT_ViewWindow* ) ),
-            this, SLOT( tryCloseView( SUIT_ViewWindow* ) ),
-            Qt::UniqueConnection );
+             this, SLOT( tryCloseView( SUIT_ViewWindow* ) ),
+             Qt::UniqueConnection );
     connect( viewMgr, SIGNAL( deleteView( SUIT_ViewWindow* ) ),
              this, SLOT( closeView( SUIT_ViewWindow* ) ),
-            Qt::UniqueConnection );
+             Qt::UniqueConnection );
   }
   
   // Connect cloneView() signal of an OCC View
   if ( view->inherits( "OCCViewer_ViewWindow" ) ) {
     connect( view, SIGNAL( viewCloned( SUIT_ViewWindow* ) ), 
              this, SLOT( cloneView( SUIT_ViewWindow* ) ),
-            Qt::UniqueConnection );
+             Qt::UniqueConnection );
   }
   // Connect cloneView() signal of Plot2d View 
   else if ( viewModel && viewModel->inherits( "Plot2d_Viewer" ) ) {
     connect( viewModel, SIGNAL( viewCloned( SUIT_ViewWindow* ) ), 
              this, SLOT( cloneView( SUIT_ViewWindow* ) ),
-            Qt::UniqueConnection );
+             Qt::UniqueConnection );
   }
 }
 
index 98f6e8074bd7352d2a1d0f3c3226cea22769552b..b2adf2131e29245fce07d99d4c24ad5d5cea8a65 100644 (file)
@@ -103,7 +103,7 @@ public slots:
   bool                       isDraggable( const SUIT_DataObject* ) const;
   bool                       isDropAccepted( const SUIT_DataObject* ) const;
   void                       dropObjects( const DataObjectList&, SUIT_DataObject*,
-                                         const int, Qt::DropAction );
+                                          const int, Qt::DropAction );
   QString                    engineIOR() const;
 
   void                       onObjectBrowserClicked(SUIT_DataObject*, int);
@@ -133,7 +133,7 @@ private:
   bool                       internalIsDraggable( LightApp_DataObject* );
   bool                       internalIsDropAccepted( LightApp_DataObject* );
   void                       internalDropObjects( const DataObjectList&, SUIT_DataObject*,
-                                                 const int, Qt::DropAction );
+                                                  const int, Qt::DropAction );
   QString                    internalEngineIOR() const;
   void                       internalOBClickedPython( const QString&, int );
 
index 5a914f487395dee3ae96b8f6311ff992738609cf..692883aac15a6d27a3e49a917d4082a23ff5ab23 100755 (executable)
@@ -48,6 +48,15 @@ INCLUDE_DIRECTORIES(
   ${PROJECT_SOURCE_DIR}/src/SUIT
 )
 
+IF(SALOME_LIGHT_ONLY)
+  #disable 'ENABLE_CORBA' feature
+  SET(PYQT_SIPFLAGS ${PYQT_SIPFLAGS} "-xENABLE_CORBA;")
+ELSE(SALOME_LIGHT_ONLY)
+  INCLUDE_DIRECTORIES(
+    ${PROJECT_SOURCE_DIR}/src/SalomeApp
+  )
+ENDIF(SALOME_LIGHT_ONLY)
+
 # additional preprocessor / compiler flags
 ADD_DEFINITIONS(
   ${QWT_DEFINITIONS}
@@ -55,6 +64,7 @@ ADD_DEFINITIONS(
   ${CAS_DEFINITIONS}
   ${BOOST_DEFINITIONS}
   ${PYTHON_DEFINITIONS}
+  ${OMNIORB_DEFINITIONS}
 )
 
 # libraries to link to
index 084529e3b47354c44a622b51c5cc7555df62dad7..e9956afd4ffb74fb541d7a5774a602d6420f90fe 100644 (file)
@@ -33,6 +33,9 @@
 #include <QColor>
 
 #include <LightApp_Application.h>
+#ifndef GUI_DISABLE_CORBA
+#include <SalomeApp_Application.h>
+#endif
 #include <LightApp_Preferences.h>
 #include <Plot2d_ViewFrame.h>
 
@@ -82,7 +85,12 @@ enum {
   WT_ObjectBrowser = LightApp_Application::WT_ObjectBrowser,
   WT_PyConsole     = LightApp_Application::WT_PyConsole,
   WT_LogWindow     = LightApp_Application::WT_LogWindow,
+#ifndef GUI_DISABLE_CORBA
+  WT_NoteBook      = SalomeApp_Application::WT_NoteBook,
+  WT_User          = SalomeApp_Application::WT_User
+#else
   WT_User          = LightApp_Application::WT_User
+#endif
 };
 
 enum { 
index b021191868a54a077fbc2c559bd85c04c0423b59..2919a905d8086a3e4161b51dd4a87cb22ac32405 100644 (file)
@@ -25,6 +25,8 @@
 
 %Module SalomePyQt
 
+%Feature ENABLE_CORBA
+
 %Import QtGuimod.sip
 %Import QtXmlmod.sip
 
@@ -68,6 +70,9 @@ enum WindowType {
   WT_ObjectBrowser,
   WT_PyConsole,
   WT_LogWindow,
+%If (ENABLE_CORBA)
+  WT_NoteBook,
+%End
   WT_User
 };
 
index a4cb8a2941917242f0744401e0f110118858ef1e..c8932c133561fbeafee2882982b3c7e6bb53f82b 100755 (executable)
@@ -92,6 +92,5 @@ INSTALL(TARGETS _libSALOME_Swig DESTINATION ${SALOME_INSTALL_PYTHON})
 
 SALOME_INSTALL_SCRIPTS("${_swig_SCRIPTS}"  ${SALOME_INSTALL_PYTHON})
 SALOME_INSTALL_SCRIPTS("${_other_SCRIPTS}" ${SALOME_INSTALL_SCRIPT_DATA})
-SALOME_INSTALL_SCRIPTS(SALOMEGUI_shared_modules.py ${SALOME_INSTALL_PYTHON_SHARED})
 
 INSTALL(FILES ${libSALOME_Swig_HEADERS} DESTINATION ${SALOME_INSTALL_HEADERS})
diff --git a/src/SALOME_SWIG/SALOMEGUI_shared_modules.py b/src/SALOME_SWIG/SALOMEGUI_shared_modules.py
deleted file mode 100755 (executable)
index 6f51cf6..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-#  -*- coding: iso-8859-1 -*-
-# Copyright (C) 2007-2014  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, or (at your option) any later version.
-#
-# 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
-#
-
-"""
-
-"""
-
-try:
-   import SALOME_Session_idl
-except:
-   pass
-
-from import_hook import register_name
-register_name("SalomePyQt")
-   
-# this function is required
-
-def init_shared_modules():
-   """
-      This function initializes shared modules that need to be
-   """
-   pass
index c811b9680b6d0d0bf30b865d25231c07ec76c06b..4bb3a4c033cbaea56c4a36fc308cb39e5b038603 100644 (file)
@@ -400,11 +400,13 @@ SUIT_ViewWindow* SPlot2d_Viewer::createView( SUIT_Desktop* theDesktop )
   SLOT: called when action "Legend Clicked" is activated.
   override "onLegendClicked" method from Plot2d_ViewModel.
 */
-void SPlot2d_Viewer::onLegendClicked( QwtPlotItem* plotItem )
+void SPlot2d_Viewer::onClicked( const QVariant& itemInfo, int index )
 {
   Plot2d_ViewFrame* aViewFrame = getActiveViewFrame();
   if(aViewFrame == NULL) return;
 
+  QwtPlotItem* plotItem = aViewFrame->getPlot()->infoToItem( itemInfo );
+
   bool isAnalytical = false;
   AnalyticalCurveList curves = aViewFrame->getAnalyticalCurves();
    foreach ( Plot2d_AnalyticalCurve* curve, curves ) {
index 347fd79e29f7bf30b31028fca02400bd52f481b3..141a4e7d0f993deb4b3cd430f8fbabea0cbd6af1 100644 (file)
@@ -84,7 +84,7 @@ public:
   Handle(SALOME_InteractiveObject) FindIObject( const char* Entry );
 
 protected slots:
-  virtual void onLegendClicked( QwtPlotItem* plotItem );
+  virtual void onClicked( const QVariant&, int );
 
 signals:
   void legendSelected( const QString& );
index 8ed218f1d59ed1d805b7ee0e8771af1e9c47cb7f..9539d7ee38edfc5200fba71dfaafe2d7af57bc18 100755 (executable)
@@ -390,11 +390,17 @@ void STD_Application::afterCloseDoc()
 
 /*!Close document, if it's possible.*/
 void STD_Application::onCloseDoc( bool ask )
+{
+  closeDoc( ask );
+}
+
+/*!Close document, if it's possible.*/
+bool STD_Application::closeDoc( bool ask )
 {
   bool closePermanently = true;
 
   if ( ask && !isPossibleToClose( closePermanently ) )
-    return;
+    return false;
 
   SUIT_Study* study = activeStudy();
 
@@ -430,6 +436,7 @@ void STD_Application::onCloseDoc( bool ask )
 
   if ( !desktop() )
     closeApplication();
+  return true;
 }
 
 /*!Check the application on closing.
index fb443d36a979709878cae64054f5e430176aca9a..8e5703b01f9e6b6b8ab6d6ed29fd0ec8385d5597 100755 (executable)
@@ -167,6 +167,7 @@ protected:
 
   virtual int           closeChoice( const QString& );
   virtual bool          closeAction( const int, bool& );
+  virtual bool          closeDoc( bool ask = true );
 
 private:
   ViewManagerList       myViewMgrs;
index 4d5f96a858ef0ea358a676a6af99be1a08541fc6..6f7dbd730d3c0d43f69de527400bbd9b05c02714 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!DOCTYPE TS>
-<TS>
+<TS version="2.0" language="ja" sourcelanguage="en">
   <context>
     <name>@default</name>
     <message>
index 5fcd23c1778212994dd309e58f6fb28e401ca576..6ac1d67b386772679dd62b63f96faadd17a42456 100755 (executable)
@@ -711,34 +711,8 @@ void SUIT_TreeModel::setVisibilityState( const QString& id, Qtx::VisibilityState
 */
 void SUIT_TreeModel::setVisibilityStateForAll( Qtx::VisibilityState state )
 {
-  if ( state != Qtx::UnpresentableState ) {
-    VisibilityMap::ConstIterator it = myVisibilityMap.begin();
-    while ( it != myVisibilityMap.end() ) {
-      if ( it.value() != state )
-       setVisibilityState( it.key(), state );
-      it++;
-    }
-  }
-  else {
-    QList<QString> anIds = myVisibilityMap.keys();
-    myVisibilityMap.clear();
-    QList<QString>::ConstIterator it = anIds.begin();
-    while ( it != anIds.end() ) {
-      QModelIndexList lst;
-      if ( searcher() ) {
-       SUIT_DataObject* o = searcher()->findObject( *it );
-       if ( o ) lst << index( o );
-      }
-      else {
-       lst = match( index( 0, root()->customData( Qtx::IdType ).toInt() ), DisplayRole, (*it), 1, Qt::MatchExactly | Qt::MatchRecursive );
-      }
-      if ( !lst.isEmpty() ) {
-       QModelIndex idx = index( lst.first().row(), SUIT_DataObject::VisibilityId ,lst.first().parent() );
-       emit dataChanged( idx, idx );
-      }
-      it++;
-    }
-  }
+  foreach( QString id, myVisibilityMap.keys() )
+    setVisibilityState( id, state );
 }
 
 /*!
index d85573f3fe71bf1a60c37fb2dff4eff2a016356b..f641779cf716b72c1e1debfdfeba00e8fa4f7f77 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!DOCTYPE TS>
-<TS>
+<TS version="2.0" language="ja" sourcelanguage="en">
   <context>
     <name>@default</name>
     <message>
index 6d44983e9065be0dc13d8d75871463f6a22bb403..ee301cb25fce7f9bae9cf61ea1fbc5e786851da6 100644 (file)
@@ -97,29 +97,6 @@ static QString getAppName( const QString& libName )
 //   }
 // }
 
-/* XPM */
-static const char* pixmap_not_found_xpm[] = {
-"16 16 3 1",
-"       c None",
-".      c #000000",
-"+      c #A80000",
-"                ",
-"                ",
-"    .     .     ",
-"   .+.   .+.    ",
-"  .+++. .+++.   ",
-"   .+++.+++.    ",
-"    .+++++.     ",
-"     .+++.      ",
-"    .+++++.     ",
-"   .+++.+++.    ",
-"  .+++. .+++.   ",
-"   .+.   .+.    ",
-"    .     .     ",
-"                ",
-"                ",
-"                "};
-
 class SUITApp_Session: public SUIT_Session
 {
 public:
@@ -143,8 +120,6 @@ public:
 
     if ( resMgr )
     {
-      static QPixmap defaultPixmap( pixmap_not_found_xpm );
-      resMgr->setDefaultPixmap( defaultPixmap );
       resMgr->setOption( "translators", QString( "%P_msg_%L.qm|%P_icons.qm|%P_images.qm" ) );
     }
     return resMgr;
@@ -277,16 +252,7 @@ int main( int argc, char* argv[] )
     int   _argc   = 1;
     char* _argv[] = {(char*)""};
     SUIT_PYTHON::init_python(_argc,_argv);
-    
-    PyEval_RestoreThread( SUIT_PYTHON::_gtstate );
-    
-    if ( !SUIT_PYTHON::salome_shared_modules_module ) // import only once
-      SUIT_PYTHON::salome_shared_modules_module = PyImport_ImportModule( (char*)"salome_shared_modules" );
-    if ( !SUIT_PYTHON::salome_shared_modules_module ) 
-      PyErr_Print();
-    
-    PyEval_ReleaseThread( SUIT_PYTHON::_gtstate );
-
+    PyEval_ReleaseLock();
 #endif
 
     SUIT_Application* theApp = aSession->startApplication( argList.first() );
index 1f2be4ff03ea3186af56bf0d7dc04826b22a74fe..504bd14d8fcee83c2ec1080baa617f3010cd8a37 100644 (file)
 //
 #include "SUITApp_init_python.hxx"
 
-
-PyThreadState* SUIT_PYTHON::_gtstate                = NULL;
-PyObject *SUIT_PYTHON::salome_shared_modules_module = NULL;
-PyInterpreterState* SUIT_PYTHON::_interp            = NULL;
 bool SUIT_PYTHON::initialized                       = false;
 
 void SUIT_PYTHON::init_python(int argc, char **argv)
@@ -37,9 +33,7 @@ void SUIT_PYTHON::init_python(int argc, char **argv)
   Py_SetProgramName(argv[0]);
   Py_Initialize(); // Initialize the interpreter
   PySys_SetArgv(argc, argv);
-  SUIT_PYTHON::_interp = PyThreadState_Get()->interp;
-  PyEval_InitThreads(); // Create (and acquire) the interpreter lock
-  SUIT_PYTHON::_gtstate = PyEval_SaveThread(); // Release global thread state
+  PyEval_InitThreads(); // Create (and acquire) the interpreter lock - can be called many times
   SUIT_PYTHON::initialized = true;
 }
 
index 0ae8d1c7ade4f97b30df38ce7a3ebc089a86eb21..3d4e2231820e71adfb3a8c39f9dcad9fe66a0287 100644 (file)
 
 struct SUITAPP_EXPORT SUIT_PYTHON
 {
-  static PyThreadState *_gtstate;
-  static PyInterpreterState *_interp;
-  static PyObject *salome_shared_modules_module;
   static bool initialized;
   static void init_python(int argc, char **argv);
-
 };
 
 #endif // _SUITAPP_INIT_PYTHON_
index 113e4f0b0b9d2a67a1c55943b6baafab2e97ecbc..dbe33848b801d4bc21cf41c07b801f022c74728e 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!DOCTYPE TS>
-<TS>
+<TS version="2.0" language="ja" sourcelanguage="en">
   <context>
     <name>@default</name>
     <message>
index 8bbed38032062ccaa891a9cbfff9e052b1426b98..d5ccedbefe59f7690d755967d4b7c4002986c054 100644 (file)
@@ -558,6 +558,18 @@ SVTK_Renderer
     myTrihedron->VisibilityOn();
 }
 
+/*!
+  Set trihedron visibility
+*/
+void 
+SVTK_Renderer
+::SetTrihedronVisibility( const bool show ) {
+  if(show)
+    myTrihedron->VisibilityOn();
+  else
+    myTrihedron->VisibilityOff();  
+}
+
 /*!
   Adjust size of the trihedron to the bounding box of the scene
 */
index 91421aa4ae0bf6a43c06ede1b4c3bcc8eb94f848..19e7f51e870d486e2037f190c24f94434fb52a29 100644 (file)
@@ -153,6 +153,11 @@ class SVTK_EXPORT SVTK_Renderer : public vtkObject
   void 
   OnViewTrihedron(); 
 
+  //! Set Toggle trihedron visibility
+
+  void
+  SetTrihedronVisibility( const bool );
+
   //! Adjust size of the trihedron to the bounding box of the scene
   void 
   OnAdjustTrihedron();
index 63ed448bc7b949b273bbf909ad527eee334d02c6..d56dde955cb163a7d2ecb1ae12e500e2f75d6d9c 100755 (executable)
@@ -799,9 +799,9 @@ bool SVTK_ViewWindow::isCubeAxesDisplayed()
 /*!
   Redirect the request to #SVTK_Renderer::OnViewTrihedron
 */
-void SVTK_ViewWindow::onViewTrihedron()
+void SVTK_ViewWindow::onViewTrihedron(bool show)
 {
-  GetRenderer()->OnViewTrihedron();
+  GetRenderer()->SetTrihedronVisibility(show);
   Repaint();
 }
 
@@ -2050,8 +2050,11 @@ void SVTK_ViewWindow::createActions(SUIT_ResourceMgr* theResourceMgr)
   anAction = new QtxAction(tr("MNU_SHOW_TRIHEDRON"), 
                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_TRIHEDRON" ) ),
                            tr( "MNU_SHOW_TRIHEDRON" ), 0, this);
+  anAction->setCheckable( true );
+  anAction->setChecked( true );
+  
   anAction->setStatusTip(tr("DSC_SHOW_TRIHEDRON"));
-  connect(anAction, SIGNAL(activated()), this, SLOT(onViewTrihedron()));
+  connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onViewTrihedron(bool)));
   mgr->registerAction( anAction, ViewTrihedronId );
 
   // onNonIsometric: Manage non-isometric params
index 3ee736b38b5969a3e1af8eb9ff37075a6a4dfede..ef6eb8a55bb196ec57e382afe6af95cb6fe9bb11 100755 (executable)
@@ -365,7 +365,7 @@ public slots:
   virtual void onFitAll();
 
   //! Redirect the request to #SVTK_Renderer::OnViewTrihedron
-  virtual void onViewTrihedron(); 
+  virtual void onViewTrihedron(bool); 
 
   //! Redirect the request to #SVTK_Renderer::OnViewCubeAxes
   virtual void onViewCubeAxes();
index baf4c4f7652822ba29b08d332ef359e2eb9f9466..dd996207cb68dd7c19dbdbec3fd8e98d16168ae2 100644 (file)
@@ -449,7 +449,7 @@ Please, refer to the documentation.</translation>
     </message>
     <message>
         <source>LBL_SELECTPOINT</source>
-        <translation>Gravity Center of Select Object</translation>
+        <translation>Gravity Center of Selected Object</translation>
     </message>
     <message>
         <source>LBL_POINT</source>
index 24b7fe4a9846eecdf2eb524d36e9e3f24783b4ee..3fec5f98de0870ea904f6e0bb546cadef35afc24 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!DOCTYPE TS>
-<TS>
+<TS version="2.0" language="ja" sourcelanguage="en">
   <context>
     <name>@default</name>
     <message>
       <source>LBL_SELECTPOINT</source>
       <translation>ビューのポイントを選択します。</translation>
     </message>
+    <message>
+      <source>LBL_POINT</source>
+      <translation>点</translation>
+    </message>
+    <message>
+      <source>LBL_EDGE</source>
+      <translation>エッジ</translation>
+    </message>
+    <message>
+      <source>LBL_FACE</source>
+      <translation>面</translation>
+    </message>
+    <message>
+      <source>LBL_VOLUME</source>
+      <translation>ボリューム</translation>
+    </message>
     <message>
       <source>DLG_TITLE</source>
       <translation>回転中心設定</translation>
index 3291a9a0884c974a530216696f93dc17bae39da5..4182bfcb145eb352d8fe696b0e722b86999e625a 100644 (file)
@@ -54,7 +54,6 @@
 #include <LightApp_SelectionMgr.h>
 #include <LightApp_NameDlg.h>
 #include <LightApp_DataOwner.h>
-#include <LightApp_Displayer.h>
 
 #include <CAM_Module.h>
 
@@ -165,8 +164,6 @@ extern "C" SALOMEAPP_EXPORT SUIT_Application* createApplication()
 SalomeApp_Application::SalomeApp_Application()
   : LightApp_Application()
 {
-  connect( desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
-           this,      SLOT( onWindowActivated( SUIT_ViewWindow* ) ), Qt::UniqueConnection );
   connect( desktop(), SIGNAL( message( const QString& ) ),
            this, SLOT( onLoadDocMessage( const QString& ) ), Qt::UniqueConnection );
   myIsSiman = false; // default
@@ -323,12 +320,13 @@ void SalomeApp_Application::createActions()
                 tr( "MEN_DESK_REGISTRY_DISPLAY" ), tr( "PRP_DESK_REGISTRY_DISPLAY" ),
                 /*Qt::SHIFT+Qt::Key_D*/0, desk, false, this, SLOT( onRegDisplay() ) );
 
-  //SRN: BugID IPAL9021, add an action "Load"
-  createAction( FileLoadId, tr( "TOT_DESK_FILE_LOAD" ),
-                resourceMgr()->loadPixmap( "STD", tr( "ICON_FILE_OPEN" ) ),
-                tr( "MEN_DESK_FILE_LOAD" ), tr( "PRP_DESK_FILE_LOAD" ),
-                Qt::CTRL+Qt::Key_L, desk, false, this, SLOT( onLoadDoc() ) );
-  //SRN: BugID IPAL9021: End
+  //rnv commented : implementation of the mono-study in GUI
+  //
+  //createAction( FileLoadId, tr( "TOT_DESK_FILE_LOAD" ),
+  //              resourceMgr()->loadPixmap( "STD", tr( "ICON_FILE_OPEN" ) ),
+  //              tr( "MEN_DESK_FILE_LOAD" ), tr( "PRP_DESK_FILE_LOAD" ),
+  //              Qt::CTRL+Qt::Key_L, desk, false, this, SLOT( onLoadDoc() ) );
+
 
 #ifdef WITH_SIMANIO
   if (myIsSiman) {
@@ -348,7 +346,7 @@ void SalomeApp_Application::createActions()
   // creation of menu item is moved to VISU
   //  createMenu( SaveGUIStateId, fileMenu, 10, -1 );
 
-  createMenu( FileLoadId,   fileMenu, 0 );  //SRN: BugID IPAL9021, add a menu item "Load"
+  // createMenu( FileLoadId,   fileMenu, 0 );
 
 #ifdef WITH_SIMANIO
   if (myIsSiman) {
@@ -376,12 +374,13 @@ void SalomeApp_Application::createActions()
 #ifndef DISABLE_PYCONSOLE
 #ifndef DISABLE_SALOMEOBJECT
   // import Python module that manages SALOME plugins
-  PyGILState_STATE gstate = PyGILState_Ensure();
-  PyObjWrapper pluginsmanager = PyImport_ImportModule((char*)"salome_pluginsmanager");
-  PyObjWrapper res = PyObject_CallMethod( pluginsmanager, (char*)"initialize", (char*)"isss",0,"salome",tr("MEN_DESK_PLUGINS_TOOLS").toStdString().c_str(),tr("MEN_DESK_PLUGINS").toStdString().c_str());
-  if ( !res )
-    PyErr_Print();
-  PyGILState_Release(gstate);
+  {
+    PyLockWrapper lck; // acquire GIL
+    PyObjWrapper pluginsmanager = PyImport_ImportModule((char*)"salome_pluginsmanager");
+    PyObjWrapper res = PyObject_CallMethod( pluginsmanager, (char*)"initialize", (char*)"isss",0,"salome",tr("MEN_DESK_PLUGINS_TOOLS").toStdString().c_str(),tr("MEN_DESK_PLUGINS").toStdString().c_str());
+    if ( !res )
+      PyErr_Print();
+  }
   // end of SALOME plugins loading
 #endif
 #endif
@@ -395,8 +394,6 @@ void SalomeApp_Application::setDesktop( SUIT_Desktop* desk )
   LightApp_Application::setDesktop( desk );
 
   if ( desk ) {
-    connect( desk, SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
-             this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ), Qt::UniqueConnection );
     connect( desk, SIGNAL( message( const QString& ) ),
              this, SLOT( onLoadDocMessage( const QString& ) ), Qt::UniqueConnection );
   }
@@ -427,6 +424,11 @@ void SalomeApp_Application::onLoadDoc()
 
   std::vector<std::string> List = studyMgr()->GetOpenStudies();
 
+  // rnv: According to the single-study approach on the server side
+  //      can be only one study. So if it is exists connect to them,  
+  //      overwise show warning message: "No active study on the server"
+
+  /*
   SUIT_Session* aSession = SUIT_Session::session();
   QList<SUIT_Application*> aAppList = aSession->applications();
 
@@ -448,10 +450,19 @@ void SalomeApp_Application::onLoadDoc()
      if ( !isAlreadyOpen )
        unloadedStudies << studyName;
   }
-
   studyName = SalomeApp_LoadStudiesDlg::selectStudy( desktop(), unloadedStudies );
   if ( studyName.isEmpty() )
     return;
+  */
+
+  if(List.size() <= 0) {
+    SUIT_MessageBox::warning( desktop(),
+                              QObject::tr("WRN_WARNING"),
+                              QObject::tr("WRN_NO_STUDY_ON SERV") );
+    return;
+  }
+  
+  studyName = List[0].c_str();
 
 #ifndef WIN32
   // this code replaces marker of windows drive and path become invalid therefore
@@ -498,6 +509,10 @@ void SalomeApp_Application::onNewWithScript()
 /*!SLOT. Load document with \a aName.*/
 bool SalomeApp_Application::onLoadDoc( const QString& aName )
 {
+#ifdef SINGLE_DESKTOP
+  if ( !LightApp_Application::closeDoc() )
+    return false;
+#endif
   bool res = true;
   if ( !activeStudy() ) {
     // if no study - load in current desktop
@@ -1138,15 +1153,16 @@ int SalomeApp_Application::closeChoice( const QString& docName )
 {
   int answer = SUIT_MessageBox::question( desktop(), tr( "APPCLOSE_CAPTION" ), tr( "APPCLOSE_DESCRIPTION" ).arg( docName ),
                                           tr ("APPCLOSE_SAVE"), tr ("APPCLOSE_CLOSE"),
-                                          tr ("APPCLOSE_UNLOAD"), tr ("APPCLOSE_CANCEL"), 0 );
+                                         //tr ("APPCLOSE_UNLOAD"), 
+                                         tr ("APPCLOSE_CANCEL"), 0 );
 
   int res = CloseCancel;
   if ( answer == 0 )
     res = CloseSave;
   else if ( answer == 1 )
     res = CloseDiscard;
-  else if ( answer == 2 )
-    res = CloseUnload;
+  // else if ( answer == 2 )
+  //   res = CloseUnload;
 
   return res;
 }
@@ -1249,7 +1265,10 @@ bool SalomeApp_Application::openAction( const int aChoice, const QString& aName
 QMap<int, QString> SalomeApp_Application::activateModuleActions() const
 {
   QMap<int, QString> opmap = LightApp_Application::activateModuleActions();
-  opmap.insert( LoadStudyId,     tr( "ACTIVATE_MODULE_OP_LOAD" ) );
+
+  // rnv commented : implementation of the mono-study in GUI
+  // opmap.insert( LoadStudyId,     tr( "ACTIVATE_MODULE_OP_LOAD" ) );
+
   opmap.insert( NewAndScriptId,  tr( "ACTIVATE_MODULE_OP_SCRIPT" ) );
   return opmap;
 }
@@ -1564,47 +1583,28 @@ void SalomeApp_Application::onStudyCreated( SUIT_Study* study )
 {
   LightApp_Application::onStudyCreated( study );
 
-#ifndef DISABLE_PYCONSOLE
-  desktop()->tabifyDockWidget( windowDock( getWindow( WT_NoteBook ) ),
-                               windowDock( getWindow( WT_ObjectBrowser ) ) );
-#endif
+//#ifndef DISABLE_PYCONSOLE
+//  desktop()->tabifyDockWidget( windowDock( getWindow( WT_NoteBook ) ),
+//                               windowDock( getWindow( WT_ObjectBrowser ) ) );
+//#endif
 
   loadDockWindowsState();
 
-  connect( this, SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
-           this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ), Qt::UniqueConnection );
-
-
   objectBrowserColumnsVisibility();
 }
 
-/*!Called on Save study operation*/
-void SalomeApp_Application::onStudySaved( SUIT_Study* study )
-{
-  LightApp_Application::onStudySaved( study );
-
-  // temporary commented
-  /*if ( objectBrowser() ) {
-    updateSavePointDataObjects( dynamic_cast<SalomeApp_Study*>( study ) );
-    objectBrowser()->updateTree( study->root() );
-  }*/
-}
-
 /*!Called on Open study operation*/
 void SalomeApp_Application::onStudyOpened( SUIT_Study* study )
 {
   LightApp_Application::onStudyOpened( study );
 
-#ifndef DISABLE_PYCONSOLE
-  desktop()->tabifyDockWidget( windowDock( getWindow( WT_NoteBook ) ),
-                               windowDock( getWindow( WT_ObjectBrowser ) ) );
-#endif
+//#ifndef DISABLE_PYCONSOLE
+//  desktop()->tabifyDockWidget( windowDock( getWindow( WT_NoteBook ) ),
+//                               windowDock( getWindow( WT_ObjectBrowser ) ) );
+//#endif
 
   loadDockWindowsState();
 
-  connect( this, SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
-           this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ), Qt::UniqueConnection );
-
   objectBrowserColumnsVisibility();
 
   // temporary commented
@@ -1837,80 +1837,6 @@ void SalomeApp_Application::onExtAction()
     printf("Error: Can't Invoke method %s\n", qPrintable(aDataList[1]));
 }
 
-/*!
- * Called when window activated
- */
-void SalomeApp_Application::onWindowActivated( SUIT_ViewWindow* theViewWindow )
-{
-  SUIT_DataBrowser* anOB = objectBrowser();
-  if( !anOB )
-    return;
-  SUIT_DataObject* rootObj = anOB->root();
-  if( !rootObj )
-    return;
-
-  DataObjectList listObj = rootObj->children( true );
-
-  SUIT_ViewModel* vmod = 0;
-  if ( SUIT_ViewManager* vman = theViewWindow->getViewManager() )
-    vmod = vman->getViewModel();
-  updateVisibilityState( listObj, vmod );
-}
-
-/*!
-  Update visibility state of given objects
- */
-void SalomeApp_Application::updateVisibilityState( DataObjectList& theList,
-                                                   SUIT_ViewModel*  theViewModel )
-{
-  LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>(activeStudy());
-
-  if(!theViewModel)
-    return;
-
-  SALOME_View* aView = dynamic_cast<SALOME_View*>( theViewModel );
-
-  if (theList.isEmpty() || !aStudy)
-    return;
-
-  for ( DataObjectList::iterator itr = theList.begin(); itr != theList.end(); ++itr ) {
-    LightApp_DataObject* obj = dynamic_cast<LightApp_DataObject*>(*itr);
-
-    if (!obj || aStudy->isComponent(obj->entry()))
-      continue;
-
-    LightApp_Module* anObjModule = dynamic_cast<LightApp_Module*>(obj->module());
-    Qtx::VisibilityState anObjState = Qtx::UnpresentableState;
-
-    if(anObjModule) {
-      LightApp_Displayer* aDisplayer = anObjModule->displayer();
-      if(aDisplayer) {
-        if( aDisplayer->canBeDisplayed(obj->entry(), theViewModel->getType()) ) {
-          if(aView && aDisplayer->IsDisplayed(obj->entry(),aView))
-            anObjState = Qtx::ShownState;
-          else
-            anObjState = Qtx::HiddenState;
-        }
-       aStudy->setVisibilityState( obj->entry(), anObjState );
-      }
-    }
-  }
-}
-
-/*!
-  Called then view manager removed
-*/
-void SalomeApp_Application::onViewManagerRemoved( SUIT_ViewManager* )
-{
-  ViewManagerList lst;
-  viewManagers(lst);
-  if( lst.count() == 1) { // in case if closed last view window
-    LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>(activeStudy());
-    if(aStudy)
-      aStudy->setVisibilityStateForAll(Qtx::UnpresentableState);
-  }
-}
-
 /*!
   Checks that an object can be renamed.
   \param entry entry of the object
@@ -1947,35 +1873,6 @@ bool SalomeApp_Application::renameObject( const QString& entry, const QString& n
   return false;
 }
 
-/*!
-  \return default windows( Object Browser, Python Console )
-  Adds to map \a aMap.
-*/
-void SalomeApp_Application::defaultWindows( QMap<int, int>& aMap ) const
-{
-  LightApp_Application::defaultWindows(aMap);
-#ifndef DISABLE_PYCONSOLE
-  if ( !aMap.contains( WT_NoteBook ) ) {
-    if ( !myNoteBook ) {
-      aMap.insert( WT_NoteBook, Qt::LeftDockWidgetArea );
-    }
-  }
-#endif
-}
-
-/*!
-  Gets current windows.
-  \param winMap - output current windows map.
-*/
-void SalomeApp_Application::currentWindows(QMap<int, int>& aMap) const
-{
-  LightApp_Application::currentWindows( aMap );
-#ifndef DISABLE_PYCONSOLE
-  if ( !aMap.contains( WT_NoteBook) && myNoteBook )
-    aMap.insert( WT_NoteBook, Qt::LeftDockWidgetArea );
-#endif
-}
-
 #ifndef DISABLE_PYCONSOLE
 //============================================================================
 /*! Function : onUpdateStudy
@@ -2147,3 +2044,49 @@ void SalomeApp_Application::afterCloseDoc()
 #endif
   LightApp_Application::afterCloseDoc();
 }
+
+/*
+  Asks to close existing document.
+*/
+bool SalomeApp_Application::checkExistingDoc() {
+  bool result = true;
+  if( activeStudy() ) {
+    int answer = SUIT_MessageBox::question( desktop(), 
+                                           tr( "APPCLOSE_CAPTION" ), 
+                                           tr( "STUDYCLOSE_DESCRIPTION" ),
+                                           tr( "APPCLOSE_SAVE" ), 
+                                           tr( "APPCLOSE_CLOSE" ),
+                                           tr( "APPCLOSE_CANCEL" ), 0 );
+    if(answer == 0) {
+      if ( activeStudy()->isSaved() ) {
+       onSaveDoc();
+       closeDoc( false );
+      } else if ( onSaveAsDoc() ) {
+       if( !closeDoc( false ) ) {
+         result = false;
+       }
+      } else {
+       result = false;
+      }        
+    }
+    else if( answer == 1 ) {
+      closeDoc( false );
+    } else if( answer == 2 ) {
+      result = false;
+    }
+  } else {
+    SALOMEDSClient_StudyManager* aMgr = studyMgr();
+    if( aMgr ) {
+      std::vector<std::string> List = studyMgr()->GetOpenStudies();
+      if( List.size() > 0 ) {
+        int answer = SUIT_MessageBox::question( desktop(), tr( "WRN_WARNING" ), tr( "QUE_ACTIVEDOC_LOAD" ),
+                                                SUIT_MessageBox::Yes | SUIT_MessageBox::No, SUIT_MessageBox::No );
+        if ( answer == SUIT_MessageBox::Yes ) {
+         onLoadDoc();
+       }
+       result = false;
+      }
+    }
+  }
+  return result;
+}
index 88f577dcc0c6d4cdb4b9e166152b8c5792c79191..5d999d1a9135e8fb063d7929021e4e9880fe34c8 100644 (file)
@@ -34,8 +34,6 @@
 #include "SalomeApp.h"
 #include <LightApp_Application.h>
 
-#include <SUIT_DataObject.h>
-
 #include <omniORB4/CORBA.h>
 
 //#include <SALOMEconfig.h>
 class LightApp_Preferences;
 class SalomeApp_Study;
 #ifndef DISABLE_PYCONSOLE
-  class SalomeApp_NoteBook;
+class SalomeApp_NoteBook;
 #endif
 class SUIT_Desktop;
-
-class SUIT_ViewModel;
 class SALOME_LifeCycleCORBA;
 
 
@@ -76,7 +72,9 @@ public:
          CatalogGenId, RegDisplayId, SaveGUIStateId, FileLoadId, UserID,
          SimanCheckInId, SimanLocalCheckInId };
 
-  typedef enum { WT_NoteBook = LightApp_Application::WT_User } WindowTypes;
+  typedef enum { WT_NoteBook = LightApp_Application::WT_User,
+                 WT_User
+               } WindowTypes;
 
 protected:
   enum { OpenRefresh = LightApp_Application::OpenReload + 1 };
@@ -98,6 +96,8 @@ public:
   virtual bool                        checkDataObject(LightApp_DataObject* theObj);
 
   virtual void                        setDesktop( SUIT_Desktop* );
+  
+  virtual bool                        checkExistingDoc();
 
   static CORBA::ORB_var               orb();
   static SALOMEDSClient_StudyManager* studyMgr();
@@ -111,17 +111,12 @@ public:
 
   virtual bool                        useStudy( const QString& );
   virtual void                        updateDesktopTitle();
-  virtual void                        currentWindows( QMap<int, int>& ) const;
 
 #ifndef DISABLE_PYCONSOLE
   virtual void                        setNoteBook(SalomeApp_NoteBook* theNoteBook);
   virtual SalomeApp_NoteBook*         getNoteBook() const;
 #endif
 
- //! update visibility state of objects
-  void                                updateVisibilityState( DataObjectList& theList,
-                                                             SUIT_ViewModel* theViewModel );  
-
   virtual bool                        renameAllowed( const QString& ) const;
   virtual bool                        renameObject( const QString&, const QString& );
   
@@ -148,12 +143,8 @@ public slots:
 
 protected slots:
   void                                onStudyCreated( SUIT_Study* );
-  void                                onStudySaved( SUIT_Study* );
   void                                onStudyOpened( SUIT_Study* );
-  void                                onStudyClosed( SUIT_Study* );
   
-  void                                onViewManagerRemoved( SUIT_ViewManager* );
-
 protected:
   virtual void                        createActions();
   virtual SUIT_Study*                 createNewStudy();
@@ -173,8 +164,6 @@ protected:
   virtual QMap<int, QString>          activateModuleActions() const;
   virtual void                        moduleActionSelected( const int );
 
-  virtual void                        defaultWindows( QMap<int, int>& ) const;
-
   void                                objectBrowserColumnsVisibility();
 
 #ifndef DISABLE_PYCONSOLE
@@ -198,8 +187,6 @@ private slots:
   void                                onOpenWith();
   void                                onExtAction();
 
-  void                                onWindowActivated( SUIT_ViewWindow* theViewWindow );
-
 private:
   void                                createExtraActions();
 
index eb9b2c957485d70c9f71e3ea583cafc2f96836ce..336ecad71ae7e6d8afbc6d78e894ba2f384211bf 100644 (file)
@@ -440,7 +440,7 @@ SalomeApp_DoubleSpinBox::SearchState SalomeApp_DoubleSpinBox::findVariable( cons
 #ifndef DISABLE_PYCONSOLE
               PyConsole_Console* pyConsole = app->pythonConsole();
               PyConsole_Interp* pyInterp = pyConsole->getInterp();
-              PyLockWrapper aLock = pyInterp->GetLockWrapper();
+              PyLockWrapper aLock; // Acquire GIL
               std::string command;
               command  = "import salome_notebook ; ";
               command += "salome_notebook.notebook.setAsReal(\"";
index d068f29c3a391b17cd5f352e19dbbe8097c37d2a..d23eb4b044681d7afd0167b49836e51573ec587a 100644 (file)
@@ -115,13 +115,12 @@ extern "C" SALOMEAPP_EXPORT SUIT_ExceptionHandler* getExceptionHandler()
   // We disable FPE signal as it was in earlier versions of SALOME. It is enabled
   // only in debug mode if the environment variable DISABLE_FPE is not set to 1.
   bool raiseFPE;
-#if defined(_DEBUG_) | defined(_DEBUG) //the Last for WIN32 default settings
-  raiseFPE = true;
-  char* envDisableFPE = getenv("DISABLE_FPE");
-  if (envDisableFPE && atoi(envDisableFPE))
-    raiseFPE = false;
-#else
   raiseFPE = false;
+
+#if defined(_DEBUG_) | defined(_DEBUG) //the Last for WIN32 default settings
+  char* envEnableFPE = getenv("ENABLE_FPE");
+  if (envEnableFPE && atoi(envEnableFPE))
+    raiseFPE = true;
 #endif
 
   return new SalomeApp_ExceptionHandler( raiseFPE );
index 4460cd446b317a634f9605c6f2b8816398ce2f21..1e57bd3fafdae0079a2cc9bc8e8c110b16d68e82 100644 (file)
@@ -388,7 +388,7 @@ SalomeApp_IntSpinBox::SearchState SalomeApp_IntSpinBox::findVariable( const QStr
 #ifndef DISABLE_PYCONSOLE
               PyConsole_Console* pyConsole = app->pythonConsole();
               PyConsole_Interp* pyInterp = pyConsole->getInterp();
-              PyLockWrapper aLock = pyInterp->GetLockWrapper();
+              PyLockWrapper aLock; // Acquire GIL
               std::string command;
               command  = "import salome_notebook ; ";
               command += "salome_notebook.notebook.setAsInteger(\"";
index 21e27eb0d1811e15a282f22e6e0a4b07f15ccfcc..2b8fb0ae9bc42ac3bec0ece0c5c8717211f990d6 100644 (file)
@@ -53,8 +53,7 @@
 
 /*!Constructor.*/
 SalomeApp_Module::SalomeApp_Module( const QString& name )
-  : LightApp_Module( name ),
-    myIsFirstActivate( true )
+  : LightApp_Module( name )
 {
 }
 
@@ -141,22 +140,6 @@ void SalomeApp_Module::storeVisualParameters(int savePoint)
 {
 }
 
-
-/*!Activate module.*/
-bool SalomeApp_Module::activateModule( SUIT_Study* theStudy )
-{
-  bool state = LightApp_Module::activateModule( theStudy );
-
-  if (!myIsFirstActivate)
-    return state;
-  
-  updateModuleVisibilityState();
-
-  myIsFirstActivate = false;
-  
-  return state;
-}
-
 /*!
  * \brief Virtual public
  *
@@ -166,94 +149,3 @@ bool SalomeApp_Module::activateModule( SUIT_Study* theStudy )
 void SalomeApp_Module::restoreVisualParameters(int savePoint)
 {
 }
-
-/*! Redefined to reset internal flags valid for study instance */
-void SalomeApp_Module::studyClosed( SUIT_Study* theStudy )
-{
-  LightApp_Module::studyClosed( theStudy );
-  
-  myIsFirstActivate = true;
-  
-  LightApp_Application* app = dynamic_cast<LightApp_Application*>(application());
-  if (!app)
-    return;
-  
-  SUIT_DataBrowser* ob = app->objectBrowser();
-  if (ob && ob->model())
-    disconnect( ob->model(), SIGNAL( clicked( SUIT_DataObject*, int ) ),
-                this, SLOT( onObjectClicked( SUIT_DataObject*, int ) ) );
-}
-
-
-/*!
- * \brief Virtual public slot
- *
- * This method is called after the object inserted into data view to update their visibility state
- * This is default implementation
- */
-void SalomeApp_Module::onObjectClicked( SUIT_DataObject* theObject, int theColumn )
-{
-  if (!isActiveModule())
-    return;
-  // change visibility of object
-  if (!theObject || theColumn != SUIT_DataObject::VisibilityId )
-    return;
-
-  SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
-  if( !study )
-    return;
-
-  LightApp_DataObject* lo = dynamic_cast<LightApp_DataObject*>(theObject);
-  if(!lo)
-    return;
-  
-  // detect action index (from LightApp level)
-  int id = -1;
-  
-  if ( study->visibilityState(lo->entry()) == Qtx::ShownState )
-    id = myErase;
-  else if ( study->visibilityState(lo->entry()) == Qtx::HiddenState )
-    id = myDisplay;
-  
-  if ( id != -1 )
-    startOperation( id );
-}
-
-
-/*!
-  Called then study closed
-*/
-void SalomeApp_Application::onStudyClosed( SUIT_Study* theStudy){
-  LightApp_Application::onStudyClosed(theStudy);
-
-  disconnect( this, SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
-             this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ) );
-}
-
-
-void SalomeApp_Module::updateModuleVisibilityState() {
-
-  // update visibility state of objects
-  SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
-  if (!app)
-    return;
-  
-  SUIT_DataBrowser* ob = app->objectBrowser();
-  if (!ob || !ob->model())
-    return;
-
-  // connect to click on item
-  connect( ob->model(), SIGNAL( clicked( SUIT_DataObject*, int ) ),
-           this, SLOT( onObjectClicked( SUIT_DataObject*, int ) ), Qt::UniqueConnection );
-
-  SUIT_DataObject* rootObj = ob->root();
-  if( !rootObj )
-    return;
-  
-  DataObjectList listObj = rootObj->children( true );
-  
-  SUIT_ViewModel* vmod = 0;
-  if ( SUIT_ViewManager* vman = app->activeViewManager() )
-    vmod = vman->getViewModel();
-  app->updateVisibilityState( listObj, vmod );
-}
index d9c0852b292454c9047bfff897b14de5ac52dc7e..2f4c7feeaf3c75d9e4ded8eaa3240c79654e4d8c 100644 (file)
@@ -64,20 +64,9 @@ public:
   virtual void                        restoreVisualParameters(int savePoint);
   virtual LightApp_Selection*         createSelection() const;
   
-  public slots:
-  virtual bool                        activateModule( SUIT_Study* );
-  virtual void                        studyClosed( SUIT_Study* );
-  virtual void                        onObjectClicked( SUIT_DataObject*, int );
-
-  virtual void                        updateModuleVisibilityState();
-
 protected:
   virtual CAM_DataModel*              createDataModel();
   virtual void                        extractContainers( const SALOME_ListIO&, SALOME_ListIO& ) const;
-
-
- protected:
-  bool myIsFirstActivate;
 };
 
 #endif
index 7f4807f8db1fa2a1ced33328dcec36e65474152c..45d8dea5bbb5a7bddcd8b49c4461a4ba66410d8b 100644 (file)
@@ -286,7 +286,7 @@ bool NoteBook_TableRow::IsValidStringValue(const QString theValue)
   SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
   PyConsole_Console* pyConsole = app->pythonConsole();
   PyConsole_Interp* pyInterp = pyConsole->getInterp();
-  PyLockWrapper aLock = pyInterp->GetLockWrapper();
+  PyLockWrapper aLock; // Acquire GIL
   std::string command = "import salome_notebook ; ";
   command += "salome_notebook.checkThisNoteBook(";
   for( int i = 0, n = aLastRowIsEmpty ? aNumRows - 1 : aNumRows; i < n; i++ ) {
@@ -460,7 +460,7 @@ bool NoteBook_Table::IsValid() const
   SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
   PyConsole_Console* pyConsole = app->pythonConsole();
   PyConsole_Interp* pyInterp = pyConsole->getInterp();
-  PyLockWrapper aLock = pyInterp->GetLockWrapper();
+  PyLockWrapper aLock; // Acquire GIL
   std::string command = "import salome_notebook ; ";
   command += "salome_notebook.checkThisNoteBook(";
   for( int i = 0, n = aLastRowIsEmpty ? aNumRows - 1 : aNumRows; i < n; i++ )
index 8eea465fa7c5746fd3f24e4cfae0237108086474..3adde1b6be2c319e0192abedb15dd88242be7f0d 100755 (executable)
@@ -48,70 +48,14 @@ SalomeApp_PyInterp::~SalomeApp_PyInterp()
 {
 }
  
-/*!\class SalomeApp_PyInterp
- * EDF-CCAR
- * When SALOME uses multi Python interpreter feature,
- * Every study has its own interpreter and thread state (_tstate = Py_NewInterpreter())
- * This is fine because every study has its own modules (sys.modules) stdout and stderr
- * BUT some Python modules must be imported only once. In multi interpreter context Python
- * modules (*.py) are imported several times.
- * The pyqt module must be imported only once because it registers classes in a C module.
- * It's quite the same with omniorb modules (internals and generated with omniidl)
- * This problem is handled with "shared modules" defined in salome_shared_modules.py
- * These "shared modules" are imported only once and only copied in all the other interpreters
- * BUT it's not the only problem. Every interpreter has its own __builtin__ module. That's fine
- * but if we have copied some modules and imported others problems may arise with operations that
- * are not allowed in restricted execution environment. So we must impose that all interpreters
- * have identical __builtin__ module.
- * That's all, for the moment ...
- */
-
-
-bool SalomeApp_PyInterp::initContext()
-{
-  /*!
-   * The GIL is assumed to be held
-   * It is the caller responsability caller to acquire the GIL
-   * It will still be held on initContext output
-   */
-  if ( !PyConsole_Interp::initContext() )
-    return false;
-
-  // Import special module to change the import mechanism
-  PyObjWrapper m1( PyImport_ImportModule( "import_hook" ) );
-  if ( !m1 )
-  {
-    MESSAGE( "initContext: problem with import_hook import" );
-    PyErr_Print();
-    ASSERT( 0 );
-    return false;
-  }
-
-  // Call init_shared_modules to initialize the shared import mechanism for modules 
-  //that must not be imported twice
-  PyObjWrapper m2( PyObject_CallMethod( m1, (char*)"init_shared_modules", (char*)"O", KERNEL_PYTHON::salome_shared_modules_module ) );
-  if ( !m2 )
-  {
-    MESSAGE( "initContext: problem with init_shared_modules call" );
-    PyErr_Print();
-    ASSERT( 0 );
-    return false;
-  }
-
-  return true;
-}
-
 /*!
-  Do nothing
-  The initialization has been done in main
+  Do nothing (we could rely on the test done in the implementation of this method in the super
+  class PyInterp_Interp, but in this context we are sure the initialization has been done in main()
+  of SALOME_Session_Server)
  */
 void SalomeApp_PyInterp::initPython()
 {
-  MESSAGE("SalomeApp_PyInterp::initPython");
-  ASSERT(KERNEL_PYTHON::_gtstate); // initialisation in main
-  SCRUTE(KERNEL_PYTHON::_gtstate);
-  _gtstate=KERNEL_PYTHON::_gtstate;
-  _interp=KERNEL_PYTHON::_interp;
+  MESSAGE("SalomeApp_PyInterp::initPython - does nothing");
 }
 
 /*!
@@ -133,3 +77,9 @@ int SalomeApp_PyInterp::beforeRun()
   }
   return true;
 }
+
+void SalomeApp_PyInterp::closeContext()
+{
+    simpleRun( "import salome", false );
+    simpleRun( "salome.salome_close()", false );
+}
index dd918a15024a2437f200bd96ddfdfa5582d67356..95855f3a4107fcfb041c5693cfb8349ce921e298 100755 (executable)
@@ -36,9 +36,9 @@ public:
   virtual ~SalomeApp_PyInterp();
 
   virtual void initPython();
+  virtual void closeContext();
 
 protected:
-  virtual bool initContext();
   virtual int  beforeRun();
 
 private:
index 070cfef7dfdaf3a0590347fbf8385ce1370e3ab0..70bd944cbdf7458bfc2b35f49957c6cbf107c4e3 100644 (file)
@@ -41,6 +41,9 @@
 #include <SUIT_ResourceMgr.h>
 #include <SUIT_TreeModel.h>
 #include <SUIT_DataBrowser.h>
+#include <SUIT_MessageBox.h>
+#include <SUIT_Session.h>
+#include <SUIT_Desktop.h>
 
 #include <LightApp_Displayer.h>
 
@@ -458,7 +461,22 @@ bool SalomeApp_Study::createDocument( const QString& theStr )
 
   // initialize myStudyDS, read HDF file
   QString aName = newStudyName();
-  _PTR(Study) study ( SalomeApp_Application::studyMgr()->NewStudy( aName.toUtf8().data() ) );
+
+  _PTR(Study) study;
+  try {
+    study = _PTR(Study)( SalomeApp_Application::studyMgr()->NewStudy( aName.toUtf8().data() ) );
+  }
+  catch(const SALOME_Exception& ex) {
+    SUIT_MessageBox::critical( SUIT_Session::session()->activeApplication()->desktop(),
+                               tr("ERR_ERROR"), tr(ex.what()));
+    return false;
+  } 
+  catch(...) {
+    SUIT_MessageBox::critical( SUIT_Session::session()->activeApplication()->desktop(),
+                               tr("ERR_ERROR"), tr("CREATE_DOCUMENT_PROBLEM"));
+    return false;
+  }
+
   if ( !study )
     return false;
 
@@ -494,7 +512,21 @@ bool SalomeApp_Study::openDocument( const QString& theFileName )
   MESSAGE( "openDocument" );
 
   // initialize myStudyDS, read HDF file
-  _PTR(Study) study ( SalomeApp_Application::studyMgr()->Open( theFileName.toUtf8().data() ) );
+  _PTR(Study) study;
+  try {
+    study = _PTR(Study) ( SalomeApp_Application::studyMgr()->Open( theFileName.toUtf8().data() ) );
+  }
+  catch(const SALOME_Exception& ex) {
+    SUIT_MessageBox::critical( SUIT_Session::session()->activeApplication()->desktop(),
+                               tr("ERR_ERROR"), tr(ex.what()));
+    return false;
+  } 
+  catch(...) {
+    SUIT_MessageBox::critical( SUIT_Session::session()->activeApplication()->desktop(),
+                               tr("ERR_ERROR"), tr("OPEN_DOCUMENT_PROBLEM"));
+    return false;
+  }
+
   if ( !study )
     return false;
 
index 446b0292aed1487bc95989b8a9aaea9ef8f9802f..af08eef16692b0bf42dfe1cb6a040092c4d38cc8 100644 (file)
@@ -12,10 +12,26 @@ Python file must include only letters, digits and underscores and start from let
         <source>WRN_FILE_NOT_EXIST</source>
         <translation>The file %1 does not exist.</translation>
     </message>
+    <message>
+        <source>QUE_ACTIVEDOC_LOAD</source>
+        <translation>There is an active study in the session.
+Do you want to load it?
+</translation>
+    </message>
+    <message>
+        <source>STUDYCLOSE_DESCRIPTION</source>
+        <translation>You should close an existing study before.
+Do you want to close it?
+</translation>
+    </message>
     <message>
         <source>WRN_STUDY_LOCKED</source>
         <translation>Study is locked.</translation>
     </message>
+    <message>
+        <source>WRN_NO_STUDY_ON SERV</source>
+        <translation>No active study in this session.</translation>
+    </message>
     <message>
         <source>CLOSE_LOCKED_STUDY</source>
         <translation>Close locked study?</translation>
@@ -84,6 +100,24 @@ Python file must include only letters, digits and underscores and start from let
         <source>ERR_NO_VARIABLE</source>
         <translation>Variable with name &quot;%1&quot; doesn&apos;t exist</translation>
     </message>
+    <message>
+        <source>ERR_ACTIVE_STUDY_CREATE</source>
+        <translation>Cannot create study: there is already an active study in this session.
+Launch a new session or close the study.</translation>
+    </message>
+    <message>
+        <source>ERR_ACTIVE_STUDY_OPEN</source>
+        <translation>Cannot open study: there is already an active study in this session.
+Launch a new session or close the study.</translation>
+    </message>
+    <message>
+        <source>OPEN_DOCUMENT_PROBLEM</source>
+        <translation>Unknown problem during opening of the document</translation>
+    </message>
+    <message>
+        <source>CREATE_DOCUMENT_PROBLEM</source>
+        <translation>Unknown problem during creation of the document</translation>
+    </message>
 </context>
 <context>
     <name>SalomeApp_Application</name>
@@ -206,7 +240,7 @@ Do you want to reload it ?</translation>
     </message>
     <message>
         <source>APPCLOSE_DESCRIPTION</source>
-        <translation>Do you want to close or unload study before closing?</translation>
+        <translation>Do you want to save study before closing?</translation>
     </message>
     <message>
         <source>PRP_DESK_PROPERTIES</source>
index faf47a5790b3a14a9aab39bf6cf54eb56a56879f..345a295e0cf2070db2275f1d7affa982b2f1161e 100755 (executable)
@@ -14,7 +14,7 @@ Un fichier Python ne doit être composé que de lettres, chiffres et tirets bas
     </message>
     <message>
         <source>WRN_STUDY_LOCKED</source>
-        <translation type="unfinished">Study is locked.</translation>
+        <translation>L&apos;étude est verrouillée</translation>
     </message>
     <message>
         <source>CLOSE_LOCKED_STUDY</source>
@@ -84,6 +84,16 @@ Un fichier Python ne doit être composé que de lettres, chiffres et tirets bas
         <source>ERR_NO_VARIABLE</source>
         <translation>La variable &quot;%1&quot; n&apos;existe pas.</translation>
     </message>
+    <message>
+        <source>ERR_ACTIVE_STUDY_CREATE</source>
+        <translation>Impossible de créer une étude car il y en a déjà une d&apos;active.
+Lancez une nouvelle session ou fermez l&apos;étude en cours.</translation>
+    </message>
+    <message>
+        <source>ERR_ACTIVE_STUDY_OPEN</source>
+        <translation>Impossible d&apos;ouvrir l&apos;étude car il y en a déjà une d&apos;active.
+Lancez une nouvelle session ou fermez l&apos;étude en cours.</translation>
+    </message>
 </context>
 <context>
     <name>SalomeApp_Application</name>
@@ -361,16 +371,16 @@ Voulez-vous le recharger ?</translation>
         <translation>Check In</translation>
     </message>
     <message>
-      <source>TOT_SIMAN_LOCAL_CHECK_IN</source>
-      <translation>Check In pour la module</translation>
+        <source>TOT_SIMAN_LOCAL_CHECK_IN</source>
+        <translation>Check In pour la module</translation>
     </message>
     <message>
-      <source>MEN_SIMAN_LOCAL_CHECK_IN</source>
-      <translation>Check In pour la module</translation>
+        <source>MEN_SIMAN_LOCAL_CHECK_IN</source>
+        <translation>Check In pour la module</translation>
     </message>
     <message>
-      <source>PRP_SIMAN_LOCAL_CHECK_IN</source>
-      <translation>Check In pour la module"</translation>
+        <source>PRP_SIMAN_LOCAL_CHECK_IN</source>
+        <translation>Check In pour la module&quot;</translation>
     </message>
 </context>
 <context>
index 819d6272d4d592e5c07b2c4c733d770acf6ac86f..4c0b3b96470f22c2803ecc40d65d337dfac6d151 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!DOCTYPE TS>
-<TS>
+<TS version="2.0" language="ja" sourcelanguage="en">
   <context>
     <name>@default</name>
     <message>
       <translation>ファイル %1 は存在しません。</translation>
     </message>
     <message>
-        <source>WRN_STUDY_LOCKED</source>
-        <translation type="unfinished">Study is locked.</translation>
+      <source>QUE_ACTIVEDOC_LOAD</source>
+      <translation>セッションにスタディがあります。読み込みますか?</translation>
+    </message>
+    <message>
+      <source>STUDYCLOSE_DESCRIPTION</source>
+      <translation>既存のスタディを閉じる必要があります。閉じますか?
+</translation>
+    </message>
+    <message>
+      <source>WRN_STUDY_LOCKED</source>
+      <translation>スタディがロックされています</translation>
+    </message>
+    <message>
+      <source>WRN_NO_STUDY_ON SERV</source>
+      <translation>セッションにスタディがありません。</translation>
     </message>
     <message>
       <source>CLOSE_LOCKED_STUDY</source>
       <source>ERR_NO_VARIABLE</source>
       <translation>変数"%1"は存在しません。</translation>
     </message>
-  </context>
-  <context>
-    <name>SalomeApp_Application</name>
-    <message>
-        <source>PRP_SIMAN_LOCAL_CHECK_IN</source>
-        <translation type="unfinished">Check In for module</translation>
-    </message>
     <message>
-        <source>MEN_SIMAN_LOCAL_CHECK_IN</source>
-        <translation type="unfinished">Check In for module</translation>
+      <source>ERR_ACTIVE_STUDY_CREATE</source>
+      <translation>スタディを作成できません: セッションに既にスタディがあります。
+新規セッションを開始するかスタディを閉じてください。</translation>
     </message>
     <message>
-        <source>TOT_SIMAN_LOCAL_CHECK_IN</source>
-        <translation type="unfinished">Check In for module</translation>
+      <source>ERR_ACTIVE_STUDY_OPEN</source>
+      <translation>スタディを開けません: セッションに既にスタディがあります。
+新規セッションを開始するかスタディを閉じてください。</translation>
     </message>
     <message>
-        <source>PRP_SIMAN_CHECK_IN</source>
-        <translation type="unfinished">Check In</translation>
+      <source>OPEN_DOCUMENT_PROBLEM</source>
+      <translation>ドキュメントオープン中に不明な問題が発生しました</translation>
     </message>
     <message>
-        <source>MEN_SIMAN_CHECK_IN</source>
-        <translation type="unfinished">Check In</translation>
-    </message>
-    <message>
-        <source>TOT_SIMAN_CHECK_IN</source>
-        <translation type="unfinished">Check In</translation>
+      <source>CREATE_DOCUMENT_PROBLEM</source>
+      <translation>ドキュメント作成中に不明な問題が発生しました</translation>
     </message>
+  </context>
+  <context>
+    <name>SalomeApp_Application</name>
     <message>
       <source>ALL_FILES_FILTER</source>
       <translation>すべてのファイル (*. *)</translation>
       <source>ACTIVATE_MODULE_OP_SCRIPT</source>
       <translation>スクリプト読込み(&amp;S)</translation>
     </message>
+    <message>
+      <source>TOT_SIMAN_CHECK_IN</source>
+      <translation>チェックイン</translation>
+    </message>
+    <message>
+      <source>MEN_SIMAN_CHECK_IN</source>
+      <translation>チェックイン</translation>
+    </message>
+    <message>
+      <source>PRP_SIMAN_CHECK_IN</source>
+      <translation>チェックイン</translation>
+    </message>
+    <message>
+      <source>TOT_SIMAN_LOCAL_CHECK_IN</source>
+      <translation>モジュールにチェックイン</translation>
+    </message>
+    <message>
+      <source>MEN_SIMAN_LOCAL_CHECK_IN</source>
+      <translation>モジュールにチェックイン</translation>
+    </message>
+    <message>
+      <source>PRP_SIMAN_LOCAL_CHECK_IN</source>
+      <translation>モジュールにチェックイン</translation>
+    </message>
   </context>
   <context>
     <name>SalomeApp_StudyPropertiesDlg</name>
index 8d06a449912dc1c120163783197a38cc7c10e862..42770dbfca724eb6ff84b328ac8365236e603a45 100755 (executable)
@@ -94,8 +94,6 @@
  * - get session state
  */
 
-PyObject* salome_shared_modules_module = 0;
-
 void MessageOutput( QtMsgType type, const char* msg )
 {
   switch ( type )
@@ -112,29 +110,6 @@ void MessageOutput( QtMsgType type, const char* msg )
   }
 }
 
-/* XPM */
-static const char* pixmap_not_found_xpm[] = {
-"16 16 3 1",
-"       c None",
-".      c #000000",
-"+      c #A80000",
-"                ",
-"                ",
-"    .     .     ",
-"   .+.   .+.    ",
-"  .+++. .+++.   ",
-"   .+++.+++.    ",
-"    .+++++.     ",
-"     .+++.      ",
-"    .+++++.     ",
-"   .+++.+++.    ",
-"  .+++. .+++.   ",
-"   .+.   .+.    ",
-"    .     .     ",
-"                ",
-"                ",
-"                "};
-
 QString salomeVersion()
 {
   return GUI_VERSION_STR;
@@ -147,7 +122,6 @@ public:
   {
     setCurrentFormat( "xml" );
     setOption( "translators", QString( "%P_msg_%L.qm|%P_icons.qm|%P_images.qm" ) );
-    setDefaultPixmap( QPixmap( pixmap_not_found_xpm ) );
   }
   static void initResourceMgr()
   {
@@ -234,32 +208,32 @@ protected:
       
       QString fname = QFileInfo( _fname ).fileName();
       if( exp.exactMatch( fname ) ) {
-        QStringList vers = exp.cap( 1 ).split( ".", QString::SkipEmptyParts );
-        int major=0, minor=0;
-        int release = 0, dev1 = 0, dev2 = 0;
-       if ( vers.count() > 0 ) major = vers[0].toInt();
-       if ( vers.count() > 1 ) minor = vers[1].toInt();
-       if ( vers.count() > 2 ) {
-         if ( vers_exp.indexIn( vers[2] ) != -1 ) {
-           release = vers_exp.cap( 1 ).toInt();
-           QString tag = vers_exp.cap( 2 ).toLower();
-           if ( !tag.isEmpty() ) {
-             if ( tag == "rc" ) // release candidate
-               dev1 = 49;       // 'rc'=49
-             else               // a, b, c, ... 
-               dev1 = (int)( tag[ 0 ].toLatin1() ) - (int)( QChar('a').toLatin1() ) + 1; // 'a'=1, 'b'=2, ..., 'z'=26
-           }
-           if ( !vers_exp.cap( 3 ).isEmpty() )
-             dev2 = vers_exp.cap( 3 ).toInt();
-         }
-       }
-        
-        int dev = dev1*100+dev2;
-       id = major;
-        id*=100; id+=minor;
-        id*=100; id+=release;
-        id*=10000;
-        if ( dev > 0 ) id-=dev;
+          QStringList vers = exp.cap( 1 ).split( ".", QString::SkipEmptyParts );
+          int major=0, minor=0;
+          int release = 0, dev1 = 0, dev2 = 0;
+          if ( vers.count() > 0 ) major = vers[0].toInt();
+          if ( vers.count() > 1 ) minor = vers[1].toInt();
+          if ( vers.count() > 2 ) {
+              if ( vers_exp.indexIn( vers[2] ) != -1 ) {
+                  release = vers_exp.cap( 1 ).toInt();
+                  QString tag = vers_exp.cap( 2 ).toLower();
+                  if ( !tag.isEmpty() ) {
+                      if ( tag == "rc" ) // release candidate
+                        dev1 = 49;       // 'rc'=49
+                      else               // a, b, c, ...
+                        dev1 = (int)( tag[ 0 ].toLatin1() ) - (int)( QChar('a').toLatin1() ) + 1; // 'a'=1, 'b'=2, ..., 'z'=26
+                  }
+                  if ( !vers_exp.cap( 3 ).isEmpty() )
+                    dev2 = vers_exp.cap( 3 ).toInt();
+              }
+          }
+
+          int dev = dev1*100+dev2;
+          id = major;
+          id*=100; id+=minor;
+          id*=100; id+=release;
+          id*=10000;
+          if ( dev > 0 ) id-=dev;
       }
     }
     return id;
@@ -279,7 +253,7 @@ public:
   SALOME_Session() : SUIT_Session() {}
   virtual ~SALOME_Session() {}
 
-protected:
+public:
   virtual SUIT_ResourceMgr* createResourceMgr( const QString& appName ) const
   {
     SALOME_ResourceMgr::initResourceMgr();
@@ -416,6 +390,19 @@ int main( int argc, char **argv )
   if ( !qtdir.isEmpty() )
     QApplication::addLibraryPath( QDir( qtdir ).absoluteFilePath( "plugins" ) );
 
+  {
+    SALOME_Session s;
+    QApplication::setApplicationName( "salome" );
+    SUIT_ResourceMgr* resMgr = s.createResourceMgr( "SalomeApp" );
+    bool isCloc = resMgr->booleanValue( "language", "locale", true );
+    if ( isCloc ) { 
+      QLocale::setDefault( QLocale::c() );
+    }
+    else {
+      QLocale::setDefault( QLocale::system() );
+    }
+  }
+
   // Create Qt application instance;
   // this should be done the very first!
   SALOME_QApplication _qappl( argc, argv );
@@ -475,14 +462,6 @@ int main( int argc, char **argv )
     int   _argc   = 1;
     char* _argv[] = {(char*)""};
     KERNEL_PYTHON::init_python( _argc,_argv );
-    PyEval_RestoreThread( KERNEL_PYTHON::_gtstate );
-    if ( !KERNEL_PYTHON::salome_shared_modules_module ) // import only once
-      KERNEL_PYTHON::salome_shared_modules_module = PyImport_ImportModule( "salome_shared_modules" );
-    if ( !KERNEL_PYTHON::salome_shared_modules_module ) {
-      INFOS( "salome_shared_modules_module == NULL" );
-      PyErr_Print();
-    }
-    PyEval_ReleaseThread( KERNEL_PYTHON::_gtstate );
 
     // ...create ORB, get RootPOA object, NamingService, etc.
     ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance();
@@ -631,28 +610,28 @@ int main( int argc, char **argv )
 
         if ( splash )
           splash->finish( aGUIApp->desktop() );
-       
+
         result = _qappl.exec();
         
         splash = 0;
-       
+
         if ( result == SUIT_Session::NORMAL ) {
-         // desktop is explicitly closed by user from GUI
-         // exit flags says if it's necessary to shutdown all servers
-         // all session server only
+        // desktop is explicitly closed by user from GUI
+        // exit flags says if it's necessary to shutdown all servers
+        // all session server only
           shutdownAll = aGUISession->exitFlags();
-       }
-       else {
-         // desktop might be closed from:
-         // - StopSesion() /temporarily/ or
-         // - Shutdown() /permanently/
-         stat = session->GetStatSession();
-         shutdownSession = stat.state == SALOME::shutdown;
-       }
-       if ( shutdownAll || shutdownSession ) {
-         _SessionMutex.lock(); // lock mutex before leaving loop - it will be unlocked later
-         break;
-       }
+        }
+        else {
+          // desktop might be closed from:
+          // - StopSesion() /temporarily/ or
+          // - Shutdown() /permanently/
+          stat = session->GetStatSession();
+          shutdownSession = stat.state == SALOME::shutdown;
+        }
+        if ( shutdownAll || shutdownSession ) {
+          _SessionMutex.lock(); // lock mutex before leaving loop - it will be unlocked later
+          break;
+        }
       }
 
       delete aGUISession;
index 2d08692cc029be7bad8666264b77d2e4e1b2f7ec..aa688aab9dce552a3495a5a92db2dddef62f9c75 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!DOCTYPE TS>
-<TS>
+<TS version="2.0" language="ja" sourcelanguage="en">
   <context>
     <name>@default</name>
     <message>
index 84277f7c3c46c3ce9cd460db0badbd0ad82d1aca..af17027b7b4c7771dbf834b5993954e78f8073c9 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!DOCTYPE TS>
-<TS>
+<TS version="2.0" language="ja" sourcelanguage="en">
   <context>
     <name>@default</name>
     <message>
index 5512ffbf83b67f306e8712e5dd348814b7ca8824..a458936a4c98ae436c0c48e29b0622db003e9b9c 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!DOCTYPE TS>
-<TS>
+<TS version="2.0" language="ja" sourcelanguage="en">
   <context>
     <name>ViewerTools_CubeAxesDlgBase</name>
     <message>