Salome HOME
0022077: EDF 2272 : Selection with the Paraview interaction mode in GEOM/SMESH
authormpa <mpa@opencascade.com>
Wed, 19 Jun 2013 14:30:51 +0000 (14:30 +0000)
committermpa <mpa@opencascade.com>
Wed, 19 Jun 2013 14:30:51 +0000 (14:30 +0000)
0021950: EDF 2311 SMESH : Polyline selection in SMESH

48 files changed:
doc/salome/gui/images/occ_view_sync.png [new file with mode: 0644]
doc/salome/gui/images/poly_selection1.png [new file with mode: 0644]
doc/salome/gui/images/poly_selection2.png [new file with mode: 0644]
doc/salome/gui/images/polyselection1.png [deleted file]
doc/salome/gui/images/polyselection2.png [deleted file]
doc/salome/gui/images/pref_salome_3dviewer.png [new file with mode: 0644]
doc/salome/gui/images/pref_salome_directories.png
doc/salome/gui/images/pref_salome_general.png
doc/salome/gui/images/pref_salome_objbrowser.png
doc/salome/gui/images/pref_salome_occviewer.png
doc/salome/gui/images/pref_salome_plot2dviewer.png
doc/salome/gui/images/pref_salome_shortcuts.png
doc/salome/gui/images/pref_salome_vtkviewer.png
doc/salome/gui/images/rect_selection1.png [new file with mode: 0644]
doc/salome/gui/images/rect_selection2.png [new file with mode: 0644]
doc/salome/gui/images/vtk_view_sync.png [new file with mode: 0644]
doc/salome/gui/input/common_functionality.doc [new file with mode: 0644]
doc/salome/gui/input/occ_3d_viewer.doc
doc/salome/gui/input/setting_preferences.doc
doc/salome/gui/input/viewers_chapter.doc
doc/salome/gui/input/vtk_3d_viewer.doc
src/LightApp/LightApp_Application.cxx
src/LightApp/resources/LightApp_msg_en.ts
src/LightApp/resources/LightApp_msg_fr.ts
src/OCCViewer/OCCViewer_ViewModel.cxx
src/OCCViewer/OCCViewer_ViewSketcher.cxx
src/OCCViewer/OCCViewer_ViewSketcher.h
src/OCCViewer/OCCViewer_ViewWindow.cxx
src/OCCViewer/OCCViewer_ViewWindow.h
src/SUIT/SUIT_ViewModel.cxx
src/SVTK/CMakeLists.txt
src/SVTK/Makefile.am
src/SVTK/SALOME_Actor.cxx
src/SVTK/SALOME_Actor.h
src/SVTK/SVTK.cxx
src/SVTK/SVTK_AreaPicker.cxx [new file with mode: 0644]
src/SVTK/SVTK_AreaPicker.h [new file with mode: 0644]
src/SVTK/SVTK_InteractorStyle.cxx
src/SVTK/SVTK_InteractorStyle.h
src/SVTK/SVTK_KeyFreeInteractorStyle.cxx
src/SVTK/SVTK_KeyFreeInteractorStyle.h
src/SVTK/SVTK_RectPicker.cxx [deleted file]
src/SVTK/SVTK_RectPicker.h [deleted file]
src/SVTK/SVTK_RenderWindowInteractor.cxx
src/SVTK/SVTK_Renderer.cxx
src/SVTK/SVTK_Renderer.h
src/SVTK/SVTK_SelectionEvent.h
src/VTKViewer/VTKViewer_InteractorStyle.cxx

diff --git a/doc/salome/gui/images/occ_view_sync.png b/doc/salome/gui/images/occ_view_sync.png
new file mode 100644 (file)
index 0000000..51ad5b3
Binary files /dev/null and b/doc/salome/gui/images/occ_view_sync.png differ
diff --git a/doc/salome/gui/images/poly_selection1.png b/doc/salome/gui/images/poly_selection1.png
new file mode 100644 (file)
index 0000000..f960124
Binary files /dev/null and b/doc/salome/gui/images/poly_selection1.png differ
diff --git a/doc/salome/gui/images/poly_selection2.png b/doc/salome/gui/images/poly_selection2.png
new file mode 100644 (file)
index 0000000..7848a50
Binary files /dev/null and b/doc/salome/gui/images/poly_selection2.png differ
diff --git a/doc/salome/gui/images/polyselection1.png b/doc/salome/gui/images/polyselection1.png
deleted file mode 100755 (executable)
index 1920e97..0000000
Binary files a/doc/salome/gui/images/polyselection1.png and /dev/null differ
diff --git a/doc/salome/gui/images/polyselection2.png b/doc/salome/gui/images/polyselection2.png
deleted file mode 100755 (executable)
index 8467a4d..0000000
Binary files a/doc/salome/gui/images/polyselection2.png and /dev/null differ
diff --git a/doc/salome/gui/images/pref_salome_3dviewer.png b/doc/salome/gui/images/pref_salome_3dviewer.png
new file mode 100644 (file)
index 0000000..235b564
Binary files /dev/null and b/doc/salome/gui/images/pref_salome_3dviewer.png differ
index c47b4578827d500f109f5e4be6a992801a442649..a05653fb824ab0b098927ce9aa0560e95f6bed56 100644 (file)
Binary files a/doc/salome/gui/images/pref_salome_directories.png and b/doc/salome/gui/images/pref_salome_directories.png differ
index db05ca064a9c87eee0a7ab52ba0b9e7d11a06f03..5beafe26469134dae50b9ac8be72d8940c7c5e0d 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 9242935e8f27af06e169e8e1aa464ffe82accefd..8299d88bb86893ada3d98ba6daac22ed68a7c561 100644 (file)
Binary files a/doc/salome/gui/images/pref_salome_objbrowser.png and b/doc/salome/gui/images/pref_salome_objbrowser.png differ
index 953d07211d5d13f551845ab5aee5586292e2f05b..00bf8a743194bde366c40cc59d606d01511f774a 100644 (file)
Binary files a/doc/salome/gui/images/pref_salome_occviewer.png and b/doc/salome/gui/images/pref_salome_occviewer.png differ
index f427aee9d259f95a88e5c32d0c7861b8c695f6df..339dbf95012b70579fe3293b43f7af6bfdf58641 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 5f4c19454fcc287020f5c7559575c296b78222f5..76c30e61789b00a5fae5c9a6c5f769dbf7970e70 100644 (file)
Binary files a/doc/salome/gui/images/pref_salome_shortcuts.png and b/doc/salome/gui/images/pref_salome_shortcuts.png differ
index 29ac576dd422a14c60e0540873b479fe1abe3669..071457d0c6414d70c64230ee374818755953068e 100644 (file)
Binary files a/doc/salome/gui/images/pref_salome_vtkviewer.png and b/doc/salome/gui/images/pref_salome_vtkviewer.png differ
diff --git a/doc/salome/gui/images/rect_selection1.png b/doc/salome/gui/images/rect_selection1.png
new file mode 100644 (file)
index 0000000..ef3fea4
Binary files /dev/null and b/doc/salome/gui/images/rect_selection1.png differ
diff --git a/doc/salome/gui/images/rect_selection2.png b/doc/salome/gui/images/rect_selection2.png
new file mode 100644 (file)
index 0000000..6fc042a
Binary files /dev/null and b/doc/salome/gui/images/rect_selection2.png differ
diff --git a/doc/salome/gui/images/vtk_view_sync.png b/doc/salome/gui/images/vtk_view_sync.png
new file mode 100644 (file)
index 0000000..51ad5b3
Binary files /dev/null and b/doc/salome/gui/images/vtk_view_sync.png differ
diff --git a/doc/salome/gui/input/common_functionality.doc b/doc/salome/gui/input/common_functionality.doc
new file mode 100644 (file)
index 0000000..7e4e2d7
--- /dev/null
@@ -0,0 +1,130 @@
+/*!
+
+\page common_functionality_page Common functionality
+
+\anchor viewer_background
+<h2>Background</h2>
+
+Viewers background can be customized using the "Change background"
+popup menu command that opens the following dialog box:
+
+\image html change_background_dlg.png
+
+The following types of the background are supported:
+
+- Single color: the background is colored with the solid color
+  specified by the user in the dialog box.
+
+- Gradient background: the background is gradiently colored according
+  to two colors and the gradient type specified in the dialog box. The
+  following types of background are supported:
+
+  - Horizontal
+
+  - Vertical
+
+  - First diagonal
+
+  - Second diagonal
+
+  - First corner
+
+  - Second corner
+
+  - Third corner
+
+  - Fourth corner
+
+- Image: allows to set image as viewer background and define filling type:
+
+  - Center: the image is located at the center of the viewer backgound
+
+  - Tile: the image fills the entire viewer backgound one by one
+
+  - Stretch: the image is stretched to the entire viewer backgound.
+
+Default background for the OCC viewer is specified via the
+\ref occ_preferences "OCC 3D Viewer Preferences" and for the
+VTK viewer via the \ref vtk_preferences "VTK 3D Viewer Preferences".
+
+<hr>
+
+<h2>Selection</h2>
+
+For selecting it is necessary to click by left mouse button on the required 
+element. Thus, this element will be selected.
+
+Also, holding down the <b>Shift</b> key while selecting objects will 
+produce multi selection. 
+
+In the viewers there are two mechanism for selecting: rectangle and 
+polyline selection.
+
+<h3>Rectangle selection</h3>
+
+The Rectangle Selection tool is designed to select rectangular regions: 
+it is the most basic of the selection tools and very commonly used.
+For selecting area by rectangle press left mouse button and draw it on 
+the viewer holding down the left mouse button.
+
+To add an area to the existing selection it is necessary to hold down 
+<b>Shift</b> key while selecting.
+
+\image html rectselectionvtk.png
+As a result, only a rectangle is selected.
+\image html rectselectionvtk2.png
+
+<h3>Polyline selection</h3>
+
+OCC and VTK Viewers features a special Polyline Selection mechanism,
+which allows selecting an arbitraty part of the graphic area using a
+polygon frame (rubber band), instead of the usual selection with a
+rectangular frame.
+
+To produce a Polyline Selection, lock the right mouse button and draw
+the first side of the polygon, then change the direction by clicking
+the left mouse button add draw another side, etc. The whole selection
+frame is drawn with the locked right mouse button.
+
+To add an area to the existing selection it is necessary to hold down 
+<b>Shift</b> key while selecting.
+
+\image html polyselectionvtk11.png
+As a result, only the faces within the frame are selected.
+\image html polyselectionvtk21.png
+
+<hr>
+
+\anchor viewer_navigation_modes
+<h2>Navigation modes</h2>
+
+OCC and VTK 3D viewers support two different navigation modes:
+
+- <b>Salome standard controls</b>
+
+  Rectangle selection in this mode is performed by left mouse button, 
+  polyline selection is done by right mouse button;
+  multiple selection is available when \b Shift button is pressed.
+
+  Also, holding \b Ctrl key pressed in conjunction with 
+  mouse buttons performs view transformations:
+  - \b Ctrl + left mouse button - zooming;
+  - \b Ctrl + middle mouse button - panning;
+  - \b Ctrl + right mouse button - rotation.
+
+- <b>Keyboard free style</b>
+
+  This mode allows to process all view transformations without using
+  keyboard (only by mouse):
+  - \b Left mouse button performs view rotation;
+  - \b Middle mouse button performs panning; 
+  - \b Right mouse button makes zooming.
+  .
+  
+  In this style selection of objects in view is performed by pressing
+  "S" key or by left mouse button click. Rectangle selection is done
+  by left mouse button when holding \b Ctrl key; polyline selection
+  is done by right mouse button with \b Ctrl key pressed.
+
+*/
index e59aafe3febe6011f985e247cf1be91e616d9ce6..e27d346d36225a3f09413236ebb46e0926103f9d 100644 (file)
@@ -20,13 +20,9 @@ jpeg image format.
 
 \image html occ_view_style_switch.png
 
-<b>Interaction style switch</b> - allows to switch between standard
-and "keyboard free" interaction styles. "Keyboard free" style allows
-to process all view transformations without using keyboard (only by
-mouse) and perform selection in view by pressing "S" key. By default,
-rotation in this mode is performed by left mouse button, panning - by
-middle mouse button, zooming - by left and middle mouse buttons
-pressed simultaneously.
+<b>Interaction style switch</b> - allows to switch between "Salome 
+standard controls" and "Keyboard free" \ref viewer_navigation_modes "interaction styles". 
+
 <hr>
 
 \image html occ_view_zooming_style_switch.png
@@ -230,68 +226,5 @@ In addition, when this button is in the "checked" state, the dynamic
 synchronization of the views is performed, i.e. any zoom, pan, rotate
 or other view operation done in one view is automatically applied to
 the other view.
-<hr>
-
-\anchor occ_background
-<h2>Background</h2>
-
-OCC Viewer background can be customized using the "Change background"
-popup menu command that opens the following dialog box:
-
-\image html change_background_dlg.png
-
-The following types of the background are supported:
-
-- Single color: the background is colored with the solid color
-  specified by the user in the dialog box.
-
-- Gradient background: the background is gradiently colored according
-  to two colors and the gradient type specified in the dialog box. The
-  following types of background are supported:
-
-  - Horizontal
-
-  - Vertical
-
-  - First diagonal
-
-  - Second diagonal
-
-  - First corner
-
-  - Second corner
-
-  - Third corner
-
-  - Fourth corner
-
-- Image: allows to set image as viewer background and define filling type:
-
-  - Center: the image is located at the center of the viewer backgound
-
-  - Tile: the image fills the entire viewer backgound one by one
-
-  - Stretch: the image is stretched to the entire viewer backgound.
-
-Default background for the viewer is specified via the
-\ref occ_preferences "application preferences".
-
-<h2>Polyline selection</h2>
-
-OCC Viewer features a special <b>Polyline Selection</b> mechanism,
-which allows selecting an arbitraty part of the graphic area using a
-polygon frame (rubber band), instead of the usual selection with a
-rectangular frame.
-
-To produce a Polyline Selection, lock the right mouse button and draw
-the first side of the polygon, then change the direction by clicking
-the left mouse button add draw another side, etc. The whole selection
-frame is drawn with the locked right mouse button.
-   
-\image html polyselection1.png
-
-As a result, only the nodes within the frame are selected.
-
-\image html polyselection2.png
 
 */
index c85fc8e29818a22d39aa5822b8933e1b4f749ed3..546b5ee6dc58381e095615e872c57ca35fda0f8e 100644 (file)
@@ -93,29 +93,10 @@ items in <b>Most Recently Used</b> list and the <b>Link type</b>:
   - \b Auto - shows full paths to the files only if some files from
 different locations have the same name.
 
-\anchor occ_preferences
-<h2>OCC 3D Viewer Preferences</h2>
+<h2>3D Viewer Preferences</h2>
 
-\image html pref_salome_occviewer.png
+\image html pref_salome_3dviewer.png
 
-- <b>Trihedron</b> - viewer trihedron settings:
-  - <b>Size</b> - size of the coordinate axes (global trihedron)
-    displayed in the viewer.
-  - <b>Relative size</b> - if this option is switched on, trihedron
-    axes scale to fit the size of the scene displayed in 3D viewer.
-  - <b>Show static trihedron</b> - allows to show/hide the static
-    mini-trihedron located in the bottom-left corner of the viewer.
-- <b>Number of isolines</b> - this submenu allows to specify the
-  number of isolines along the axes of coordinates:
-  - <b>Along U</b> and
-  - <b>Along V</b>
-- <b>Background</b> - specifies the default background for the viewers,
-  separately for (for more details, refer to the \ref occ_background
-  "this page"):
-  - <b>3D View</b>
-  - <b>XZ View</b>
-  - <b>YZ View</b>
-  - <b>XY View</b>
 - <b>Navigation style</b> - this option allows to choose one of the
   modes of work with mouse in OCC and VTK 3D viewers.
   - <b>Salome Standard Controls</b> - allows to manipulate objects in the
@@ -133,6 +114,26 @@ different locations have the same name.
   relatively to its center.
   - <b>Relative to the cursor</b> - allows to zoom the view
   relatively to the current cursor position.
+- <b>Trihedron</b> - viewer trihedron settings:
+  - <b>Size</b> - size of the coordinate axes (global trihedron)
+    displayed in the viewer.
+  - <b>Relative size</b> - if this option is switched on, trihedron
+    axes scale to fit the size of the scene displayed in 3D viewer.
+  - <b>Show static trihedron</b> - allows to show/hide the static
+    mini-trihedron located in the bottom-left corner of the viewer.
+
+\anchor occ_preferences
+<h2>OCC 3D Viewer Preferences</h2>
+
+\image html pref_salome_occviewer.png
+
+- <b>Background</b> - specifies the default background for the viewers,
+  separately for (for more details, refer to the \ref viewer_background
+  "this page"):
+  - <b>3D View</b>
+  - <b>XZ View</b>
+  - <b>YZ View</b>
+  - <b>XY View</b>
 
 \anchor vtk_preferences
 <h2>VTK 3D Viewer Preferences</h2>
@@ -142,24 +143,13 @@ different locations have the same name.
 - <b>Projection mode</b> - allows choosing between \b Orthogonal and
 \b Perspective projection mode.
 - <b>Background</b> - specifies the default background for the viewer;
-  for more details, refer to the \ref vtk_background "this page".
-- <b>Navigation style</b> - this option allows to choose one of the
-  modes of work with mouse in OCC and VTK 3D viewers (for more details
-  see \ref occ_preferences "preferences for OCC Viewer 3d").
-- <b>Zooming style</b> - this option allows to choose a zooming mode
-  (for more details see \ref occ_preferences "preferences for OCC Viewer 3d").
+  for more details, refer to the \ref viewer_background "this page".
 - <b>Speed Increment</b> - defines the number of units by
   which the speed increases or respectively decreases after pressing [+]
   or [-] keyboard buttons.
 - <b>Modification Mode</b> - allows choosing between \b Arithmetic
   and \b Geometrical progression used for zooming.
 - <b>Dynamic pre-selection</b> - switches dynamic pre-selection on/off.
-- <b>Trihedron</b> - viewer trihedron settings:
-  - <b>Size</b> - size of the coordinate axes displayed in the viewer.
-  - <b>Relative size</b> - if this option is switched on, trihedron
-    axes scale to fit the size of the scene displayed in 3D viewer.
-  - <b>Show static trihedron</b> - allows to show/hide the static
-    mini-trihedron located in the bottom-left corner of the viewer.
 - <b>Spacemouse</b> - a mouse-like manipulator device specially designed
   for working with 3D presentations, objects, etc. You can reassign the
   actions listed below to any of its buttons.
index b3a3b92de94417153ee0aab44a31e1217f5fbe2c..fd493caab85437388adc40716445d3f8f262d280 100644 (file)
@@ -31,4 +31,6 @@ directly, but can be used in custom modules for 2D visualization purposes.
 developed on the basis of Qt QGraphicsView scene. This viewer is used
 in SALOME YACS module for visualization of computation schemes.
 
+- \subpage common_functionality_page used in OCC and VTK 3d viewers.
+
 */
index 529bf3a39983379e921a7371ccb0fed7e59d3de4..1774bf1f5173cd6b7ea32ead5ea1499b51781a1e 100644 (file)
@@ -20,13 +20,9 @@ jpeg image format.
 
 \image html vtk_view_style_switch.png
 
-<b>Interaction style switch</b> - allows to switch between standard
-and "keyboard free" interaction styles. "Keyboard free" style allows
-to process all view transformations without using keyboard (only by
-mouse) and perform selection in view by pressing "S" key. By default,
-rotation in this mode is performed by left mouse button, panning - by
-middle mouse button, zooming - by left and middle mouse buttons
-pressed simultaneously.
+<b>Interaction style switch</b> - allows to switch between "Salome 
+standard controls" and "Keyboard free" \ref viewer_navigation_modes "interaction styles". 
+
 <hr>
 
 \image html vtk_view_zooming_style_switch.png
@@ -283,51 +279,4 @@ the AVI format using external software (jpeg2yuv):
 
 - <b>Stop recording</b> - stop recording.
 
-<hr>
-
-\anchor vtk_background
-<h2>Background</h2>
-
-VTK Viewer background can be customized using the "Change background"
-popup menu command that opens the following dialog box:
-
-\image html change_background_dlg.png
-
-The following types of the background are supported:
-
-- Single color: the background is colored with the solid color
-  specified by the user in the dialog box.
-
-- Gradient background: the background is gradiently colored according
-  to two colors and the gradient type specified in the dialog
-  box. The following types of background are supported:
-
-  - Horizontal
-
-  - Vertical
-
-  - First diagonal
-
-  - Second diagonal
-
-  - First corner
-
-  - Second corner
-
-  - Third corner
-
-  - Fourth corner
-
-- Image: allows to set image as viewer background and define filling type:
-
-  - Center: the image is located at the center of the viewer backgound
-
-  - Tile: the image fills the entire viewer backgound one by one
-
-  - Stretch: the image is stretched to the entire viewer backgound.
-
-
-Default background for the viewer is specified via the
-\ref vtk_preferences "application preferences".
-
 */
index 8dd648f27aa78e305caa0e07ca06acdecb3d2d1f..889c6f2f3e3555f7fb159fde17407db0cae00609 100644 (file)
@@ -1443,10 +1443,10 @@ SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType
     vm->setBackground( OCCViewer_ViewFrame::BOTTOM_RIGHT,
                        resMgr->backgroundValue( "OCCViewer", "background", vm->background(OCCViewer_ViewFrame::MAIN_VIEW) ) );
 
-    vm->setTrihedronSize(  resMgr->doubleValue( "OCCViewer", "trihedron_size", vm->trihedronSize() ),
-                           resMgr->booleanValue( "OCCViewer", "relative_size", vm->trihedronRelative() ));
-    vm->setInteractionStyle( resMgr->integerValue( "OCCViewer", "navigation_mode", vm->interactionStyle() ) );
-    vm->setZoomingStyle( resMgr->integerValue( "OCCViewer", "zooming_mode", vm->zoomingStyle() ) );
+    vm->setTrihedronSize(  resMgr->doubleValue( "3DViewer", "trihedron_size", vm->trihedronSize() ),
+                           resMgr->booleanValue( "3DViewer", "relative_size", vm->trihedronRelative() ));
+    vm->setInteractionStyle( resMgr->integerValue( "3DViewer", "navigation_mode", vm->interactionStyle() ) );
+    vm->setZoomingStyle( resMgr->integerValue( "3DViewer", "zooming_mode", vm->zoomingStyle() ) );
     viewMgr->setViewModel( vm );// custom view model, which extends SALOME_View interface
     new LightApp_OCCSelector( (OCCViewer_Viewer*)viewMgr->getViewModel(), mySelMgr );
   }
@@ -1465,11 +1465,11 @@ SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType
     {
       vm->setProjectionMode( resMgr->integerValue( "VTKViewer", "projection_mode", vm->projectionMode() ) );
       vm->setBackground( resMgr->backgroundValue( "VTKViewer", "background", vm->background() ) );
-      vm->setTrihedronSize( resMgr->doubleValue( "VTKViewer", "trihedron_size", vm->trihedronSize() ),
-                            resMgr->booleanValue( "VTKViewer", "relative_size", vm->trihedronRelative() ) );
-      vm->setStaticTrihedronVisible( resMgr->booleanValue( "VTKViewer", "show_static_trihedron", vm->isStaticTrihedronVisible() ) );
-      vm->setInteractionStyle( resMgr->integerValue( "VTKViewer", "navigation_mode", vm->interactionStyle() ) );
-      vm->setZoomingStyle( resMgr->integerValue( "VTKViewer", "zooming_mode", vm->zoomingStyle() ) );
+      vm->setTrihedronSize( resMgr->doubleValue( "3DViewer", "trihedron_size", vm->trihedronSize() ),
+                            resMgr->booleanValue( "3DViewer", "relative_size", vm->trihedronRelative() ) );
+      vm->setStaticTrihedronVisible( resMgr->booleanValue( "3DViewer", "show_static_trihedron", vm->isStaticTrihedronVisible() ) );
+      vm->setInteractionStyle( resMgr->integerValue( "3DViewer", "navigation_mode", vm->interactionStyle() ) );
+      vm->setZoomingStyle( resMgr->integerValue( "3DViewer", "zooming_mode", vm->zoomingStyle() ) );
       vm->setDynamicPreSelection( resMgr->booleanValue( "VTKViewer", "dynamic_preselection", vm->dynamicPreSelection() ) );
       vm->setIncrementalSpeed( resMgr->integerValue( "VTKViewer", "speed_value", vm->incrementalSpeed() ),
                                resMgr->integerValue( "VTKViewer", "speed_mode", vm->incrementalSpeedMode() ) );
@@ -2094,22 +2094,46 @@ void LightApp_Application::createPreferences( LightApp_Preferences* pref )
   // ... "MRU" preferences group <<end>>
   // .. "General" preferences tab <<end>>
 
-  // .. "OCC viewer" group <<start>>
-  int occGroup = pref->addPreference( tr( "PREF_GROUP_OCCVIEWER" ), salomeCat );
-
+  // .. "3D viewer" group <<start>>
+  int Viewer3DGroup = pref->addPreference( tr( "PREF_GROUP_3DVIEWER" ), salomeCat );
+  // ... -> navigation mode
+  int vtkStyleMode = pref->addPreference( tr( "PREF_NAVIGATION" ), Viewer3DGroup,
+                                          LightApp_Preferences::Selector, "3DViewer", "navigation_mode" );
+  aValuesList.clear();
+  anIndicesList.clear();
+  aValuesList   << tr("PREF_STANDARD_STYLE") << tr("PREF_KEYFREE_STYLE");
+  anIndicesList << 0                         << 1;
+  pref->setItemProperty( "strings", aValuesList,   vtkStyleMode );
+  pref->setItemProperty( "indexes", anIndicesList, vtkStyleMode );
+  // ... -> zooming mode
+  #if OCC_VERSION_LARGE > 0x0603000A // available only with OCC-6.3-sp11 and higher version
+    int occZoomingStyleMode = pref->addPreference( tr( "PREF_ZOOMING" ), Viewer3DGroup,
+                                                   LightApp_Preferences::Selector, "3DViewer", "zooming_mode" );
+    aValuesList.clear();
+    anIndicesList.clear();
+    aValuesList   << tr("PREF_ZOOMING_AT_CENTER") << tr("PREF_ZOOMING_AT_CURSOR");
+    anIndicesList << 0                            << 1;
+    pref->setItemProperty( "strings", aValuesList,   occZoomingStyleMode );
+    pref->setItemProperty( "indexes", anIndicesList, occZoomingStyleMode );
+  #endif
   // ... "Trihedron" group <<start>>
-  int occTriGroup = pref->addPreference( tr( "PREF_TRIHEDRON" ), occGroup );
+  int occTriGroup = pref->addPreference( tr( "PREF_TRIHEDRON" ), Viewer3DGroup );
   pref->setItemProperty( "columns", 2, occTriGroup );
   // .... -> trihedron size
   int occTS = pref->addPreference( tr( "PREF_TRIHEDRON_SIZE" ), occTriGroup,
-                                   LightApp_Preferences::DblSpin, "OCCViewer", "trihedron_size" );
+                                   LightApp_Preferences::DblSpin, "3DViewer", "trihedron_size" );
   pref->setItemProperty( "min", 1.0E-06, occTS );
   pref->setItemProperty( "max", 1000, occTS );
   // .... -> relative size of trihedron
-  pref->addPreference( tr( "PREF_RELATIVE_SIZE" ), occTriGroup, LightApp_Preferences::Bool, "OCCViewer", "relative_size" );
+  pref->addPreference( tr( "PREF_RELATIVE_SIZE" ), occTriGroup, LightApp_Preferences::Bool, "3DViewer", "relative_size" );
   // .... -> show static trihedron
-  pref->addPreference( tr( "PREF_SHOW_STATIC_TRIHEDRON" ), occTriGroup, LightApp_Preferences::Bool, "OCCViewer", "show_static_trihedron" );
+  pref->addPreference( tr( "PREF_SHOW_STATIC_TRIHEDRON" ), occTriGroup, LightApp_Preferences::Bool, "3DViewer", "show_static_trihedron" );
   // ... "Trihedron" group <<end>>
+  // .. "3D viewer" group <<end>>
+
+  // .. "OCC viewer" group <<start>>
+  int occGroup = pref->addPreference( tr( "PREF_GROUP_OCCVIEWER" ), salomeCat );
+
   // ... "Background" group <<start>>
   int bgGroup = pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), occGroup );
   //  pref->setItemProperty( "columns", 2, bgGroup );
@@ -2168,26 +2192,6 @@ void LightApp_Application::createPreferences( LightApp_Preferences* pref )
   int occGen = pref->addPreference( "", occGroup, LightApp_Preferences::Frame );
   pref->setItemProperty( "margin",  0, occGen );
   pref->setItemProperty( "columns", 2, occGen );
-  // .... -> navigation mode
-  int occStyleMode = pref->addPreference( tr( "PREF_NAVIGATION" ), occGen,
-                                          LightApp_Preferences::Selector, "OCCViewer", "navigation_mode" );
-  aValuesList.clear();
-  anIndicesList.clear();
-  aValuesList   << tr("PREF_STANDARD_STYLE") << tr("PREF_KEYFREE_STYLE");
-  anIndicesList << 0                         << 1;
-  pref->setItemProperty( "strings", aValuesList,   occStyleMode );
-  pref->setItemProperty( "indexes", anIndicesList, occStyleMode );
-  // .... -> zooming mode
-#if OCC_VERSION_LARGE > 0x0603000A // available only with OCC-6.3-sp11 and higher version
-  int occZoomingStyleMode = pref->addPreference( tr( "PREF_ZOOMING" ), occGen,
-                                                 LightApp_Preferences::Selector, "OCCViewer", "zooming_mode" );
-  aValuesList.clear();
-  anIndicesList.clear();
-  aValuesList   << tr("PREF_ZOOMING_AT_CENTER") << tr("PREF_ZOOMING_AT_CURSOR");
-  anIndicesList << 0                            << 1;
-  pref->setItemProperty( "strings", aValuesList,   occZoomingStyleMode );
-  pref->setItemProperty( "indexes", anIndicesList, occZoomingStyleMode );
-#endif
   // ... -> empty frame (for layout) <<end>>
   // .. "OCC viewer" group <<end>>
 
@@ -2222,24 +2226,6 @@ void LightApp_Application::createPreferences( LightApp_Preferences* pref )
   pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
   pref->setItemProperty( "custom_enabled", false, bgId );
   pref->setItemProperty( "image_formats", formats, bgId );
-  // .... -> navigation mode
-  int vtkStyleMode = pref->addPreference( tr( "PREF_NAVIGATION" ), vtkGen,
-                                          LightApp_Preferences::Selector, "VTKViewer", "navigation_mode" );
-  aValuesList.clear();
-  anIndicesList.clear();
-  aValuesList   << tr("PREF_STANDARD_STYLE") << tr("PREF_KEYFREE_STYLE");
-  anIndicesList << 0                         << 1;
-  pref->setItemProperty( "strings", aValuesList,   vtkStyleMode );
-  pref->setItemProperty( "indexes", anIndicesList, vtkStyleMode );
-  // .... -> zooming mode
-  int vtkZoomingStyleMode = pref->addPreference( tr( "PREF_ZOOMING" ), vtkGen,
-                                                 LightApp_Preferences::Selector, "VTKViewer", "zooming_mode" );
-  aValuesList.clear();
-  anIndicesList.clear();
-  aValuesList   << tr("PREF_ZOOMING_AT_CENTER") << tr("PREF_ZOOMING_AT_CURSOR");
-  anIndicesList << 0                            << 1;
-  pref->setItemProperty( "strings", aValuesList,   vtkZoomingStyleMode );
-  pref->setItemProperty( "indexes", anIndicesList, vtkZoomingStyleMode );
   // .... -> speed increment
   int vtkSpeed = pref->addPreference( tr( "PREF_INCREMENTAL_SPEED" ), vtkGen,
                                       LightApp_Preferences::IntSpin, "VTKViewer", "speed_value" );
@@ -2258,20 +2244,6 @@ void LightApp_Application::createPreferences( LightApp_Preferences* pref )
   pref->addPreference( tr( "PREF_DYNAMIC_PRESELECTION" ),  vtkGen, LightApp_Preferences::Bool, "VTKViewer", "dynamic_preselection" );
   // ... -> empty frame (for layout) <<end>>
 
-  // ... "Trihedron" group <<start>>
-  int vtkTriGroup = pref->addPreference( tr( "PREF_TRIHEDRON" ), vtkGroup );
-  pref->setItemProperty( "columns", 2, vtkTriGroup );
-  // .... -> trihedron size
-  int vtkTS = pref->addPreference( tr( "PREF_TRIHEDRON_SIZE" ), vtkTriGroup,
-                                   LightApp_Preferences::DblSpin, "VTKViewer", "trihedron_size" );
-  pref->setItemProperty( "min", 1.0E-06, vtkTS );
-  pref->setItemProperty( "max", 150, vtkTS );
-  // .... -> relative size of trihedron
-  pref->addPreference( tr( "PREF_RELATIVE_SIZE" ), vtkTriGroup, LightApp_Preferences::Bool, "VTKViewer", "relative_size" );
-  // .... -> static trihedron
-  pref->addPreference( tr( "PREF_SHOW_STATIC_TRIHEDRON" ), vtkTriGroup, LightApp_Preferences::Bool, "VTKViewer", "show_static_trihedron" );
-  // ... "Trihedron" group <<end>>
-
   // ... space mouse sub-group <<start>>
   int vtkSM = pref->addPreference( tr( "PREF_FRAME_SPACEMOUSE" ), vtkGroup, LightApp_Preferences::GroupBox );
   //pref->setItemProperty( "columns", 2, vtkSM );
@@ -2493,17 +2465,17 @@ void LightApp_Application::preferencesChanged( const QString& sec, const QString
     }
   }
 
-#ifndef DISABLE_OCCVIEWER
-  if ( sec == QString( "OCCViewer" ) && (param == QString( "trihedron_size" ) || param == QString( "relative_size" )))
+  if ( sec == QString( "3DViewer" ) && (param == QString( "trihedron_size" ) || param == QString( "relative_size" )))
   {
     double sz = resMgr->doubleValue( sec, "trihedron_size", -1 );
     bool relative = resMgr->booleanValue( sec, "relative_size", true );
     QList<SUIT_ViewManager*> lst;
+#ifndef DISABLE_OCCVIEWER
     viewManagers( OCCViewer_Viewer::Type(), lst );
-    QListIterator<SUIT_ViewManager*> it( lst );
-    while ( it.hasNext() && sz >= 0 )
+    QListIterator<SUIT_ViewManager*> itOCC( lst );
+    while ( itOCC.hasNext() && sz >= 0 )
     {
-      SUIT_ViewModel* vm = it.next()->getViewModel();
+      SUIT_ViewModel* vm = itOCC.next()->getViewModel();
       if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
         continue;
 
@@ -2511,163 +2483,142 @@ void LightApp_Application::preferencesChanged( const QString& sec, const QString
       occVM->setTrihedronSize( sz, relative );
       occVM->getAISContext()->UpdateCurrentViewer();
     }
-  }
 #endif
-
-#ifndef DISABLE_OCCVIEWER
-  if ( sec == QString( "OCCViewer" ) && param == QString( "show_static_trihedron" ) )
-  {
-    bool isVisible = resMgr->booleanValue( "OCCViewer", "show_static_trihedron", true );
-    QList<SUIT_ViewManager*> lst;
-    viewManagers( OCCViewer_Viewer::Type(), lst );
-    QListIterator<SUIT_ViewManager*> it( lst );
-    while ( it.hasNext() )
+#ifndef DISABLE_VTKVIEWER
+#ifndef DISABLE_SALOMEOBJECT
+    viewManagers( SVTK_Viewer::Type(), lst );
+    QListIterator<SUIT_ViewManager*> itVTK( lst );
+    while ( itVTK.hasNext() && sz >= 0 )
     {
-      SUIT_ViewModel* vm = it.next()->getViewModel();
-      if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
+      SUIT_ViewModel* vm = itVTK.next()->getViewModel();
+      if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
         continue;
 
-      OCCViewer_Viewer* occVM = dynamic_cast<OCCViewer_Viewer*>( vm );
-      if( occVM )
+      SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
+      if( vtkVM )
       {
-        occVM->setStaticTrihedronDisplayed( isVisible );
+        vtkVM->setTrihedronSize( sz, relative );
+        vtkVM->Repaint();
       }
     }
-  }
 #endif
-
-#ifndef DISABLE_OCCVIEWER
-  if ( sec == QString( "OCCViewer" ) && param == QString( "navigation_mode" ) )
-  {
-    int mode = resMgr->integerValue( "OCCViewer", "navigation_mode", 0 );
-    QList<SUIT_ViewManager*> lst;
-    viewManagers( OCCViewer_Viewer::Type(), lst );
-    QListIterator<SUIT_ViewManager*> it( lst );
-    while ( it.hasNext() )
-    {
-      SUIT_ViewModel* vm = it.next()->getViewModel();
-      if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
-        continue;
-
-      OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
-      occVM->setInteractionStyle( mode );
-    }
-  }
 #endif
+  }
 
-#ifndef DISABLE_OCCVIEWER
-  if ( sec == QString( "OCCViewer" ) && param == QString( "zooming_mode" ) )
+  if ( sec == QString( "3DViewer" ) && param == QString( "show_static_trihedron" ) )
   {
-    int mode = resMgr->integerValue( "OCCViewer", "zooming_mode", 0 );
+    bool isVisible = resMgr->booleanValue( "3DViewer", "show_static_trihedron", true );
     QList<SUIT_ViewManager*> lst;
+#ifndef DISABLE_OCCVIEWER
     viewManagers( OCCViewer_Viewer::Type(), lst );
-    QListIterator<SUIT_ViewManager*> it( lst );
-    while ( it.hasNext() )
+    QListIterator<SUIT_ViewManager*> itOCC( lst );
+    while ( itOCC.hasNext() )
     {
-      SUIT_ViewModel* vm = it.next()->getViewModel();
+      SUIT_ViewModel* vm = itOCC.next()->getViewModel();
       if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
         continue;
 
-      OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
-      occVM->setZoomingStyle( mode );
+      OCCViewer_Viewer* occVM = dynamic_cast<OCCViewer_Viewer*>( vm );
+      if( occVM )
+      {
+        occVM->setStaticTrihedronDisplayed( isVisible );
+      }
     }
-  }
 #endif
-
 #ifndef DISABLE_VTKVIEWER
-  if ( sec == QString( "VTKViewer" ) && (param == QString( "trihedron_size" ) || param == QString( "relative_size" )) )
-  {
-    double sz = resMgr->doubleValue( "VTKViewer", "trihedron_size", -1 );
-    bool isRelative = resMgr->booleanValue( "VTKViewer", "relative_size", true );
-    QList<SUIT_ViewManager*> lst;
 #ifndef DISABLE_SALOMEOBJECT
     viewManagers( SVTK_Viewer::Type(), lst );
-    QListIterator<SUIT_ViewManager*> it( lst );
-    while ( it.hasNext() && sz >= 0 )
+    QListIterator<SUIT_ViewManager*> itVTK( lst );
+    while ( itVTK.hasNext() )
     {
-      SUIT_ViewModel* vm = it.next()->getViewModel();
+      SUIT_ViewModel* vm = itVTK.next()->getViewModel();
       if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
         continue;
 
       SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
       if( vtkVM )
       {
-        vtkVM->setTrihedronSize( sz, isRelative );
+        vtkVM->setStaticTrihedronVisible( isVisible );
         vtkVM->Repaint();
       }
     }
 #endif
-  }
 #endif
+  }
 
-#ifndef DISABLE_VTKVIEWER
-  if ( sec == QString( "VTKViewer" ) && (param == QString( "speed_value" ) || param == QString( "speed_mode" )) )
+  if ( sec == QString( "3DViewer" ) && param == QString( "navigation_mode" ) )
   {
-    int speed = resMgr->integerValue( "VTKViewer", "speed_value", 10 );
-    int mode = resMgr->integerValue( "VTKViewer", "speed_mode", 0 );
+    int mode = resMgr->integerValue( "3DViewer", "navigation_mode", 0 );
     QList<SUIT_ViewManager*> lst;
-#ifndef DISABLE_SALOMEOBJECT
-    viewManagers( SVTK_Viewer::Type(), lst );
-    QListIterator<SUIT_ViewManager*> it( lst );
-    while ( it.hasNext() )
+#ifndef DISABLE_OCCVIEWER
+    viewManagers( OCCViewer_Viewer::Type(), lst );
+    QListIterator<SUIT_ViewManager*> itOCC( lst );
+    while ( itOCC.hasNext() )
     {
-      SUIT_ViewModel* vm = it.next()->getViewModel();
-      if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
+      SUIT_ViewModel* vm = itOCC.next()->getViewModel();
+      if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
         continue;
 
-      SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
-      if( vtkVM ) vtkVM->setIncrementalSpeed( speed, mode );
+      OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
+      occVM->setInteractionStyle( mode );
     }
 #endif
-  }
-#endif
-
 #ifndef DISABLE_VTKVIEWER
-  if ( sec == QString( "VTKViewer" ) && param == QString( "projection_mode" ) )
-  {
-    int mode = resMgr->integerValue( "VTKViewer", "projection_mode", 0 );
-    QList<SUIT_ViewManager*> lst;
 #ifndef DISABLE_SALOMEOBJECT
     viewManagers( SVTK_Viewer::Type(), lst );
-    QListIterator<SUIT_ViewManager*> it( lst );
-    while ( it.hasNext() )
+    QListIterator<SUIT_ViewManager*> itVTK( lst );
+    while ( itVTK.hasNext() )
     {
-      SUIT_ViewModel* vm = it.next()->getViewModel();
+      SUIT_ViewModel* vm = itVTK.next()->getViewModel();
       if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
         continue;
 
       SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
-      if( vtkVM ) vtkVM->setProjectionMode( mode );
+      if( vtkVM ) vtkVM->setInteractionStyle( mode );
     }
 #endif
-  }
 #endif
+  }
 
-#ifndef DISABLE_VTKVIEWER
-  if ( sec == QString( "VTKViewer" ) && param == QString( "navigation_mode" ) )
+  if ( sec == QString( "3DViewer" ) && param == QString( "zooming_mode" ) )
   {
-    int mode = resMgr->integerValue( "VTKViewer", "navigation_mode", 0 );
+    int mode = resMgr->integerValue( "3DViewer", "zooming_mode", 0 );
     QList<SUIT_ViewManager*> lst;
+#ifndef DISABLE_OCCVIEWER
+    viewManagers( OCCViewer_Viewer::Type(), lst );
+    QListIterator<SUIT_ViewManager*> itOCC( lst );
+    while ( itOCC.hasNext() )
+    {
+      SUIT_ViewModel* vm = itOCC.next()->getViewModel();
+      if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
+        continue;
+
+      OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
+      occVM->setZoomingStyle( mode );
+    }
+#endif
+#ifndef DISABLE_VTKVIEWER
 #ifndef DISABLE_SALOMEOBJECT
     viewManagers( SVTK_Viewer::Type(), lst );
-    QListIterator<SUIT_ViewManager*> it( lst );
-    while ( it.hasNext() )
+    QListIterator<SUIT_ViewManager*> itVTK( lst );
+    while ( itVTK.hasNext() )
     {
-      SUIT_ViewModel* vm = it.next()->getViewModel();
+      SUIT_ViewModel* vm = itVTK.next()->getViewModel();
       if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
         continue;
 
       SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
-      if( vtkVM ) vtkVM->setInteractionStyle( mode );
+      if( vtkVM ) vtkVM->setZoomingStyle( mode );
     }
 #endif
-  }
 #endif
+  }
 
 #ifndef DISABLE_VTKVIEWER
-  if ( sec == QString( "VTKViewer" ) && param == QString( "zooming_mode" ) )
+  if ( sec == QString( "VTKViewer" ) && (param == QString( "speed_value" ) || param == QString( "speed_mode" )) )
   {
-    int mode = resMgr->integerValue( "VTKViewer", "zooming_mode", 0 );
+    int speed = resMgr->integerValue( "VTKViewer", "speed_value", 10 );
+    int mode = resMgr->integerValue( "VTKViewer", "speed_mode", 0 );
     QList<SUIT_ViewManager*> lst;
 #ifndef DISABLE_SALOMEOBJECT
     viewManagers( SVTK_Viewer::Type(), lst );
@@ -2679,16 +2630,16 @@ void LightApp_Application::preferencesChanged( const QString& sec, const QString
         continue;
 
       SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
-      if( vtkVM ) vtkVM->setZoomingStyle( mode );
+      if( vtkVM ) vtkVM->setIncrementalSpeed( speed, mode );
     }
 #endif
   }
 #endif
 
 #ifndef DISABLE_VTKVIEWER
-  if ( sec == QString( "VTKViewer" ) && param == QString( "dynamic_preselection" ) )
+  if ( sec == QString( "VTKViewer" ) && param == QString( "projection_mode" ) )
   {
-    bool mode = resMgr->booleanValue( "VTKViewer", "dynamic_preselection", true );
+    int mode = resMgr->integerValue( "VTKViewer", "projection_mode", 0 );
     QList<SUIT_ViewManager*> lst;
 #ifndef DISABLE_SALOMEOBJECT
     viewManagers( SVTK_Viewer::Type(), lst );
@@ -2700,16 +2651,16 @@ void LightApp_Application::preferencesChanged( const QString& sec, const QString
         continue;
 
       SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
-      if( vtkVM ) vtkVM->setDynamicPreSelection( mode );
+      if( vtkVM ) vtkVM->setProjectionMode( mode );
     }
 #endif
   }
 #endif
 
 #ifndef DISABLE_VTKVIEWER
-  if ( sec == QString( "VTKViewer" ) && param == QString( "show_static_trihedron" ) )
+  if ( sec == QString( "VTKViewer" ) && param == QString( "dynamic_preselection" ) )
   {
-    bool isVisible = resMgr->booleanValue( "VTKViewer", "show_static_trihedron", true );
+    bool mode = resMgr->booleanValue( "VTKViewer", "dynamic_preselection", true );
     QList<SUIT_ViewManager*> lst;
 #ifndef DISABLE_SALOMEOBJECT
     viewManagers( SVTK_Viewer::Type(), lst );
@@ -2721,11 +2672,7 @@ void LightApp_Application::preferencesChanged( const QString& sec, const QString
         continue;
 
       SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
-      if( vtkVM )
-      {
-        vtkVM->setStaticTrihedronVisible( isVisible );
-        vtkVM->Repaint();
-      }
+      if( vtkVM ) vtkVM->setDynamicPreSelection( mode );
     }
 #endif
   }
index 065b1bfe35d1166ce26b9547f16a652456d57074..1bb64f5dbd0c23b856482cfcf5203e0a6faa36b5 100644 (file)
@@ -618,6 +618,10 @@ The changes will be applied on the next application session.</translation>
         <source>PREF_GROUP_COMMON</source>
         <translation>Common</translation>
     </message>
+    <message>
+        <source>PREF_GROUP_3DVIEWER</source>
+        <translation>3D Viewer</translation>
+    </message>
     <message>
         <source>PREF_GROUP_OCCVIEWER</source>
         <translation>OCC 3D Viewer</translation>
index cf5a1fc0adf4516b834d715e3ffa11201951afa8..8ebdcb07569e786847bdbf68d39fe5f9db116439 100755 (executable)
@@ -618,6 +618,10 @@ Les modifications seront appliquées Ã  la prochaine session.</translation>
         <source>PREF_GROUP_COMMON</source>
         <translation>Commun</translation>
     </message>
+    <message>
+        <source>PREF_GROUP_3DVIEWER</source>
+        <translation>Scène 3D</translation>
+    </message>
     <message>
         <source>PREF_GROUP_OCCVIEWER</source>
         <translation>Scène OCC 3D</translation>
index b102ac7381c3df390303412c80aa009ab163f467..71f94cbe4db1449d89690ca99af4ade60275d911 100755 (executable)
@@ -161,7 +161,7 @@ OCCViewer_Viewer::OCCViewer_Viewer( bool DisplayTrihedron)
   
   SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
   if(resMgr)
-    myShowStaticTrihedron = resMgr->booleanValue( "OCCViewer", "show_static_trihedron", true );
+    myShowStaticTrihedron = resMgr->booleanValue( "3DViewer", "show_static_trihedron", true );
 }
 
 /*!
@@ -313,7 +313,7 @@ void OCCViewer_Viewer::onMouseRelease(SUIT_ViewWindow* theWindow, QMouseEvent* t
   if (!theWindow->inherits("OCCViewer_ViewWindow")) return;
 
   OCCViewer_ViewWindow* aView = (OCCViewer_ViewWindow*) theWindow;
-  if (!aView || aView->interactionStyle() != SUIT_ViewModel::STANDARD)
+  if (!aView )
     return;
 
   myEndPnt.setX(theEvent->x()); myEndPnt.setY(theEvent->y());
@@ -900,7 +900,7 @@ bool OCCViewer_Viewer::computeTrihedronSize( double& theNewSize, double& theSize
   if ( aMaxSide < Precision::Confusion() )
     return false;
 
-  float aSizeInPercents = SUIT_Session::session()->resourceMgr()->doubleValue("OCCViewer","trihedron_size", 100.);
+  float aSizeInPercents = SUIT_Session::session()->resourceMgr()->doubleValue("3DViewer","trihedron_size", 100.);
 
   static float EPS = 5.0E-3;
   theSize = getTrihedron()->Size();
index 7f01d1189be88c5e1e05c294af4b39d8437a78b1..085ba42e791b2674e0c2ad562fcb9c997d19f393 100755 (executable)
@@ -41,7 +41,8 @@ mypViewWindow( vw ),
 myType( type ),
 mypData( 0 ),
 myResult( Neutral ),
-myButtonState( 0 )
+myButtonState( 0 ),
+myHasShift( false )
 {
 }
 
@@ -99,6 +100,11 @@ int OCCViewer_ViewSketcher::buttonState() const
   return myButtonState;
 }
 
+bool OCCViewer_ViewSketcher::isHasShift() const
+{
+  return myHasShift;
+}
+
 void OCCViewer_ViewSketcher::onActivate()
 {
 }
@@ -116,6 +122,7 @@ bool OCCViewer_ViewSketcher::eventFilter( QObject* o, QEvent* e )
 {
   OCCViewer_ViewPort3d* avp = mypViewWindow->getViewPort();
 
+  QMouseEvent* me = (QMouseEvent*)e;
   SketchState state = EnTrain;
   bool ignore = false;
   if ( o == avp )
@@ -127,7 +134,6 @@ bool OCCViewer_ViewSketcher::eventFilter( QObject* o, QEvent* e )
       case QEvent::MouseButtonRelease:
       case QEvent::MouseButtonDblClick:
       {
-        QMouseEvent* me = (QMouseEvent*)e;
 
         myButtonState = me->buttons();
         if ( e->type() == QEvent::MouseButtonPress )
@@ -147,6 +153,7 @@ bool OCCViewer_ViewSketcher::eventFilter( QObject* o, QEvent* e )
           state = Fin;
 
         ignore = true;
+        myHasShift = ( me->modifiers() & Qt::ShiftModifier );
         break;
       }
       case QEvent::Hide:
index a90ff502cf2a2d988f84864844124861011fb317..a44350df90a0758a523e7785ed73e7e624171a08 100755 (executable)
@@ -57,6 +57,7 @@ public:
   int                          type() const;
   int                          result() const;
   int                          buttonState() const;
+  bool                         isHasShift() const;
   void*                        data() const;
 
   void                         activate();
@@ -88,6 +89,7 @@ protected:
   QCursor                      mySavedCursor;
   QPoint                       myStart, myCurr;
   int                          myButtonState;
+  bool                         myHasShift;
 };
 
 /*!
index 2b2d6d866b4f9d28e58667cb31635c2739676dad..8b3340dbd9a3b6cb4a53249d3f5842a227ee717a 100755 (executable)
@@ -230,6 +230,7 @@ OCCViewer_ViewWindow::OCCViewer_ViewWindow( SUIT_Desktop*     theDesktop,
   myRectBand = 0;
   
   IsSketcherStyle = false;
+  myIsKeyFree = false;
 
   mypSketcher = 0;
   myCurSketch = -1;
@@ -448,17 +449,24 @@ void OCCViewer_ViewWindow::vpMousePressEvent( QMouseEvent* theEvent )
 
   default:
   /*  Try to activate a transformation */
-    switch ( getButtonState(theEvent, anInteractionStyle) ) {
+    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();
+      activatePanning();
       break;
     case ROTATE:
-            activateRotation();
-            myViewPort->startRotation(myStartX, myStartY, myCurrPointType, mySelectedPoint);
+      activateRotation();
+      myViewPort->startRotation(myStartX, myStartY, myCurrPointType, mySelectedPoint);
       break;
     default:
       if ( myRotationPointSelection )
@@ -792,6 +800,25 @@ bool OCCViewer_ViewWindow::setTransformRequested( OperationType op )
 */
 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) {
@@ -829,8 +856,10 @@ void OCCViewer_ViewWindow::vpMouseMoveEvent( QMouseEvent* theEvent )
       int aState = theEvent->modifiers();
       int aButton = theEvent->buttons();
       int anInteractionStyle = interactionStyle();
-      if ( anInteractionStyle == SUIT_ViewModel::STANDARD && 
-           aButton == Qt::LeftButton && ( aState == Qt::NoModifier || Qt::ShiftModifier ) ) {
+      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();
@@ -843,8 +872,10 @@ void OCCViewer_ViewWindow::vpMouseMoveEvent( QMouseEvent* theEvent )
         }
         emit mouseMoving( this, theEvent );
       }
-      else if ( anInteractionStyle == SUIT_ViewModel::STANDARD && 
-                aButton == Qt::RightButton && ( aState == Qt::NoModifier || Qt::ShiftModifier ) ) {
+      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 )
@@ -2294,7 +2325,7 @@ void OCCViewer_ViewWindow::onSketchingFinished()
   if ( mypSketcher && mypSketcher->result() == OCCViewer_ViewSketcher::Accept )
   {
     Handle(AIS_InteractiveContext) ic = myModel->getAISContext();
-    bool append = bool( mypSketcher->buttonState() & Qt::ShiftModifier );
+    bool append = bool( mypSketcher->buttonState() && mypSketcher->isHasShift() );
     switch( mypSketcher->type() )
     {
     case Rect:
index 9bae6138ca29c740863b89263c71f03c7491b2c0..a445b5a86e668b3b0f60f32f1d3609bac2cdb32f 100755 (executable)
@@ -315,6 +315,7 @@ protected:
   bool                  myEnableDrawMode;
   bool                  myPaintersRedrawing;  // set to draw with external painters  
   bool                  IsSketcherStyle;
+  bool                  myIsKeyFree;
   
   QCursor               myCursor;
 
index 9d7f44a9b3f20c66efb13da2c557bb0ce26e9902..ebf166665925889beffd9015e3ee7b16f7ee232a 100755 (executable)
@@ -52,7 +52,7 @@ SUIT_ViewModel::SUIT_ViewModel()
 
     // "key free" interaction style
     SUIT_ViewModel::myStateMap[KEY_FREE][ZOOM]  = Qt::NoModifier;
-    SUIT_ViewModel::myButtonMap[KEY_FREE][ZOOM] = Qt::LeftButton | Qt::MidButton;
+    SUIT_ViewModel::myButtonMap[KEY_FREE][ZOOM] = Qt::RightButton;
 
     SUIT_ViewModel::myStateMap[KEY_FREE][PAN]   = Qt::NoModifier;
     SUIT_ViewModel::myButtonMap[KEY_FREE][PAN]  = Qt::MidButton;
index 6180af5cd48e38f74d2ed1debb57b601e90f3529..6b8b7d45e043dd6e3eb975b9b8b58495fddaef68 100755 (executable)
@@ -65,7 +65,7 @@ SET(SVTK_SOURCES
   SVTK_Prs.cxx
   SVTK_Actor.cxx
   SALOME_Actor.cxx
-  SVTK_RectPicker.cxx
+  SVTK_AreaPicker.cxx
   SVTK_DeviceActor.cxx
   SVTK_CubeAxesActor2D.cxx
   SVTK_NonIsometricDlg.cxx
@@ -118,7 +118,7 @@ SET(COMMON_HEADERS_H
   SVTK_Prs.h
   SVTK_Actor.h
   SALOME_Actor.h
-  SVTK_RectPicker.h
+  SVTK_AreaPicker.h
   SVTK_DeviceActor.h
   SVTK_FontWidget.h
   SVTK_CubeAxesActor2D.h
index e4c4a9a6564a6cd1751745ed3f3f973c711ba79f..6d176194cd9600e88abdbc1f241cf9d33a45836a 100755 (executable)
@@ -29,7 +29,7 @@ salomeinclude_HEADERS= \
        SVTK_Prs.h \
        SVTK_Actor.h \
        SALOME_Actor.h \
-       SVTK_RectPicker.h \
+       SVTK_AreaPicker.h \
        SVTK_DeviceActor.h \
        SVTK_FontWidget.h \
        SVTK_CubeAxesActor2D.h \
@@ -62,7 +62,7 @@ dist_libSVTK_la_SOURCES= \
        SVTK_Prs.cxx \
        SVTK_Actor.cxx \
        SALOME_Actor.cxx \
-       SVTK_RectPicker.cxx \
+       SVTK_AreaPicker.cxx \
        SVTK_DeviceActor.cxx \
        SVTK_CubeAxesActor2D.cxx \
        SVTK_NonIsometricDlg.cxx \
index bc7b43ad7ffaaf511920821b34fdb2fa6f5de0e0..5f74dd561981327aa0d1d1357db50bbdd173310e 100644 (file)
@@ -38,7 +38,7 @@
 #include "VTKViewer_TransformFilter.h"
 #include "VTKViewer_GeometryFilter.h"
 #include "VTKViewer_FramedTextActor.h"
-#include "SVTK_RectPicker.h"
+#include "SVTK_AreaPicker.h"
 
 #include "SVTK_Actor.h"
 
@@ -59,6 +59,7 @@
 #include <vtkPolyDataMapper.h>
 #include <vtkProperty.h>
 #include <vtkOutlineSource.h>
+#include <vtkPolygon.h>
 
 #include <vtkInteractorStyle.h>
 #include <vtkRenderWindowInteractor.h>
 #include <TColStd_MapOfInteger.hxx>
 #include <TColStd_IndexedMapOfInteger.hxx>
 
+#include <math.h>
+#include <QPoint>
+#include <QVector>
+
 #if defined __GNUC__
   #if __GNUC__ == 2
     #define __GNUC_2__
@@ -671,102 +676,30 @@ SALOME_Actor
 
   double x = theSelectionEvent->myX;
   double y = theSelectionEvent->myY;
-  double z = 0.0;
 
-  if( !theSelectionEvent->myIsRectangle ) {
-    switch(aSelectionMode){
-    case NodeSelection: {
-      SVTK::TPickLimiter aPickLimiter( myPointPicker, this );
-      myPointPicker->Pick( x, y, z, aRenderer );
-
-      int aVtkId = myPointPicker->GetPointId();
-      if( aVtkId >= 0 && mySelector->IsValid( this, aVtkId, true ) ) {
-        int anObjId = GetNodeObjId( aVtkId );
-        if( hasIO() && anObjId >= 0 ) {
-          mySelector->AddOrRemoveIndex( myIO, anObjId, anIsShift );
-          mySelector->AddIObject( this );
-        }
-      }
-      break;
-    }
-    case CellSelection: 
-    case EdgeSelection:
-    case FaceSelection:
-    case VolumeSelection: 
-    case Elem0DSelection:        
-    case BallSelection: 
-    {
-      SVTK::TPickLimiter aPickLimiter( myCellPicker, this );
-      myCellPicker->Pick( x, y, z, aRenderer );
-    
-      int aVtkId = myCellPicker->GetCellId();
-      if( aVtkId >= 0 && mySelector->IsValid( this, aVtkId ) ) {
-        int anObjId = GetElemObjId( aVtkId );
-        if( anObjId >= 0 ) {
-          if ( hasIO() && CheckDimensionId(aSelectionMode,this,anObjId) ) {
-            mySelector->AddOrRemoveIndex( myIO, anObjId, anIsShift );
-            mySelector->AddIObject( this );
-          }
-        }
-      }
-      break;
-    }
-    case EdgeOfCellSelection: 
-    {
-      SVTK::TPickLimiter aPickLimiter( myCellPicker, this );
-      myCellPicker->Pick( x, y, z, aRenderer );
-    
-      int aVtkId = myCellPicker->GetCellId();
-      if( aVtkId >= 0 && mySelector->IsValid( this, aVtkId ) ) {
-        int anObjId = GetElemObjId( aVtkId );
-        if( anObjId >= 0 ) {
-          int anEdgeId = GetEdgeId(this,myCellPicker.GetPointer(),anObjId);
-          if( hasIO() && anEdgeId < 0 ) {
-            mySelector->AddOrRemoveIndex( myIO, anObjId, false );
-            mySelector->AddOrRemoveIndex( myIO, anEdgeId, true );
-            mySelector->AddIObject( this );
-          } 
-        }
-      }
-      break;
-    }
-    case ActorSelection : 
-    {
-      if ( hasIO() ) {
-        if( mySelector->IsSelected( myIO ) && anIsShift )
-          mySelector->RemoveIObject( this );
-        else {
-          mySelector->AddIObject( this );
-        }
-      }
-      break;
-    }
-    default:
-      break;
-    }
-  }else{
+  if( theSelectionEvent->myIsRectangle || theSelectionEvent->myIsPolygon ) {
     double xLast = theSelectionEvent->myLastX;
     double yLast = theSelectionEvent->myLastY;
-    double zLast = 0.0;
 
     double x1 = x < xLast ? x : xLast;
     double y1 = y < yLast ? y : yLast;
-    double z1 = z < zLast ? z : zLast;
     double x2 = x > xLast ? x : xLast;
     double y2 = y > yLast ? y : yLast;
-    double z2 = z > zLast ? z : zLast;
 
     switch(aSelectionMode){
     case NodeSelection: {
 
-      SVTK::TPickLimiter aPickLimiter( myPointRectPicker, this );
-      myPointRectPicker->Pick( x1, y1, z1, x2, y2, z2, aRenderer );
+      SVTK::TPickLimiter aPickLimiter( myPointAreaPicker, this );
+      if ( theSelectionEvent->myIsRectangle )
+        myPointAreaPicker->Pick( x1, y1, x2, y2, aRenderer, SVTK_AreaPicker::RectangleMode );
+      else if( theSelectionEvent->myIsPolygon )
+        myPointAreaPicker->Pick( theSelectionEvent->myPolygonPoints, aRenderer, SVTK_AreaPicker::PolygonMode );
 
-      const SVTK_RectPicker::TVectorIdsMap& aVectorIdsMap = myPointRectPicker->GetPointIdsMap();
-      SVTK_RectPicker::TVectorIdsMap::const_iterator aMapIter = aVectorIdsMap.find(this);
+      const SVTK_AreaPicker::TVectorIdsMap& aVectorIdsMap = myPointAreaPicker->GetPointIdsMap();
+      SVTK_AreaPicker::TVectorIdsMap::const_iterator aMapIter = aVectorIdsMap.find(this);
       TColStd_MapOfInteger anIndexes;
       if(aMapIter != aVectorIdsMap.end()){
-        const SVTK_RectPicker::TVectorIds& aVectorIds = aMapIter->second;
+        const SVTK_AreaPicker::TVectorIds& aVectorIds = aMapIter->second;
         vtkIdType anEnd = aVectorIds.size();
         for(vtkIdType anId = 0; anId < anEnd; anId++ ) {
           int aPointId = aVectorIds[anId];
@@ -800,17 +733,28 @@ SALOME_Actor
             aRenderer->SetWorldPoint( aBounds[ i ], aBounds[ j ], aBounds[ k ], 1.0 );
             aRenderer->WorldToDisplay();
             aRenderer->GetDisplayPoint( aPnt );
-
-            if( aPnt[0] < x1 || aPnt[0] > x2 || aPnt[1] < y1 || aPnt[1] > y2 ) {
-              anIsPicked = false;
-              break;
+            bool anIsPointInSelection;
+            if( theSelectionEvent->myIsRectangle )
+              anIsPointInSelection =  aPnt[0] > x1 && aPnt[0] < x2 && aPnt[1] > y1 && aPnt[1] < y2;
+            else if( theSelectionEvent->myIsPolygon )
+              anIsPointInSelection = myPointAreaPicker->isPointInPolygon( QPoint( aPnt[0], aPnt[1] ),
+                                                                          theSelectionEvent->myPolygonPoints );
+
+            if( !anIsPointInSelection ) {
+                anIsPicked = false;
+                break;
             }
           }
         }
       }
 
-      if( anIsPicked )
-        mySelector->AddIObject(this);
+      if ( hasIO() ) {
+        if( anIsPicked && mySelector->IsSelected( myIO ) && anIsShift )
+          mySelector->RemoveIObject( this );
+        else if ( anIsPicked ){
+          mySelector->AddIObject( this );
+        }
+      }
 
       break;
     }
@@ -821,14 +765,17 @@ SALOME_Actor
     case Elem0DSelection:        
     case BallSelection: 
     {
-      SVTK::TPickLimiter aPickLimiter( myCellRectPicker, this );
-      myCellRectPicker->Pick( x1, y1, z1, x2, y2, z2, aRenderer );
-
-      const SVTK_RectPicker::TVectorIdsMap& aVectorIdsMap = myCellRectPicker->GetCellIdsMap();
-      SVTK_RectPicker::TVectorIdsMap::const_iterator aMapIter = aVectorIdsMap.find(this);
+      SVTK::TPickLimiter aPickLimiter( myCellAreaPicker, this );
+      if( theSelectionEvent->myIsRectangle )
+        myCellAreaPicker->Pick( x1, y1, x2, y2, aRenderer, SVTK_AreaPicker::RectangleMode );
+      else if( theSelectionEvent->myIsPolygon )
+        myCellAreaPicker->Pick( theSelectionEvent->myPolygonPoints, aRenderer, SVTK_AreaPicker::PolygonMode );
+
+      const SVTK_AreaPicker::TVectorIdsMap& aVectorIdsMap = myCellAreaPicker->GetCellIdsMap();
+      SVTK_AreaPicker::TVectorIdsMap::const_iterator aMapIter = aVectorIdsMap.find(this);
       TColStd_MapOfInteger anIndexes;
       if(aMapIter != aVectorIdsMap.end()){
-        const SVTK_RectPicker::TVectorIds& aVectorIds = aMapIter->second;
+        const SVTK_AreaPicker::TVectorIds& aVectorIds = aMapIter->second;
         vtkIdType anEnd = aVectorIds.size();
         for(vtkIdType anId = 0; anId < anEnd; anId++ ) {
           int aCellId = aVectorIds[anId];
@@ -857,6 +804,78 @@ SALOME_Actor
       break;
     }
   }
+  else {
+    switch(aSelectionMode){
+    case NodeSelection: {
+      SVTK::TPickLimiter aPickLimiter( myPointPicker, this );
+      myPointPicker->Pick( x, y, 0.0, aRenderer );
+
+      int aVtkId = myPointPicker->GetPointId();
+      if( aVtkId >= 0 && mySelector->IsValid( this, aVtkId, true ) ) {
+        int anObjId = GetNodeObjId( aVtkId );
+        if( hasIO() && anObjId >= 0 ) {
+          mySelector->AddOrRemoveIndex( myIO, anObjId, anIsShift );
+          mySelector->AddIObject( this );
+        }
+      }
+      break;
+    }
+    case CellSelection:
+    case EdgeSelection:
+    case FaceSelection:
+    case VolumeSelection:
+    case Elem0DSelection:
+    case BallSelection:
+    {
+      SVTK::TPickLimiter aPickLimiter( myCellPicker, this );
+      myCellPicker->Pick( x, y, 0.0, aRenderer );
+
+      int aVtkId = myCellPicker->GetCellId();
+      if( aVtkId >= 0 && mySelector->IsValid( this, aVtkId ) ) {
+        int anObjId = GetElemObjId( aVtkId );
+        if( anObjId >= 0 ) {
+          if ( hasIO() && CheckDimensionId(aSelectionMode,this,anObjId) ) {
+            mySelector->AddOrRemoveIndex( myIO, anObjId, anIsShift );
+            mySelector->AddIObject( this );
+          }
+        }
+      }
+      break;
+    }
+    case EdgeOfCellSelection:
+    {
+      SVTK::TPickLimiter aPickLimiter( myCellPicker, this );
+      myCellPicker->Pick( x, y, 0.0, aRenderer );
+
+      int aVtkId = myCellPicker->GetCellId();
+      if( aVtkId >= 0 && mySelector->IsValid( this, aVtkId ) ) {
+        int anObjId = GetElemObjId( aVtkId );
+        if( anObjId >= 0 ) {
+          int anEdgeId = GetEdgeId(this,myCellPicker.GetPointer(),anObjId);
+          if( hasIO() && anEdgeId < 0 ) {
+            mySelector->AddOrRemoveIndex( myIO, anObjId, false );
+            mySelector->AddOrRemoveIndex( myIO, anEdgeId, true );
+            mySelector->AddIObject( this );
+          }
+        }
+      }
+      break;
+    }
+    case ActorSelection :
+    {
+      if ( hasIO() ) {
+        if( mySelector->IsSelected( myIO ) && anIsShift )
+          mySelector->RemoveIObject( this );
+        else {
+          mySelector->AddIObject( this );
+        }
+      }
+      break;
+    }
+    default:
+      break;
+    }
+  }
 
   mySelectionMode = aSelectionMode;
 
@@ -978,25 +997,25 @@ SALOME_Actor
 }
 
 /*!
-  To set up a picker for point rectangle selection (initialized by SVTK_Renderer::AddActor)
-  \param theRectPicker - new picker
+  To set up a picker for point rectangle or polygonal selection (initialized by SVTK_Renderer::AddActor)
+  \param theAreaPicker - new picker
 */
 void
 SALOME_Actor
-::SetPointRectPicker(SVTK_RectPicker* theRectPicker) 
+::SetPointAreaPicker(SVTK_AreaPicker* theAreaPicker)
 {
-  myPointRectPicker = theRectPicker;
+  myPointAreaPicker = theAreaPicker;
 }
 
 /*!
-  To set up a picker for cell rectangle selection (initialized by SVTK_Renderer::AddActor)
-  \param theRectPicker - new picker
+  To set up a picker for cell rectangle of polygonal selection (initialized by SVTK_Renderer::AddActor)
+  \param theAreaPicker - new picker
 */
 void
 SALOME_Actor
-::SetCellRectPicker(SVTK_RectPicker* theRectPicker) 
+::SetCellAreaPicker(SVTK_AreaPicker* theAreaPicker)
 {
-  myCellRectPicker = theRectPicker;
+  myCellAreaPicker = theAreaPicker;
 }
 
 /*!
index aabf4635c3980f3817ac2a25ce5800997da050e7..704210dfcf038b4ad2a24d89a334eea148c2a4e5 100644 (file)
@@ -53,7 +53,7 @@ class vtkRenderWindowInteractor;
 class VTKViewer_FramedTextActor;
 
 class SVTK_Actor;
-class SVTK_RectPicker;
+class SVTK_AreaPicker;
 class SVTK_InteractorStyle;
 
 SVTK_EXPORT extern int SALOME_POINT_SIZE;
@@ -251,11 +251,11 @@ class SVTK_EXPORT SALOME_Actor : public VTKViewer_Actor
 
   //! To set up a picker for point rectangle selection (initialized by #SVTK_Renderer::AddActor)
   void
-  SetPointRectPicker(SVTK_RectPicker* theRectPicker);
+  SetPointAreaPicker(SVTK_AreaPicker* theAreaPicker);
 
   //! To set up a picker for cell rectangle selection (initialized by #SVTK_Renderer::AddActor)
   void
-  SetCellRectPicker(SVTK_RectPicker* theRectPicker);
+  SetCellAreaPicker(SVTK_AreaPicker* theAreaPicker);
 
   //----------------------------------------------------------------------------
   //! To set up a prehighlight property (initialized by #SVTK_Renderer::AddActor)
@@ -285,8 +285,8 @@ class SVTK_EXPORT SALOME_Actor : public VTKViewer_Actor
   vtkSmartPointer<vtkPointPicker> myPointPicker;
   vtkSmartPointer<vtkCellPicker> myCellPicker;
 
-  vtkSmartPointer<SVTK_RectPicker> myPointRectPicker;
-  vtkSmartPointer<SVTK_RectPicker> myCellRectPicker;
+  vtkSmartPointer<SVTK_AreaPicker> myPointAreaPicker;
+  vtkSmartPointer<SVTK_AreaPicker> myCellAreaPicker;
 
   vtkSmartPointer<SVTK_Actor> myPreHighlightActor;
   vtkSmartPointer<SVTK_Actor> myHighlightActor;
index a619838fdc73beb74ba0f2e4a2b4807a534b3d4a..4bca4352785344d2e4424e07dc7ec42ef65ee558 100644 (file)
@@ -28,7 +28,7 @@
 #include "SVTK_Prs.h"
 #include "SVTK_Actor.h"
 #include "SALOME_Actor.h"
-#include "SVTK_RectPicker.h"
+#include "SVTK_AreaPicker.h"
 #include "SVTK_DeviceActor.h"
 #include "SVTK_CubeAxesActor2D.h"
 #include "SVTK_Functor.h"
diff --git a/src/SVTK/SVTK_AreaPicker.cxx b/src/SVTK/SVTK_AreaPicker.cxx
new file mode 100644 (file)
index 0000000..974b2a0
--- /dev/null
@@ -0,0 +1,438 @@
+// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+//  SALOME VTKViewer : build VTK viewer into Salome desktop
+//  File   : SVTK_AreaPicker.cxx
+//  Author : 
+//  Module : SALOME
+//
+#include "SVTK_AreaPicker.h"
+
+#include <set>
+
+#include <vtkObjectFactory.h>
+#include <vtkCommand.h>
+
+#include <vtkAbstractMapper3D.h>
+#include <vtkMapper.h>
+#include <vtkProperty.h>
+
+#include <vtkAssemblyPath.h>
+#include <vtkAssemblyNode.h>
+
+#include <vtkRenderWindow.h>
+#include <vtkMatrix4x4.h>
+#include <vtkRenderer.h>
+#include <vtkPoints.h>
+#include <vtkCamera.h>
+#include <vtkCell.h>
+
+namespace
+{
+  //----------------------------------------------------------------------------
+  inline
+  double GetZ( float* theZPtr, int theSelection[4], int theDX, int theDY )
+  {
+    return theZPtr[theDX - theSelection[0]
+        + ( theDY - theSelection[1] )
+            * ( theSelection[2] - theSelection[0] + 1 )];
+  }
+
+  //----------------------------------------------------------------------------
+  inline
+  int Check( float* theZPtr, int theSelection[4], double theTolerance,
+      double theDZ, int theDX, int theDY )
+  {
+    int aRet = 0;
+    double aZ = -1.0;
+    if ( theDX >= theSelection[0] && theDX <= theSelection[2]
+        && theDY >= theSelection[1] && theDY <= theSelection[3] ) {
+      // Access the value from the captured zbuffer.  Note, we only
+      // captured a portion of the zbuffer, so we need to offset dx by
+      // the selection window.
+      aZ = GetZ( theZPtr, theSelection, theDX, theDY );
+      if ( aZ > theTolerance && aZ < 1.0 - theTolerance ) {
+        aRet = fabs( aZ - theDZ ) <= theTolerance;
+      }
+    }
+    return aRet;
+  }
+
+  //----------------------------------------------------------------------------
+  inline
+  void GetCenter( const double theBounds[6], double theCenter[3] )
+  {
+    theCenter[0] = ( theBounds[1] + theBounds[0] ) / 2.0;
+    theCenter[1] = ( theBounds[3] + theBounds[2] ) / 2.0;
+    theCenter[2] = ( theBounds[5] + theBounds[4] ) / 2.0;
+  }
+
+  //----------------------------------------------------------------------------
+  void CalculatePickPosition( vtkRenderer *theRenderer, double theSelectionX,
+      double theSelectionY, double theSelectionZ, double thePickPosition[3] )
+  {
+    // Convert the selection point into world coordinates.
+    //
+    theRenderer->SetDisplayPoint( theSelectionX, theSelectionY, theSelectionZ );
+    theRenderer->DisplayToWorld();
+    double* aWorldCoords = theRenderer->GetWorldPoint();
+    if ( aWorldCoords[3] != 0.0 ) {
+      for ( int i = 0; i < 3; i++ ) {
+        thePickPosition[i] = aWorldCoords[i] / aWorldCoords[3];
+      }
+    }
+  }
+}
+
+vtkStandardNewMacro( SVTK_AreaPicker )
+;
+
+SVTK_AreaPicker::SVTK_AreaPicker()
+{
+  this->Tolerance = 0.005;
+  this->PickPoints = 1;
+}
+
+SVTK_AreaPicker::~SVTK_AreaPicker()
+{
+}
+
+int SVTK_AreaPicker::Pick( double, double, double, vtkRenderer* )
+{
+  return 0;
+}
+
+int SVTK_AreaPicker::Pick( double theSelectionX, double theSelectionY,
+    double theSelectionX2, double theSelectionY2, vtkRenderer *theRenderer,
+    SelectionMode theMode )
+{
+  QVector< QPoint > aPoints;
+  aPoints.append( QPoint( theSelectionX, theSelectionY ) );
+  aPoints.append( QPoint( theSelectionX2, theSelectionY2 ) );
+  return Pick( aPoints, theRenderer, theMode );
+}
+
+int SVTK_AreaPicker::Pick( QVector< QPoint >& thePoints,
+    vtkRenderer *theRenderer, SelectionMode theMode )
+{
+  //  Initialize picking process
+  this->Initialize();
+  myCellIdsMap.clear();
+  myPointIdsMap.clear();
+  this->Renderer = theRenderer;
+
+  if ( theMode == RectangleMode ) {
+    mySelection = {thePoints[0].x(), thePoints[0].y(), thePoints[1].x(), thePoints[1].y()};
+  }
+  else if( theMode == PolygonMode ) {
+    int minX, minY, maxX, maxY;
+    minX = maxX = thePoints[0].x();
+    minY = maxY = thePoints[0].y();
+    for ( int i=0; i < thePoints.size(); i++ ) {
+      if ( thePoints[i].x() < minX )
+      minX = thePoints[i].x();
+      if ( thePoints[i].x() > maxX )
+      maxX = thePoints[i].x();
+      if ( thePoints[i].y() < minY )
+      minY = thePoints[i].y();
+      if ( thePoints[i].y() > maxY )
+      maxY = thePoints[i].y();
+    }
+    mySelection = {minX, minY, maxX, maxY};
+  }
+
+  // Invoke start pick method if defined
+  this->InvokeEvent( vtkCommand::StartPickEvent, NULL );
+
+  vtkPropCollection *aProps;
+  if ( this->PickFromList ) aProps = this->GetPickList();
+  else
+    aProps = theRenderer->GetViewProps();
+
+  aProps->InitTraversal();
+  while( vtkProp* aProp = aProps->GetNextProp() ) {
+    aProp->InitPathTraversal();
+    while( vtkAssemblyPath* aPath = aProp->GetNextPath() ) {
+      vtkMapper *aMapper = NULL;
+      bool anIsPickable = false;
+      vtkActor* anActor = NULL;
+      vtkProp *aPropCandidate = aPath->GetLastNode()->GetViewProp();
+      if ( aPropCandidate->GetPickable() && aPropCandidate->GetVisibility() ) {
+        anIsPickable = true;
+        anActor = vtkActor::SafeDownCast( aPropCandidate );
+        if ( anActor ) {
+          aMapper = anActor->GetMapper();
+          if ( anActor->GetProperty()->GetOpacity() <= 0.0 ) anIsPickable =
+              false;
+        }
+      }
+      if ( anIsPickable && aMapper && aMapper->GetInput() ) {
+        if ( this->PickPoints ) {
+          TVectorIds& aVisibleIds = myPointIdsMap[anActor];
+          TVectorIds anInVisibleIds;
+          SelectVisiblePoints( thePoints, theRenderer, aMapper->GetInput(),
+              aVisibleIds, anInVisibleIds, this->Tolerance, theMode );
+          if ( aVisibleIds.empty() ) {
+            myPointIdsMap.erase( myPointIdsMap.find( anActor ) );
+          }
+        }
+        else {
+          TVectorIds& aVectorIds = myCellIdsMap[anActor];
+          SelectVisibleCells( thePoints, theRenderer, aMapper->GetInput(),
+              aVectorIds, this->Tolerance, theMode );
+          if ( aVectorIds.empty() ) {
+            myCellIdsMap.erase( myCellIdsMap.find( anActor ) );
+          }
+        }
+      }
+    }
+  }
+
+  // Invoke end pick method if defined
+  this->InvokeEvent( vtkCommand::EndPickEvent, NULL );
+
+  return myPointIdsMap.empty() || myCellIdsMap.empty();
+}
+
+//----------------------------------------------------------------------------
+void SVTK_AreaPicker::SelectVisiblePoints( QVector< QPoint >& thePoints,
+    vtkRenderer *theRenderer, vtkDataSet *theInput,
+    SVTK_AreaPicker::TVectorIds& theVisibleIds,
+    SVTK_AreaPicker::TVectorIds& theInVisibleIds, double theTolerance,
+    SelectionMode theMode )
+{
+  theVisibleIds.clear();
+  theInVisibleIds.clear();
+
+  vtkIdType aNumPts = theInput->GetNumberOfPoints();
+  if ( aNumPts < 1 ) return;
+
+  theVisibleIds.reserve( aNumPts / 2 + 1 );
+  theInVisibleIds.reserve( aNumPts / 2 + 1 );
+
+  // Grab the composite perspective transform.  This matrix is used to convert
+  // each point to view coordinates.  vtkRenderer provides a WorldToView()
+  // method but it computes the composite perspective transform each time
+  // WorldToView() is called.  This is expensive, so we get the matrix once
+  // and handle the transformation ourselves.
+  vtkMatrix4x4 *aMatrix = vtkMatrix4x4::New();
+  aMatrix->DeepCopy(
+      theRenderer->GetActiveCamera()->GetCompositeProjectionTransformMatrix(
+          theRenderer->GetTiledAspectRatio(), 0, 1 ) );
+
+  // We grab the z-buffer for the selection region all at once and probe the resulting array.
+  float *aZPtr = theRenderer->GetRenderWindow()->GetZbufferData( mySelection[0],
+      mySelection[1], mySelection[2], mySelection[3] );
+
+  for ( vtkIdType aPntId = 0; aPntId < aNumPts; aPntId++ ) {
+    // perform conversion
+    double aX[4] = { 1.0, 1.0, 1.0, 1.0 };
+    theInput->GetPoint( aPntId, aX );
+
+    double aView[4];
+    aMatrix->MultiplyPoint( aX, aView );
+    if ( aView[3] == 0.0 ) continue;
+    theRenderer->SetViewPoint( aView[0] / aView[3], aView[1] / aView[3],
+        aView[2] / aView[3] );
+    theRenderer->ViewToDisplay();
+
+    double aDX[3];
+    theRenderer->GetDisplayPoint( aDX );
+
+    bool isInSelection;
+    if ( theMode == RectangleMode ) isInSelection = aDX[0] >= mySelection[0]
+        && aDX[0] <= mySelection[2] && aDX[1] >= mySelection[1]
+        && aDX[1] <= mySelection[3];
+    else
+      if ( theMode == PolygonMode ) isInSelection =
+          SVTK_AreaPicker::isPointInPolygon( QPoint( aDX[0], aDX[1] ),
+              thePoints );
+
+    // check whether visible and in selection window
+    if ( isInSelection ) {
+      int aDX0 = int( aDX[0] );
+      int aDX1 = int( aDX[1] );
+
+      int aRet = Check( aZPtr, mySelection, theTolerance, aDX[2], aDX0, aDX1 );
+      if ( aRet > 0 ) goto ADD_VISIBLE;
+      if ( aRet < 0 ) goto ADD_INVISIBLE;
+
+      static int aMaxRadius = 5;
+      for ( int aRadius = 1; aRadius < aMaxRadius; aRadius++ ) {
+        int aStartDX[2] = { aDX0 - aRadius, aDX1 - aRadius };
+        for ( int i = 0; i <= aRadius; i++ ) {
+          int aRet = Check( aZPtr, mySelection, theTolerance, aDX[2],
+              aStartDX[0]++, aStartDX[1] );
+          if ( aRet > 0 ) goto ADD_VISIBLE;
+          if ( aRet < 0 ) goto ADD_INVISIBLE;
+        }
+        for ( int i = 0; i <= aRadius; i++ ) {
+          int aRet = Check( aZPtr, mySelection, theTolerance, aDX[2],
+              aStartDX[0], aStartDX[1]++ );
+          if ( aRet > 0 ) goto ADD_VISIBLE;
+          if ( aRet < 0 ) goto ADD_INVISIBLE;
+        }
+        for ( int i = 0; i <= aRadius; i++ ) {
+          int aRet = Check( aZPtr, mySelection, theTolerance, aDX[2],
+              aStartDX[0]--, aStartDX[1] );
+          if ( aRet > 0 ) goto ADD_VISIBLE;
+          if ( aRet < 0 ) goto ADD_INVISIBLE;
+        }
+        for ( int i = 0; i <= aRadius; i++ ) {
+          int aRet = Check( aZPtr, mySelection, theTolerance, aDX[2],
+              aStartDX[0], aStartDX[1]-- );
+          if ( aRet > 0 ) goto ADD_VISIBLE;
+          if ( aRet < 0 ) goto ADD_INVISIBLE;
+        }
+      }
+      if ( false ) ADD_VISIBLE:theVisibleIds.push_back( aPntId );
+      if ( false ) ADD_INVISIBLE:theInVisibleIds.push_back( aPntId );
+    }
+  }  //for all points
+
+  aMatrix->Delete();
+
+  if ( aZPtr ) delete[] aZPtr;
+}
+
+void SVTK_AreaPicker::SelectVisibleCells( QVector< QPoint >& thePoints,
+    vtkRenderer *theRenderer, vtkDataSet *theInput,
+    SVTK_AreaPicker::TVectorIds& theVectorIds, double theTolerance,
+    SelectionMode theMode )
+{
+  theVectorIds.clear();
+
+  vtkIdType aNumCells = theInput->GetNumberOfCells();
+  if ( aNumCells < 1 ) return;
+
+  theVectorIds.reserve( aNumCells / 2 + 1 );
+
+  SVTK_AreaPicker::TVectorIds aVisiblePntIds;
+  SVTK_AreaPicker::TVectorIds anInVisiblePntIds;
+  SelectVisiblePoints( thePoints, theRenderer, theInput, aVisiblePntIds,
+      anInVisiblePntIds, theTolerance, theMode );
+
+  typedef std::set< vtkIdType > TIdsSet;
+  TIdsSet aVisibleIds( aVisiblePntIds.begin(), aVisiblePntIds.end() );
+  TIdsSet anInVisibleIds( anInVisiblePntIds.begin(), anInVisiblePntIds.end() );
+
+  // Grab the composite perspective transform.  This matrix is used to convert
+  // each point to view coordinates.  vtkRenderer provides a WorldToView()
+  // method but it computes the composite perspective transform each time
+  // WorldToView() is called.  This is expensive, so we get the matrix once
+  // and handle the transformation ourselves.
+  vtkMatrix4x4 *aMatrix = vtkMatrix4x4::New();
+  aMatrix->DeepCopy(
+      theRenderer->GetActiveCamera()->GetCompositeProjectionTransformMatrix(
+          theRenderer->GetTiledAspectRatio(), 0, 1 ) );
+
+  for ( vtkIdType aCellId = 0; aCellId < aNumCells; aCellId++ ) {
+    vtkCell* aCell = theInput->GetCell( aCellId );
+
+    double aBounds[6];
+    aCell->GetBounds( aBounds );
+
+    double aCenter[3];
+    GetCenter( aBounds, aCenter );
+
+    double aView[4];
+    double aX[4] = { aCenter[0], aCenter[1], aCenter[2], 1.0 };
+    aMatrix->MultiplyPoint( aX, aView );
+
+    if ( aView[3] == 0.0 ) continue;
+
+    theRenderer->SetViewPoint( aView[0] / aView[3], aView[1] / aView[3],
+        aView[2] / aView[3] );
+    theRenderer->ViewToDisplay();
+
+    double aDX[3];
+    theRenderer->GetDisplayPoint( aDX );
+
+    bool isInSelection;
+    if ( theMode == RectangleMode ) isInSelection = aDX[0] >= mySelection[0]
+        && aDX[0] <= mySelection[2] && aDX[1] >= mySelection[1]
+        && aDX[1] <= mySelection[3];
+    else
+      if ( theMode == PolygonMode ) isInSelection =
+          SVTK_AreaPicker::isPointInPolygon( QPoint( aDX[0], aDX[1] ),
+              thePoints );
+    // check whether visible and in selection window
+    if ( isInSelection ) {
+      vtkIdType aNumPts = aCell->GetNumberOfPoints();
+      bool anIsVisible = true;
+      for ( vtkIdType anId = 0; anId < aNumPts; anId++ ) {
+        vtkIdType aPntId = aCell->GetPointId( anId );
+        anIsVisible = aVisibleIds.find( aPntId ) != aVisibleIds.end();
+        if ( !anIsVisible ) break;
+      }
+      if ( anIsVisible ) theVectorIds.push_back( aCellId );
+    }
+  }  //for all parts
+}
+
+bool SVTK_AreaPicker::isPointInPolygon( const QPoint& thePoint,
+    const QVector< QPoint >& thePolygon )
+{
+  double eps = 1.0;
+  if ( thePolygon.size() < 3 ) return false;
+
+  QVector< QPoint >::const_iterator end = thePolygon.end();
+  QPoint last_pt = thePolygon.back();
+
+  last_pt.setX( last_pt.x() - thePoint.x() );
+  last_pt.setY( last_pt.y() - thePoint.y() );
+
+  double sum = 0.0;
+
+  for ( QVector< QPoint >::const_iterator iter = thePolygon.begin();
+      iter != end; ++iter ) {
+    QPoint cur_pt = *iter;
+    cur_pt.setX( cur_pt.x() - thePoint.x() );
+    cur_pt.setY( cur_pt.y() - thePoint.y() );
+
+    double del = last_pt.x() * cur_pt.y() - cur_pt.x() * last_pt.y();
+    double xy = cur_pt.x() * last_pt.x() + cur_pt.y() * last_pt.y();
+
+    sum +=
+        ( atan(
+            ( last_pt.x() * last_pt.x() + last_pt.y() * last_pt.y() - xy )
+                / del )
+            + atan(
+                ( cur_pt.x() * cur_pt.x() + cur_pt.y() * cur_pt.y() - xy )
+                    / del ) );
+
+    last_pt = cur_pt;
+  }
+  return fabs( sum ) > eps;
+}
+
+const SVTK_AreaPicker::TVectorIdsMap&
+SVTK_AreaPicker::GetPointIdsMap() const
+{
+  return myPointIdsMap;
+}
+
+const SVTK_AreaPicker::TVectorIdsMap&
+SVTK_AreaPicker::GetCellIdsMap() const
+{
+  return myCellIdsMap;
+}
diff --git a/src/SVTK/SVTK_AreaPicker.h b/src/SVTK/SVTK_AreaPicker.h
new file mode 100644 (file)
index 0000000..b08bea0
--- /dev/null
@@ -0,0 +1,150 @@
+// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+//  SALOME VTKViewer : build VTK viewer into Salome desktop
+//  File   : SVTK_AreaPicker.h
+//  Author : 
+//  Module : SALOME
+//
+#ifndef __SVTK_AreaPicker_h
+#define __SVTK_AreaPicker_h
+
+#include "SVTK.h"
+#include "VTKViewer.h"
+
+#include <map>
+#include <vector>
+
+#include <vtkAbstractPropPicker.h>
+#include <vtkDataSet.h>
+#include <QVector>
+#include <QPoint>
+
+class vtkRenderer;
+
+#ifdef WIN32
+#pragma warning ( disable:4251 )
+#endif
+
+/*! \class vtkAbstractPropPicker
+ * \brief For more information see <a href="http://www.vtk.org/">VTK documentation
+ */
+/*! \class SVTK_AreaPicker
+ * \brief Rectangular picker class.
+ */
+class SVTK_EXPORT SVTK_AreaPicker : public vtkAbstractPropPicker
+{
+ public:
+
+  enum SelectionMode { RectangleMode, PolygonMode };
+
+  static
+  SVTK_AreaPicker *New();
+
+  vtkTypeMacro(SVTK_AreaPicker,vtkAbstractPropPicker);
+  
+  /*! 
+    Specify tolerance for performing pick operation. Tolerance is specified
+    as fraction of rendering window size. (Rendering window size is measured
+    across diagonal.)
+  */
+  vtkSetMacro(Tolerance,double);
+  vtkGetMacro(Tolerance,double);
+
+  //! Use these methods to pick points or points and cells
+  vtkSetMacro(PickPoints,int);
+  vtkGetMacro(PickPoints,int);
+  vtkBooleanMacro(PickPoints,int);
+
+  int
+  Pick( QVector<QPoint>& thePoints,
+        vtkRenderer *theRenderer,
+        SelectionMode theMode );
+
+  int
+  Pick( double theSelectionX,
+        double theSelectionY,
+        double theSelectionX2,
+        double theSelectionY2,
+        vtkRenderer *theRenderer,
+        SelectionMode theMode );
+
+  static bool
+  isPointInPolygon( const QPoint& thePoint,const QVector<QPoint>& thePolygon );
+
+  typedef std::vector<vtkIdType> TVectorIds;
+  typedef std::map<vtkActor*,TVectorIds> TVectorIdsMap;
+
+  const TVectorIdsMap& 
+  GetPointIdsMap() const;
+
+  const TVectorIdsMap& 
+  GetCellIdsMap() const;
+
+ protected:
+  SVTK_AreaPicker();
+  ~SVTK_AreaPicker();
+
+  //! tolerance for computation (% of window)
+  double Tolerance;
+
+  //! use the following to control picking mode
+  int PickPoints;
+
+  //! coordinates of bounding box of selection
+  int mySelection[4];
+
+  TVectorIdsMap myPointIdsMap;
+  TVectorIdsMap myCellIdsMap;
+
+ private:
+  virtual 
+  int
+  Pick(double, 
+       double, 
+       double, 
+       vtkRenderer*);
+
+  void
+  SelectVisiblePoints( QVector<QPoint>& thePoints,
+                       vtkRenderer *theRenderer,
+                       vtkDataSet *theInput,
+                       SVTK_AreaPicker::TVectorIds& theVisibleIds,
+                       SVTK_AreaPicker::TVectorIds& theInVisibleIds,
+                       double theTolerance,
+                       SelectionMode theMode );
+  void
+  SelectVisibleCells( QVector<QPoint>& thePoints,
+                      vtkRenderer *theRenderer,
+                      vtkDataSet *theInput,
+                      SVTK_AreaPicker::TVectorIds& theVectorIds,
+                      double theTolerance,
+                      SelectionMode theMode );
+};
+
+#ifdef WIN32
+#pragma warning ( default:4251 )
+#endif
+
+#endif
+
+
index 7e99f5b7070ed50792533340b3d753c4bd75ec37..7f7f5e6e79a003291d21295ab64f82ddbf90decb 100644 (file)
@@ -59,6 +59,7 @@
 #include <QPixmap>
 #include <QWidget>
 #include <QRubberBand>
+#include <QPolygon>
 
 #include <algorithm>
 #include <iostream>
@@ -90,7 +91,9 @@ SVTK_InteractorStyle::SVTK_InteractorStyle():
   myControllerOnKeyDown(SVTK_ControllerOnKeyDown::New()),
   myHighlightSelectionPointActor(SVTK_Actor::New()),
   myRectBand(0),
-  myIsAdvancedZoomingEnabled(false)
+  myPolygonBand(0),
+  myIsAdvancedZoomingEnabled(false),
+  myPoligonState( Disable )
 {
   myPointPicker->Delete();
 
@@ -138,6 +141,7 @@ SVTK_InteractorStyle::SVTK_InteractorStyle():
 SVTK_InteractorStyle::~SVTK_InteractorStyle() 
 {
   endDrawRect();
+  endDrawPolygon();
 }
 
 /*!
@@ -451,6 +455,17 @@ void SVTK_InteractorStyle::OnMouseWheelBackward()
   myOtherPoint = QPoint(x, y);
 }
 
+/*!
+  To handle mouse double click event
+*/
+void SVTK_InteractorStyle::OnMouseButtonDoubleClick()
+{
+  if( myPoligonState == InProcess ) {
+    onFinishOperation();
+    myPoligonState = Finished;
+  }
+}
+
 /*!
   To handle mouse move event
 */
@@ -458,6 +473,12 @@ void SVTK_InteractorStyle::OnMouseMove(int vtkNotUsed(ctrl),
                                        int shift,
                                        int x, int y) 
 {
+  if ( myPoligonState == Start ) {
+    // if right button was pressed and mouse is moved
+    // we can to draw a polygon for polygonal selection
+    myPoligonState = InProcess;
+    startOperation( VTK_INTERACTOR_STYLE_CAMERA_SELECT );
+  }
   myShiftState = shift;
   if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE)
     onOperation(QPoint(x, y));
@@ -475,6 +496,9 @@ void SVTK_InteractorStyle::OnLeftButtonDown(int ctrl, int shift,
   if(GetCurrentRenderer() == NULL)
     return;
 
+  if ( myPoligonState != Disable )
+    return;
+
   myShiftState = shift;
   // finishing current viewer operation
   if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE) {
@@ -565,10 +589,23 @@ void SVTK_InteractorStyle::OnLeftButtonDown(int ctrl, int shift,
 */
 void SVTK_InteractorStyle::OnLeftButtonUp(int vtkNotUsed(ctrl),
                                           int shift, 
-                                          int vtkNotUsed(x),
-                                          int vtkNotUsed(y))
+                                          int x,
+                                          int y)
 {
   myShiftState = shift;
+  if( myPoligonState == InProcess ) { // add a new point of polygon
+    myPolygonPoints.append( QPoint( x, y ) );
+    this->Interactor->GetEventPosition( mySelectionEvent->myX, mySelectionEvent->myY );
+    mySelectionEvent->myPolygonPoints.append( QPoint( mySelectionEvent->myX, mySelectionEvent->myY ) );
+    return;
+  }
+  else if ( myPoligonState == Closed ) { // close polygon and apply a selection
+    onFinishOperation();
+    myPoligonState = Finished;
+    return;
+  }
+  else if( myPoligonState == Finished || myPoligonState == NotValid )
+    return;
   // finishing current viewer operation
   if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE) {
     onFinishOperation();
@@ -587,6 +624,9 @@ void SVTK_InteractorStyle::OnMiddleButtonDown(int ctrl,
   if(GetCurrentRenderer() == NULL)
     return;
 
+  if ( myPoligonState != Disable )
+    return;
+
   myShiftState = shift;
   // finishing current viewer operation
   if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE) {
@@ -612,6 +652,13 @@ void SVTK_InteractorStyle::OnMiddleButtonUp(int vtkNotUsed(ctrl),
                                             int vtkNotUsed(x),
                                             int vtkNotUsed(y))
 {
+  if( myPoligonState == InProcess ) { // delete a point of polygon
+    if ( myPolygonPoints.size() > 2 ) {
+      myPolygonPoints.remove( myPolygonPoints.size() - 1 );
+      mySelectionEvent->myPolygonPoints.remove( mySelectionEvent->myPolygonPoints.size() - 1 );
+    }
+    return;
+  }
   myShiftState = shift;
   // finishing current viewer operation
   if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE) {
@@ -633,6 +680,12 @@ void SVTK_InteractorStyle::OnRightButtonDown(int ctrl,
     return;
 
   myShiftState = shift;
+
+  if ( !ctrl ) {
+    myPoligonState = Start;
+    this->Interactor->GetEventPosition(mySelectionEvent->myX, mySelectionEvent->myY);
+    mySelectionEvent->myPolygonPoints.append( QPoint( mySelectionEvent->myX, mySelectionEvent->myY) );
+  }
   // finishing current viewer operation
   if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE) {
     onFinishOperation();
@@ -656,6 +709,18 @@ void SVTK_InteractorStyle::OnRightButtonUp(int vtkNotUsed(ctrl),
                                            int vtkNotUsed(x),
                                            int vtkNotUsed(y))
 {
+  if( myPoligonState == Start ) { // if right button was pressed but mouse is not moved
+    myPoligonState = Disable;
+    mySelectionEvent->myPolygonPoints.clear();
+  }
+
+  if( myPoligonState != Disable ) {
+    endDrawPolygon();
+    myPoligonState = Finished;
+    startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
+    return;
+  }
+
   myShiftState = shift;
   // finishing current viewer operation
   if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE) {
@@ -1020,7 +1085,10 @@ void SVTK_InteractorStyle::onStartOperation()
     case VTK_INTERACTOR_STYLE_CAMERA_SELECT:
     case VTK_INTERACTOR_STYLE_CAMERA_FIT:
     {
-      drawRect();
+      if ( myPoligonState == InProcess )
+        drawPolygon();
+      else
+        drawRect();
       break;
     }
     case VTK_INTERACTOR_STYLE_CAMERA_ZOOM:
@@ -1067,78 +1135,86 @@ void SVTK_InteractorStyle::onFinishOperation()
       }
       else {
         if (myPoint == myOtherPoint)
-          {
-            // process point selection
-            this->FindPokedRenderer(aSelectionEvent->myX, aSelectionEvent->myY);
-            Interactor->StartPickCallback();
+        {
+          // process point selection
+          this->FindPokedRenderer(aSelectionEvent->myX, aSelectionEvent->myY);
+          Interactor->StartPickCallback();
             
-            SALOME_Actor* aHighlightedActor = NULL;
-            vtkActorCollection* anActorCollection = GetSelector()->Pick(aSelectionEvent, GetCurrentRenderer());
-
-            aSelectionEvent->myIsRectangle = false;
+          SALOME_Actor* aHighlightedActor = NULL;
+          vtkActorCollection* anActorCollection = GetSelector()->Pick(aSelectionEvent, GetCurrentRenderer());
 
-            if(!myShiftState)
-              GetSelector()->ClearIObjects();
+          aSelectionEvent->myIsRectangle = false;
+          aSelectionEvent->myIsPolygon = false;
+          if(!myShiftState)
+            GetSelector()->ClearIObjects();
 
-            if( anActorCollection )
+          if( anActorCollection )
+          {
+            anActorCollection->InitTraversal();
+            while( vtkActor* aVTKActor = anActorCollection->GetNextActor() )
             {
-              anActorCollection->InitTraversal();
-              while( vtkActor* aVTKActor = anActorCollection->GetNextActor() )
+              if( SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( aVTKActor ) )
               {
-                if( SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( aVTKActor ) )
+                if( anActor->Highlight( this, aSelectionEvent, true ) )
                 {
-                  if( anActor->Highlight( this, aSelectionEvent, true ) )
-                  {
-                    aHighlightedActor = anActor;
-                    break;
-                  }
+                  aHighlightedActor = anActor;
+                  break;
                 }
               }
             }
+          }
 
-            if( !aHighlightedActor )
-            {
-              if(myLastHighlitedActor.GetPointer() && myLastHighlitedActor.GetPointer() != aHighlightedActor)
-                myLastHighlitedActor->Highlight( this, aSelectionEvent, false );
-            }
-            myLastHighlitedActor = aHighlightedActor;
-          } 
-        else 
+          if( !aHighlightedActor )
           {
-            //processing rectangle selection
-            Interactor->StartPickCallback();
-            GetSelector()->StartPickCallback();
+            if(myLastHighlitedActor.GetPointer() && myLastHighlitedActor.GetPointer() != aHighlightedActor)
+              myLastHighlitedActor->Highlight( this, aSelectionEvent, false );
+          }
+          myLastHighlitedActor = aHighlightedActor;
+        }
+        else
+        {
+          if ( myPoligonState == InProcess || myPoligonState == Closed )
+            aSelectionEvent->myIsPolygon = true;
+          else
             aSelectionEvent->myIsRectangle = true;
 
-            if(!myShiftState)
-              GetSelector()->ClearIObjects();
+          //processing polygonal selection
+          Interactor->StartPickCallback();
+          GetSelector()->StartPickCallback();
+
+          if(!myShiftState)
+            GetSelector()->ClearIObjects();
 
-            VTK::ActorCollectionCopy aCopy(GetCurrentRenderer()->GetActors());
-            vtkActorCollection* aListActors = aCopy.GetActors();
-            aListActors->InitTraversal();
-            while(vtkActor* aActor = aListActors->GetNextActor())
+          VTK::ActorCollectionCopy aCopy(GetCurrentRenderer()->GetActors());
+          vtkActorCollection* aListActors = aCopy.GetActors();
+          aListActors->InitTraversal();
+          while(vtkActor* aActor = aListActors->GetNextActor())
+          {
+            if(aActor->GetVisibility())
+            {
+              if(SALOME_Actor* aSActor = SALOME_Actor::SafeDownCast(aActor))
               {
-                if(aActor->GetVisibility())
-                  {
-                    if(SALOME_Actor* aSActor = SALOME_Actor::SafeDownCast(aActor))
-                      {
-                        if(aSActor->hasIO())
-                          aSActor->Highlight( this, aSelectionEvent, true );
-                      }
-                  }
+                if(aSActor->hasIO())
+                  aSActor->Highlight( this, aSelectionEvent, true );
               }
+            }
           }
+        }
+        aSelectionEvent->myIsRectangle = false;
+        aSelectionEvent->myIsPolygon = false;
+        aSelectionEvent->myPolygonPoints.clear();
+        endDrawPolygon();
         Interactor->EndPickCallback();
         GetSelector()->EndPickCallback();
       } 
-    } 
-    break;
-  case VTK_INTERACTOR_STYLE_CAMERA_ZOOM:
-  case VTK_INTERACTOR_STYLE_CAMERA_PAN:
-  case VTK_INTERACTOR_STYLE_CAMERA_ROTATE:
-  case VTK_INTERACTOR_STYLE_CAMERA_SPIN:
-    break;
-  case VTK_INTERACTOR_STYLE_CAMERA_GLOBAL_PAN: 
+      break;
+    }
+    case VTK_INTERACTOR_STYLE_CAMERA_ZOOM:
+    case VTK_INTERACTOR_STYLE_CAMERA_PAN:
+    case VTK_INTERACTOR_STYLE_CAMERA_ROTATE:
+    case VTK_INTERACTOR_STYLE_CAMERA_SPIN:
+      break;
+    case VTK_INTERACTOR_STYLE_CAMERA_GLOBAL_PAN:
     {
       int w, h, x, y;
       Interactor->GetSize(w, h);
@@ -1198,7 +1274,10 @@ void SVTK_InteractorStyle::onOperation(QPoint mousePos)
   case VTK_INTERACTOR_STYLE_CAMERA_FIT:
     {
       myOtherPoint = mousePos;
-      drawRect();
+      if ( myPoligonState == InProcess || myPoligonState == Closed || myPoligonState == NotValid )
+        drawPolygon();
+      else if ( myPoligonState != Finished )
+        drawRect();
       break;
     }
   }
@@ -1493,6 +1572,131 @@ void SVTK_InteractorStyle::drawRect()
   myRectBand->setVisible( aRect.isValid() );
 }
 
+bool isIntersect( const QPoint& theStart1, const QPoint& theEnd1,
+                  const QPoint& theStart2, const QPoint& theEnd2 )
+{
+  if ( ( theStart1 == theStart2 && theEnd1 == theEnd2 ) ||
+       ( theStart1 == theEnd2 && theEnd1 == theStart2 ) )
+    return true;
+
+  if ( theStart1 == theStart2 || theStart2 == theEnd1 ||
+      theStart1 == theEnd2 || theEnd1 == theEnd2 )
+    return false;
+
+  double x11 = theStart1.x() * 1.0;
+  double x12 = theEnd1.x() * 1.0;
+  double y11 = theStart1.y() * 1.0;
+  double y12 = theEnd1.y() * 1.0;
+
+  double x21 = theStart2.x() * 1.0;
+  double x22 = theEnd2.x() * 1.0;
+  double y21 = theStart2.y() * 1.0;
+  double y22 = theEnd2.y() * 1.0;
+
+  double k1 = x12 == x11 ? 0 : ( y12 - y11 ) / ( x12 - x11 );
+  double k2 = x22 == x21 ? 0 : ( y22 - y21 ) / ( x22 - x21 );
+
+  double b1 = y11 - k1 * x11;
+  double b2 = y21 - k2 * x21;
+
+  if ( k1 == k2 )
+  {
+    if ( b1 != b2 )
+      return false;
+    else
+      return !( ( qMax( x11, x12 ) <= qMin( x21, x22 ) ||
+                  qMin( x11, x12 ) >= qMax( x21, x22 ) ) &&
+                ( qMax( y11, y12 ) <= qMin( y21, y22 ) ||
+                  qMin( y11, y12 ) >= qMax( y21, y22 ) ) );
+  }
+  else
+  {
+    double x0 = ( b2 - b1 ) / ( k1 - k2 );
+    double y0 = ( k1 * b2 - k2 * b1 ) / ( k1 - k2 );
+
+    if ( qMin( x11, x12 ) < x0 && x0 < qMax( x11, x12 ) &&
+         qMin( y11, y12 ) < y0 && y0 < qMax( y11, y12 ) &&
+         qMin( x21, x22 ) < x0 && x0 < qMax( x21, x22 ) &&
+         qMin( y21, y22 ) < y0 && y0 < qMax( y21, y22 ) )
+      return true;
+  }
+  return false;
+}
+
+bool isValid( const QPolygon* thePoints, const QPoint& theCurrent )
+{
+  if ( !thePoints->count() )
+    return true;
+
+  if ( thePoints->count() == 1 && thePoints->point( 0 ) == theCurrent )
+    return false;
+
+  const QPoint& aLast = thePoints->point( thePoints->count() - 1 );
+
+  if ( aLast == theCurrent )
+    return true;
+
+  bool res = true;
+  for ( uint i = 0; i < thePoints->count() - 1 && res; i++ )
+  {
+    const QPoint& aStart = thePoints->point( i );
+    const QPoint& anEnd  = thePoints->point( i + 1 );
+    res = !isIntersect( aStart, anEnd, theCurrent, aLast );
+  }
+  return res;
+}
+
+/*!
+  Draws polygon
+*/
+void SVTK_InteractorStyle::drawPolygon()
+{
+  QSize aToler( 5, 5 );
+  if ( !myPolygonBand ) {
+    myPolygonBand = new QtxPolyRubberBand( GetRenderWidget() );
+    QPalette palette;
+    palette.setColor( myPolygonBand->foregroundRole(), Qt::white );
+    myPolygonBand->setPalette( palette );
+    myPolygonPoints.append( QPoint( myPoint.x(), myPoint.y() ) );
+  }
+  myPolygonBand->hide();
+
+  bool closed = false;
+  bool valid = GetRenderWidget()->rect().contains( QPoint( myOtherPoint.x(), myOtherPoint.y() ) );
+  if ( !myPolygonPoints.at(0).isNull() )
+  {
+    QRect aRect( myPolygonPoints.at(0).x() - aToler.width(), myPolygonPoints.at(0).y() - aToler.height(),
+                 2 * aToler.width(), 2 * aToler.height() );
+    closed = aRect.contains( QPoint( myOtherPoint.x(), myOtherPoint.y() ) );
+  }
+
+  QPolygon* points = new QPolygon( myPolygonPoints );
+  valid = valid && isValid( points, QPoint( myOtherPoint.x(), myOtherPoint.y() ) );
+  myPoligonState = valid ? InProcess : NotValid;
+  delete points;
+  if ( closed && !valid )
+    closed = false;
+
+  if ( closed && myPolygonPoints.size() > 2 ) {
+    GetRenderWidget()->setCursor( Qt::CrossCursor );
+    myPoligonState = Closed;
+  }
+  else if ( valid )
+    GetRenderWidget()->setCursor( Qt::PointingHandCursor );
+  else
+    GetRenderWidget()->setCursor( Qt::ForbiddenCursor );
+
+  myPolygonPoints.append( QPoint( myOtherPoint.x(), myOtherPoint.y() ) );
+
+  QPolygon aPolygon( myPolygonPoints );
+  myPolygonBand->initGeometry( aPolygon );
+  myPolygonBand->setVisible( true );
+
+  if ( myPolygonPoints.size() > 1 ) {
+    myPolygonPoints.remove( myPolygonPoints.size() - 1 );
+  }
+}
+
 /*!
   \brief Delete rubber band on the end on the dragging operation.
 */
@@ -1504,6 +1708,19 @@ void SVTK_InteractorStyle::endDrawRect()
   myRectBand = 0;
 }
 
+/*!
+  \brief Delete rubber band on the end on the dragging operation.
+*/
+void SVTK_InteractorStyle::endDrawPolygon()
+{
+  if ( myPolygonBand ) myPolygonBand->hide();
+
+  delete myPolygonBand;
+  myPolygonBand = 0;
+
+  myPolygonPoints.clear();
+}
+
 /*!
   Main process event method (reimplemented from #vtkInteractorStyle)
 */
index fe174e8d27f7a5eda73bfa2ecbe9ce330f057144..4070d5516ed2fab58967d8467dec0592bae26b38 100644 (file)
@@ -37,6 +37,7 @@
 #include <vtkSmartPointer.h>
 
 #include <QCursor>
+#include <QtxRubberBand.h>
 
 #include <map>
 
@@ -145,6 +146,8 @@ class QRubberBand;
 #define VTK_INTERACTOR_STYLE_CAMERA_GLOBAL_PAN 7
 #define VTK_INTERACTOR_STYLE_CAMERA_SELECT_ROTATION_POINT 8
 
+enum PolygonState { Disable, Start, InProcess, Finished, Closed, NotValid };
+
 //! Introduce SALOME way of user interaction
 /*!
   This class defines SALOME way of user interaction for VTK viewer, as well, 
@@ -205,6 +208,9 @@ class SVTK_EXPORT SVTK_InteractorStyle: public vtkInteractorStyle
   //! To handle mouse wheel backward event (reimplemented from #vtkInteractorStyle)
   virtual void OnMouseWheelBackward();
 
+  //! To handle mouse button double click event
+  virtual void OnMouseButtonDoubleClick();
+
   //! To handle keyboard event (reimplemented from #vtkInteractorStyle)
   virtual void OnChar();
 
@@ -231,7 +237,10 @@ class SVTK_EXPORT SVTK_InteractorStyle: public vtkInteractorStyle
   
   SVTK_Selector* GetSelector();
 
-  int   CurrentState() const { return State; }
+  int          CurrentState() const { return State; }
+  PolygonState GetPolygonState() const { return myPoligonState; }
+  void         SetPolygonState( const PolygonState& thePolygonState )
+                              { myPoligonState = thePolygonState; }
 
   void SetAdvancedZoomingEnabled( const bool theState ) { myIsAdvancedZoomingEnabled = theState; }
   bool IsAdvancedZoomingEnabled() const { return myIsAdvancedZoomingEnabled; }
@@ -308,6 +317,8 @@ class SVTK_EXPORT SVTK_InteractorStyle: public vtkInteractorStyle
   
   void drawRect();
   void endDrawRect();
+  void drawPolygon();
+  void endDrawPolygon();
 
  protected:
   QCursor                   myDefCursor;
@@ -354,10 +365,13 @@ class SVTK_EXPORT SVTK_InteractorStyle: public vtkInteractorStyle
   vtkSmartPointer<SVTK_Actor>     myHighlightSelectionPointActor;
   vtkSmartPointer<vtkPointPicker> myPointPicker;
   
-  double            myBBCenter[3];
+  double                          myBBCenter[3];
   bool                            myBBFirstCheck;
 
   QRubberBand*                    myRectBand; //!< selection rectangle rubber band
+  QtxPolyRubberBand*              myPolygonBand; //!< polygonal selection
+  QVector<QPoint>                 myPolygonPoints;
+  PolygonState                    myPoligonState;
 
   bool                            myIsAdvancedZoomingEnabled;
 };
index 7564c17c40e256328eb7a58cd71faf2d09d01fca..32c0b96fedd460cc55791a018ac5cb9b4c7b4840 100644 (file)
@@ -37,8 +37,8 @@ vtkStandardNewMacro(SVTK_KeyFreeInteractorStyle);
 //----------------------------------------------------------------------------
 
 SVTK_KeyFreeInteractorStyle::SVTK_KeyFreeInteractorStyle():
-  myIsMidButtonDown( false ),
-  myIsLeftButtonDown( false )
+  myIsLeftButtonDown( false ),
+  myIsRightButtonDown( false )
 {
 }
 
@@ -47,11 +47,37 @@ SVTK_KeyFreeInteractorStyle::~SVTK_KeyFreeInteractorStyle()
 {
 }
 
+//----------------------------------------------------------------------------
+void SVTK_KeyFreeInteractorStyle::OnMouseMove(int ctrl,
+                                              int shift,
+                                              int x, int y)
+{
+  // OnLeftButtonDown + OnMouseMove = Rotate
+  if ( myIsLeftButtonDown ) {
+    OnLeftButtonDown( ctrl, shift, x, y );
+    myIsLeftButtonDown = false;
+  }
+  // OnRightButtonDown + OnMouseMove = Zoom
+  if ( myIsRightButtonDown ) {
+    OnRightButtonDown( ctrl, shift, x, y );
+    myIsRightButtonDown = false;
+  }
+  SVTK_InteractorStyle::OnMouseMove( ctrl, shift, x, y );
+}
+
 //----------------------------------------------------------------------------
 void SVTK_KeyFreeInteractorStyle::OnLeftButtonDown(int ctrl, int shift, 
                                                    int x, int y) 
 {
-  myIsLeftButtonDown = true;
+  if ( ctrl ) {
+    SVTK_InteractorStyle::OnLeftButtonDown( !ctrl, shift, x, y );
+    return;
+  }
+
+  if( !myIsLeftButtonDown ) {
+    myIsLeftButtonDown = true;
+    return;
+  }
 
   if (this->HasObserver(vtkCommand::LeftButtonPressEvent)) {
     this->InvokeEvent(vtkCommand::LeftButtonPressEvent,NULL);
@@ -71,16 +97,9 @@ void SVTK_KeyFreeInteractorStyle::OnLeftButtonDown(int ctrl, int shift,
   if (ForcedState != VTK_INTERACTOR_STYLE_CAMERA_NONE) {
     startOperation(ForcedState);
   } 
-  else {
-    if (!(ctrl||shift)){
-      if (myIsMidButtonDown){
-        startOperation(VTK_INTERACTOR_STYLE_CAMERA_ZOOM);
-      }
-      else{
-        startOperation(VTK_INTERACTOR_STYLE_CAMERA_ROTATE);
-      }
-    }
-  }
+  else if ( !shift )
+    startOperation(VTK_INTERACTOR_STYLE_CAMERA_ROTATE);
+
   return;
 }
 
@@ -89,7 +108,10 @@ void SVTK_KeyFreeInteractorStyle::OnMiddleButtonDown(int ctrl,
                                                      int shift, 
                                                      int x, int y) 
 {
-  myIsMidButtonDown = true;
+  if ( ctrl ) {
+    SVTK_InteractorStyle::OnMiddleButtonDown( !ctrl, shift, x, y );
+    return;
+  }
 
   if (this->HasObserver(vtkCommand::MiddleButtonPressEvent))  {
     this->InvokeEvent(vtkCommand::MiddleButtonPressEvent,NULL);
@@ -109,36 +131,73 @@ void SVTK_KeyFreeInteractorStyle::OnMiddleButtonDown(int ctrl,
   if (ForcedState != VTK_INTERACTOR_STYLE_CAMERA_NONE) {
     startOperation(ForcedState);
   }
-  else {
-    if (!(ctrl||shift)){
-      if ( myIsLeftButtonDown ){
-        startOperation(VTK_INTERACTOR_STYLE_CAMERA_ZOOM);
-      }
-      else{
-        startOperation(VTK_INTERACTOR_STYLE_CAMERA_PAN);
-      }
-    }
+  else if ( !shift )
+    startOperation(VTK_INTERACTOR_STYLE_CAMERA_PAN);
+}
+
+//----------------------------------------------------------------------------
+void SVTK_KeyFreeInteractorStyle::OnRightButtonDown( int ctrl,
+                                                     int shift,
+                                                     int x, int y )
+{
+  if ( ctrl ) {
+    SVTK_InteractorStyle::OnRightButtonDown( !ctrl, shift, x, y );
+    return;
   }
+
+  if( !myIsRightButtonDown ) {
+    myIsRightButtonDown = true;
+    return;
+  }
+
+  if( this->HasObserver( vtkCommand::RightButtonPressEvent ) ) {
+    this->InvokeEvent( vtkCommand::RightButtonPressEvent, NULL );
+    return;
+  }
+  this->FindPokedRenderer( x, y );
+  if( this->CurrentRenderer == NULL ) {
+    return;
+  }
+  myShiftState = shift;
+  // finishing current viewer operation
+  if ( State != VTK_INTERACTOR_STYLE_CAMERA_NONE ) {
+    onFinishOperation();
+    startOperation( VTK_INTERACTOR_STYLE_CAMERA_NONE );
+  }
+  myOtherPoint = myPoint = QPoint(x, y);
+  if ( ForcedState != VTK_INTERACTOR_STYLE_CAMERA_NONE ) {
+    startOperation(ForcedState);
+  }
+  else if ( !shift )
+    startOperation( VTK_INTERACTOR_STYLE_CAMERA_ZOOM );
 }
 
 //----------------------------------------------------------------------------
 void SVTK_KeyFreeInteractorStyle::OnLeftButtonUp(int ctrl, int shift, int x, int y)
 {
-  myIsLeftButtonDown = false;
+  // OnLeftButtonDown + OnLeftButtonUp = Select
+  if ( myIsLeftButtonDown ) {
+    SVTK_InteractorStyle::OnLeftButtonDown( ctrl, shift, x, y );
+    myIsLeftButtonDown = false;
+  }
   SVTK_InteractorStyle::OnLeftButtonUp( ctrl, shift, x, y );
-
-  if ( myIsMidButtonDown )
-    OnMiddleButtonDown( ctrl, shift, x, y );
 }
 
 //----------------------------------------------------------------------------
 void SVTK_KeyFreeInteractorStyle::OnMiddleButtonUp(int ctrl, int shift, int x, int y)
 {
-  myIsMidButtonDown = false;
   SVTK_InteractorStyle::OnMiddleButtonUp( ctrl, shift, x, y );
+}
 
-  if ( myIsLeftButtonDown )
-    OnLeftButtonDown( ctrl, shift, x, y );
+//----------------------------------------------------------------------------
+void SVTK_KeyFreeInteractorStyle::OnRightButtonUp(int ctrl, int shift, int x, int y)
+{
+  // OnRightButtonDown + OnRightButtonUp = Open context menu
+  if( myIsRightButtonDown ) {
+    myIsRightButtonDown = false;
+    SVTK_InteractorStyle::OnRightButtonDown( ctrl, shift, x, y );
+  }
+  SVTK_InteractorStyle::OnRightButtonUp( ctrl, shift, x, y );
 }
 
 //----------------------------------------------------------------------------
index 8d4d053d9612eafd4ac57b6db162926879293fb8..dae65b44b7302e26ba768a60be6330aafc59e14c 100644 (file)
@@ -44,23 +44,32 @@ class SVTK_EXPORT SVTK_KeyFreeInteractorStyle : public SVTK_InteractorStyle
 
   // Generic event bindings must be overridden in subclasses
 
+  //! Redefine SVTK_InteractorStyle::OnMouseMove
+  virtual void OnMouseMove(int ctrl, int shift, int x, int y);
+
   //! Redefine SVTK_InteractorStyle::OnLeftButtonDown
   virtual void OnLeftButtonDown(int ctrl, int shift, int x, int y);
 
   //! Redefine SVTK_InteractorStyle::OnMiddleButtonDown
   virtual void OnMiddleButtonDown(int ctrl, int shift, int x, int y);
 
+  //! Redefine SVTK_InteractorStyle::OnRightButtonDown
+  virtual void OnRightButtonDown(int ctrl, int shift, int x, int y);
+
   //! Redefine SVTK_InteractorStyle::OnLeftButtonUp
   virtual void OnLeftButtonUp(int ctrl, int shift, int x, int y);
 
   //! Redefine SVTK_InteractorStyle::OnMiddleButtonUp
   virtual void OnMiddleButtonUp(int ctrl, int shift, int x, int y);
 
+  //! Redefine SVTK_InteractorStyle::OnRightButtonUp
+  virtual void OnRightButtonUp(int ctrl, int shift, int x, int y);
+
   //! Redefine SVTK_InteractorStyle::OnChar
   virtual void OnChar();
-  
-  bool myIsMidButtonDown;
+
   bool myIsLeftButtonDown;
+  bool myIsRightButtonDown;
 };
 
 #endif
diff --git a/src/SVTK/SVTK_RectPicker.cxx b/src/SVTK/SVTK_RectPicker.cxx
deleted file mode 100644 (file)
index f3251da..0000000
+++ /dev/null
@@ -1,498 +0,0 @@
-// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-//  SALOME VTKViewer : build VTK viewer into Salome desktop
-//  File   : SVTK_RectPicker.cxx
-//  Author : 
-//  Module : SALOME
-//
-#include "SVTK_RectPicker.h"
-
-#include <set>
-
-#include <vtkObjectFactory.h>
-#include <vtkCommand.h>
-
-#include <vtkAbstractMapper3D.h>
-#include <vtkMapper.h>
-#include <vtkProperty.h>
-
-#include <vtkAssemblyPath.h>
-#include <vtkAssemblyNode.h>
-
-#include <vtkRenderWindow.h>
-#include <vtkMatrix4x4.h>
-#include <vtkRenderer.h>
-#include <vtkDataSet.h>
-#include <vtkPoints.h>
-#include <vtkCamera.h>
-#include <vtkCell.h>
-
-namespace
-{
-  //----------------------------------------------------------------------------
-  inline
-  double
-  GetZ(float* theZPtr,
-       int theSelection[4],
-       int theDX,
-       int theDY)
-  {
-    return theZPtr[theDX - theSelection[0] + (theDY - theSelection[1])*(theSelection[2] - theSelection[0] + 1)];
-  }
-
-
-  //----------------------------------------------------------------------------
-  inline
-  int
-  Check(float* theZPtr,
-        int theSelection[4],
-        double theTolerance,
-        double theDZ,
-        int theDX,
-        int theDY)
-  {
-    int aRet = 0;
-    double aZ = -1.0;
-    if(theDX >= theSelection[0] && theDX <= theSelection[2] &&
-       theDY >= theSelection[1] && theDY <= theSelection[3])
-    {
-      // Access the value from the captured zbuffer.  Note, we only
-      // captured a portion of the zbuffer, so we need to offset dx by
-      // the selection window.
-      aZ = GetZ(theZPtr,theSelection,theDX,theDY);
-      if(aZ > theTolerance && aZ < 1.0 - theTolerance){
-        aRet = fabs(aZ - theDZ) <= theTolerance;
-      }
-    }
-
-    //cout<<"\tCheck = {"<<theDX<<", "<<theDY<<", "<<theDZ<<", "<<aZ<<"} = "<<aRet<<"\n";
-    return aRet;
-  }
-
-
-  //----------------------------------------------------------------------------
-  void
-  SelectVisiblePoints(int theSelection[4],
-                      vtkRenderer *theRenderer,
-                      vtkDataSet *theInput,
-                      SVTK_RectPicker::TVectorIds& theVisibleIds,
-                      SVTK_RectPicker::TVectorIds& theInVisibleIds,
-                      double theTolerance)
-  {
-    theVisibleIds.clear();
-    theInVisibleIds.clear();
-
-    vtkIdType aNumPts = theInput->GetNumberOfPoints();
-    if(aNumPts < 1)
-      return;
-    
-    theVisibleIds.reserve(aNumPts/2 + 1);
-    theInVisibleIds.reserve(aNumPts/2 + 1);
-
-    // Grab the composite perspective transform.  This matrix is used to convert
-    // each point to view coordinates.  vtkRenderer provides a WorldToView()
-    // method but it computes the composite perspective transform each time
-    // WorldToView() is called.  This is expensive, so we get the matrix once
-    // and handle the transformation ourselves.
-    vtkMatrix4x4 *aMatrix = vtkMatrix4x4::New();
-    aMatrix->DeepCopy( theRenderer->GetActiveCamera()->
-                       GetCompositeProjectionTransformMatrix( theRenderer->GetTiledAspectRatio(), 0, 1 ) );
-
-    // We grab the z-buffer for the selection region all at once and probe the resulting array.
-    float *aZPtr = theRenderer->GetRenderWindow()->
-      GetZbufferData(theSelection[0], theSelection[1], theSelection[2], theSelection[3]);
-
-    //cout<<"theSelection = {"<<theSelection[0]<<", "<<theSelection[1]<<", "<<theSelection[2]<<", "<<theSelection[3]<<"}\n";
-
-    //cout<<"\t";
-    for(int iX = theSelection[0]; iX <= theSelection[2];  iX++){
-      //cout<<iX<<"\t";
-    }
-    //cout<<endl;
-
-    for(int iY = theSelection[1]; iY <= theSelection[3];  iY++){
-      //cout<<iY<<"\t";
-      for(int iX = theSelection[0]; iX <= theSelection[2];  iX++){
-        //cout<<std::setprecision(4)<<GetZ(aZPtr,theSelection,iX,iY)<<"\t";
-      }
-      //cout<<endl;
-    }
-
-    for(vtkIdType aPntId = 0; aPntId < aNumPts; aPntId++){
-      // perform conversion
-      double aX[4] = {1.0, 1.0, 1.0, 1.0};
-      theInput->GetPoint(aPntId,aX);
-
-      double aView[4];
-      aMatrix->MultiplyPoint(aX,aView);
-      if(aView[3] == 0.0)
-        continue;
-      theRenderer->SetViewPoint(aView[0]/aView[3], 
-                                aView[1]/aView[3],
-                                aView[2]/aView[3]);
-      theRenderer->ViewToDisplay();
-
-      double aDX[3];
-      theRenderer->GetDisplayPoint(aDX);
-      
-      // check whether visible and in selection window 
-      if(aDX[0] >= theSelection[0] && aDX[0] <= theSelection[2] &&
-         aDX[1] >= theSelection[1] && aDX[1] <= theSelection[3])
-      {
-        //cout<<"aPntId "<<aPntId<<"; aDX = {"<<aDX[0]<<", "<<aDX[1]<<", "<<aDX[2]<<"}\n";
-        int aDX0 = int(aDX[0]);
-        int aDX1 = int(aDX[1]);
-
-        int aRet = Check(aZPtr,theSelection,theTolerance,aDX[2],aDX0,aDX1);
-        if(aRet > 0)
-          goto ADD_VISIBLE;
-        if(aRet < 0)
-          goto ADD_INVISIBLE;
-
-        static int aMaxRadius = 5;
-        for(int aRadius = 1; aRadius < aMaxRadius; aRadius++){
-          int aStartDX[2] = {aDX0 - aRadius, aDX1 - aRadius};
-          for(int i = 0; i <= aRadius; i++){
-            int aRet = Check(aZPtr,theSelection,theTolerance,aDX[2],aStartDX[0]++,aStartDX[1]);
-            if(aRet > 0)
-              goto ADD_VISIBLE;
-            if(aRet < 0)
-              goto ADD_INVISIBLE;
-          }
-          for(int i = 0; i <= aRadius; i++){
-            int aRet = Check(aZPtr,theSelection,theTolerance,aDX[2],aStartDX[0],aStartDX[1]++);
-            if(aRet > 0)
-              goto ADD_VISIBLE;
-            if(aRet < 0)
-              goto ADD_INVISIBLE;
-          }
-          for(int i = 0; i <= aRadius; i++){
-            int aRet = Check(aZPtr,theSelection,theTolerance,aDX[2],aStartDX[0]--,aStartDX[1]);
-            if(aRet > 0)
-              goto ADD_VISIBLE;
-            if(aRet < 0)
-              goto ADD_INVISIBLE;
-          }
-          for(int i = 0; i <= aRadius; i++){
-            int aRet = Check(aZPtr,theSelection,theTolerance,aDX[2],aStartDX[0],aStartDX[1]--);
-            if(aRet > 0)
-              goto ADD_VISIBLE;
-            if(aRet < 0)
-              goto ADD_INVISIBLE;
-          }
-        }
-        if(false)
-          ADD_VISIBLE : theVisibleIds.push_back(aPntId);
-        if(false)
-          ADD_INVISIBLE : theInVisibleIds.push_back(aPntId);
-      }
-    }//for all points
-
-    aMatrix->Delete();
-
-    if(aZPtr)
-      delete [] aZPtr;
-  }
-
-
-  //----------------------------------------------------------------------------
-  inline
-  void
-  GetCenter(const double theBounds[6],
-            double theCenter[3])
-  {
-    theCenter[0] = (theBounds[1] + theBounds[0]) / 2.0;
-    theCenter[1] = (theBounds[3] + theBounds[2]) / 2.0;
-    theCenter[2] = (theBounds[5] + theBounds[4]) / 2.0;
-  }
-
-  void
-  SelectVisibleCells(int theSelection[4],
-                     vtkRenderer *theRenderer,
-                     vtkDataSet *theInput,
-                     SVTK_RectPicker::TVectorIds& theVectorIds,
-                     double theTolerance)
-  {
-    theVectorIds.clear();
-
-    vtkIdType aNumCells = theInput->GetNumberOfCells();
-    if(aNumCells < 1)
-      return;
-    
-    theVectorIds.reserve(aNumCells/2 + 1);
-
-    SVTK_RectPicker::TVectorIds aVisiblePntIds;
-    SVTK_RectPicker::TVectorIds anInVisiblePntIds;
-    SelectVisiblePoints(theSelection,
-                        theRenderer,
-                        theInput,
-                        aVisiblePntIds,
-                        anInVisiblePntIds,
-                        theTolerance);
-
-    typedef std::set<vtkIdType> TIdsSet;
-    TIdsSet aVisibleIds(aVisiblePntIds.begin(),aVisiblePntIds.end());
-    TIdsSet anInVisibleIds(anInVisiblePntIds.begin(),anInVisiblePntIds.end());
-
-    // Grab the composite perspective transform.  This matrix is used to convert
-    // each point to view coordinates.  vtkRenderer provides a WorldToView()
-    // method but it computes the composite perspective transform each time
-    // WorldToView() is called.  This is expensive, so we get the matrix once
-    // and handle the transformation ourselves.
-    vtkMatrix4x4 *aMatrix = vtkMatrix4x4::New();
-    aMatrix->DeepCopy(theRenderer->GetActiveCamera()->
-                      GetCompositeProjectionTransformMatrix( theRenderer->GetTiledAspectRatio(), 0, 1 ) );
-
-    for(vtkIdType aCellId = 0; aCellId < aNumCells; aCellId++){
-      vtkCell* aCell = theInput->GetCell(aCellId);
-
-      double aBounds[6];
-      aCell->GetBounds(aBounds);
-
-      double aCenter[3];
-      GetCenter(aBounds,aCenter);
-
-      double aView[4];
-      double aX[4] = {aCenter[0], aCenter[1], aCenter[2], 1.0};
-      aMatrix->MultiplyPoint(aX,aView);
-
-      if(aView[3] == 0.0)
-        continue;
-
-      theRenderer->SetViewPoint(aView[0]/aView[3], 
-                                aView[1]/aView[3],
-                                aView[2]/aView[3]);
-      theRenderer->ViewToDisplay();
-
-      double aDX[3];
-      theRenderer->GetDisplayPoint(aDX);
-      
-      // check whether visible and in selection window 
-      if(aDX[0] >= theSelection[0] && aDX[0] <= theSelection[2] &&
-         aDX[1] >= theSelection[1] && aDX[1] <= theSelection[3])
-      {
-
-        //cout<<"aCellId = "<<aCellId<<": ";
-        vtkIdType aNumPts = aCell->GetNumberOfPoints();
-        bool anIsVisible = true;
-        for(vtkIdType anId = 0; anId < aNumPts; anId++){
-          vtkIdType aPntId = aCell->GetPointId(anId);
-          //cout<<aPntId<<"; ";
-          anIsVisible = aVisibleIds.find(aPntId) != aVisibleIds.end();
-          if(!anIsVisible)
-            break;
-        }
-        //cout<<"\t"<<anIsVisible<<"\n";
-        if(anIsVisible)
-          theVectorIds.push_back(aCellId);
-      }
-    }//for all parts
-  }
-
-  //----------------------------------------------------------------------------
-  void
-  CalculatePickPosition(vtkRenderer *theRenderer,
-                        double theSelectionX, 
-                        double theSelectionY, 
-                        double theSelectionZ,
-                        double thePickPosition[3])
-  {
-    // Convert the selection point into world coordinates.
-    //
-    theRenderer->SetDisplayPoint(theSelectionX, theSelectionY, theSelectionZ);
-    theRenderer->DisplayToWorld();
-    double* aWorldCoords = theRenderer->GetWorldPoint();
-    if ( aWorldCoords[3] != 0.0 ) {
-      for (int i=0; i < 3; i++) {
-        thePickPosition[i] = aWorldCoords[i] / aWorldCoords[3];
-      }
-    }
-  }
-}
-
-vtkStandardNewMacro(SVTK_RectPicker);
-
-SVTK_RectPicker
-::SVTK_RectPicker()
-{
-  this->Tolerance = 0.005;
-  this->PickPoints = 1;
-}
-
-SVTK_RectPicker
-::~SVTK_RectPicker()
-{}
-
-int
-SVTK_RectPicker
-::Pick(double, 
-       double, 
-       double, 
-       vtkRenderer*)
-{
-  return 0;
-}
-
-int
-SVTK_RectPicker
-::Pick(double theSelection[3], 
-       double theSelection2[3], 
-       vtkRenderer *theRenderer)
-{
-  return Pick(theSelection[0], theSelection[1], theSelection[2], 
-              theSelection2[0], theSelection2[1], theSelection2[2],
-              theRenderer);
-}
-
-int 
-SVTK_RectPicker
-::Pick(double theSelectionX, 
-       double theSelectionY, 
-       double theSelectionZ, 
-       double theSelectionX2, 
-       double theSelectionY2, 
-       double theSelectionZ2,
-       vtkRenderer *theRenderer)
-{
-  //  Initialize picking process
-  this->Initialize();
-  myCellIdsMap.clear();
-  myPointIdsMap.clear();
-  this->Renderer = theRenderer;
-
-  // Get camera focal point and position. Convert to display (screen) 
-  // coordinates. We need a depth value for z-buffer.
-  //
-  vtkCamera* aCamera = theRenderer->GetActiveCamera();
-
-  double aCameraFP[4];
-  aCamera->GetFocalPoint(aCameraFP); 
-  aCameraFP[3] = 1.0;
-
-  theRenderer->SetWorldPoint(aCameraFP);
-  theRenderer->WorldToDisplay();
-  double* aDisplayCoords = theRenderer->GetDisplayPoint();
-  double aSelectionZ = aDisplayCoords[2];
-
-  this->SelectionPoint[0] = theSelectionX;
-  this->SelectionPoint[1] = theSelectionY;
-  this->SelectionPoint[2] = theSelectionZ;
-
-  // Convert the selection point into world coordinates.
-  //
-  CalculatePickPosition(theRenderer,
-                        theSelectionX,
-                        theSelectionY,
-                        aSelectionZ,
-                        this->PickPosition);
-
-  this->SelectionPoint2[0] = theSelectionX2;
-  this->SelectionPoint2[1] = theSelectionY2;
-  this->SelectionPoint2[2] = theSelectionZ2;
-
-  // Convert the selection point into world coordinates.
-  //
-  CalculatePickPosition(theRenderer,
-                        theSelectionX2,
-                        theSelectionY2,
-                        aSelectionZ,
-                        this->PickPosition2);
-
-  // Invoke start pick method if defined
-  this->InvokeEvent(vtkCommand::StartPickEvent,NULL);
-
-  vtkPropCollection *aProps;
-  if ( this->PickFromList ) 
-    aProps = this->GetPickList();
-  else 
-    aProps = theRenderer->GetViewProps();
-
-  aProps->InitTraversal();
-  while ( vtkProp* aProp = aProps->GetNextProp() ) {
-    aProp->InitPathTraversal();
-    while ( vtkAssemblyPath* aPath = aProp->GetNextPath() ) {
-      vtkMapper *aMapper = NULL;
-      bool anIsPickable = false;
-      vtkActor* anActor = NULL;
-      vtkProp *aPropCandidate = aPath->GetLastNode()->GetViewProp();
-      if ( aPropCandidate->GetPickable() && aPropCandidate->GetVisibility() ) {
-        anIsPickable = true;
-        anActor = vtkActor::SafeDownCast(aPropCandidate);
-        if ( anActor ) {
-          aMapper = anActor->GetMapper();
-          if ( anActor->GetProperty()->GetOpacity() <= 0.0 )
-            anIsPickable = false;
-        }
-      }
-      if ( anIsPickable  &&  aMapper && aMapper->GetInput()) {
-        int aSelectionPoint[4] = {int(theSelectionX),
-                                  int(theSelectionY),
-                                  int(theSelectionX2),
-                                  int(theSelectionY2)};
-        if ( this->PickPoints ) {
-          TVectorIds& aVisibleIds = myPointIdsMap[anActor];
-          TVectorIds anInVisibleIds;
-          SelectVisiblePoints(aSelectionPoint,
-                              theRenderer,
-                              aMapper->GetInput(),
-                              aVisibleIds,
-                              anInVisibleIds,
-                              this->Tolerance);
-          if ( aVisibleIds.empty() ) {
-            myPointIdsMap.erase(myPointIdsMap.find(anActor));
-          }
-        } else {
-          TVectorIds& aVectorIds = myCellIdsMap[anActor];
-          SelectVisibleCells(aSelectionPoint,
-                             theRenderer,
-                             aMapper->GetInput(),
-                             aVectorIds,
-                             this->Tolerance);
-          if ( aVectorIds.empty() ) {
-            myCellIdsMap.erase(myCellIdsMap.find(anActor));
-          }
-        }
-      }
-    }
-  }
-
-  // Invoke end pick method if defined
-  this->InvokeEvent(vtkCommand::EndPickEvent,NULL);
-
-  return myPointIdsMap.empty() || myCellIdsMap.empty();
-}
-
-
-const SVTK_RectPicker::TVectorIdsMap& 
-SVTK_RectPicker
-::GetPointIdsMap() const
-{
-  return myPointIdsMap;
-}
-
-const SVTK_RectPicker::TVectorIdsMap& 
-SVTK_RectPicker
-::GetCellIdsMap() const
-{
-  return myCellIdsMap;
-}
diff --git a/src/SVTK/SVTK_RectPicker.h b/src/SVTK/SVTK_RectPicker.h
deleted file mode 100644 (file)
index d493159..0000000
+++ /dev/null
@@ -1,130 +0,0 @@
-// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-//  SALOME VTKViewer : build VTK viewer into Salome desktop
-//  File   : SVTK_RectPicker.h
-//  Author : 
-//  Module : SALOME
-//
-#ifndef __SVTK_RectPicker_h
-#define __SVTK_RectPicker_h
-
-#include "SVTK.h"
-#include "VTKViewer.h"
-
-#include <map>
-#include <vector>
-
-#include <vtkAbstractPropPicker.h>
-
-class vtkRenderer;
-
-#ifdef WIN32
-#pragma warning ( disable:4251 )
-#endif
-
-/*! \class vtkAbstractPropPicker
- * \brief For more information see <a href="http://www.vtk.org/">VTK documentation
- */
-/*! \class SVTK_RectPicker
- * \brief Rectangular picker class.
- */
-class SVTK_EXPORT SVTK_RectPicker : public vtkAbstractPropPicker
-{
- public:
-  static
-  SVTK_RectPicker *New();
-
-  vtkTypeMacro(SVTK_RectPicker,vtkAbstractPropPicker);
-  
-  /*! 
-    Specify tolerance for performing pick operation. Tolerance is specified
-    as fraction of rendering window size. (Rendering window size is measured
-    across diagonal.)
-  */
-  vtkSetMacro(Tolerance,double);
-  vtkGetMacro(Tolerance,double);
-
-  //! Use these methods to pick points or points and cells
-  vtkSetMacro(PickPoints,int);
-  vtkGetMacro(PickPoints,int);
-  vtkBooleanMacro(PickPoints,int);
-
-  virtual 
-  int
-  Pick(double theSelectionX, 
-       double theSelectionY, 
-       double theSelectionZ, 
-       double theSelectionX2, 
-       double theSelectionY2, 
-       double theSelectionZ2,
-       vtkRenderer *theRenderer);  
-
-  int
-  Pick(double theSelection[3], 
-       double theSelection2[3], 
-       vtkRenderer *theRenderer);
-
-  typedef std::vector<vtkIdType> TVectorIds;
-  typedef std::map<vtkActor*,TVectorIds> TVectorIdsMap;
-
-  const TVectorIdsMap& 
-  GetPointIdsMap() const;
-
-  const TVectorIdsMap& 
-  GetCellIdsMap() const;
-
- protected:
-  SVTK_RectPicker();
-  ~SVTK_RectPicker();
-
-  //! tolerance for computation (% of window)
-  double Tolerance;
-
-  //! use the following to control picking mode
-  int PickPoints;
-
-  //! second rectangle selection point in window (pixel) coordinates
-  double SelectionPoint2[3]; 
-
-  //! second rectangle selection point in world coordinates
-  double PickPosition2[3]; 
-
-  TVectorIdsMap myPointIdsMap;
-  TVectorIdsMap myCellIdsMap;
-
- private:
-  virtual 
-  int
-  Pick(double, 
-       double, 
-       double, 
-       vtkRenderer*);
-};
-
-#ifdef WIN32
-#pragma warning ( default:4251 )
-#endif
-
-#endif
-
-
index 50a0893124f547dc244109a975360f09fb9b1273..560cef7c3707cefdded8d63e2cffea2e85f18488 100644 (file)
@@ -724,17 +724,25 @@ void
 SVTK_RenderWindowInteractor
 ::mouseReleaseEvent( QMouseEvent *event )
 {
+  SVTK_InteractorStyle* style = 0;
   bool aRightBtn = event->button() == Qt::RightButton;
   bool isOperation = false;
+  bool isPolygonalSelection = false;
   if( aRightBtn && GetInteractorStyle()) {
-    SVTK_InteractorStyle* style = dynamic_cast<SVTK_InteractorStyle*>( GetInteractorStyle() );
+    style = dynamic_cast<SVTK_InteractorStyle*>( GetInteractorStyle() );
     if ( style )
       isOperation = style->CurrentState() != VTK_INTERACTOR_STYLE_CAMERA_NONE;
   }
 
   QVTK_RenderWindowInteractor::mouseReleaseEvent(event);
 
-  if ( aRightBtn && !isOperation && !( event->modifiers() & Qt::ControlModifier ) &&
+  if ( style ) {
+    isPolygonalSelection = style->GetPolygonState() == Finished;
+    style->SetPolygonState( Disable );
+  }
+
+  if ( aRightBtn && !isOperation && !isPolygonalSelection &&
+       !( event->modifiers() & Qt::ControlModifier ) &&
        !( event->modifiers() & Qt::ShiftModifier ) ) {
     QContextMenuEvent aEvent( QContextMenuEvent::Mouse,
                               event->pos(), event->globalPos() );
@@ -752,6 +760,12 @@ void
 SVTK_RenderWindowInteractor
 ::mouseDoubleClickEvent( QMouseEvent* event )
 {
+  if( GetInteractorStyle() && event->button() == Qt::LeftButton ) {
+    SVTK_InteractorStyle* style = dynamic_cast<SVTK_InteractorStyle*>( GetInteractorStyle() );
+    if ( style )
+      style->OnMouseButtonDoubleClick();
+  }
+
   QVTK_RenderWindowInteractor::mouseDoubleClickEvent(event);
 
   if(GENERATE_SUIT_EVENTS)
index fa09eb29f078fd9cd483af3f6cfaf8797b02988b..75c9574a3c27427c7cadee7992502380d3cfdbad 100644 (file)
@@ -28,7 +28,7 @@
 
 #include "SVTK_Trihedron.h"
 #include "SVTK_CubeAxesActor2D.h"
-#include "SVTK_RectPicker.h"
+#include "SVTK_AreaPicker.h"
 
 #include "SALOME_Actor.h"
 #include "VTKViewer_Actor.h"
@@ -67,8 +67,8 @@ SVTK_Renderer
   myEventCallbackCommand(vtkCallbackCommand::New()),
   myPointPicker(vtkPointPicker::New()),
   myCellPicker(vtkCellPicker::New()),
-  myPointRectPicker(SVTK_RectPicker::New()),
-  myCellRectPicker(SVTK_RectPicker::New()),
+  myPointAreaPicker(SVTK_AreaPicker::New()),
+  myCellAreaPicker(SVTK_AreaPicker::New()),
   myPreHighlightProperty(vtkProperty::New()),
   myHighlightProperty(vtkProperty::New()),
   myTransform(VTKViewer_Transform::New()),
@@ -83,12 +83,12 @@ SVTK_Renderer
   myPointPicker->Delete();
   myCellPicker->Delete();
 
-  myPointRectPicker->Delete();
-  myPointRectPicker->PickFromListOn();
+  myPointAreaPicker->Delete();
+  myPointAreaPicker->PickFromListOn();
 
-  myCellRectPicker->Delete();
-  myCellRectPicker->PickFromListOn();
-  myCellRectPicker->PickPointsOff();
+  myCellAreaPicker->Delete();
+  myCellAreaPicker->PickFromListOn();
+  myCellAreaPicker->PickPointsOff();
 
   //SetPreselectionProp();
   myPreHighlightProperty->Delete();
@@ -244,8 +244,8 @@ SVTK_Renderer
     anActor->SetPointPicker(myPointPicker.GetPointer());
     anActor->SetCellPicker(myCellPicker.GetPointer());
 
-    anActor->SetPointRectPicker(myPointRectPicker.GetPointer());
-    anActor->SetCellRectPicker(myCellRectPicker.GetPointer());
+    anActor->SetPointAreaPicker(myPointAreaPicker.GetPointer());
+    anActor->SetCellAreaPicker(myCellAreaPicker.GetPointer());
 
     anActor->SetPreHighlightProperty(myPreHighlightProperty.GetPointer());
     anActor->SetHighlightProperty(myHighlightProperty.GetPointer());
@@ -275,8 +275,8 @@ SVTK_Renderer
     anActor->SetPointPicker(NULL);
     anActor->SetCellPicker(NULL);
 
-    anActor->SetPointRectPicker(NULL);
-    anActor->SetCellRectPicker(NULL);
+    anActor->SetPointAreaPicker(NULL);
+    anActor->SetCellAreaPicker(NULL);
 
     anActor->SetPreHighlightProperty(NULL);
     anActor->SetHighlightProperty(NULL);
@@ -369,8 +369,8 @@ SVTK_Renderer
   myPointPicker->SetTolerance( theTolNodes );
   myCellPicker->SetTolerance( theTolCell );
 
-  myPointRectPicker->SetTolerance( theTolNodes );
-  myCellRectPicker->SetTolerance( theTolCell );
+  myPointAreaPicker->SetTolerance( theTolNodes );
+  myCellAreaPicker->SetTolerance( theTolCell );
 
   mySelector->SetTolerance( theTolObjects );
 }
index d8e545f84eaa4f0aa65a92e2053637157c824f43..6c9781286df1e163e4023aab3d4fd169e15ff4fb 100644 (file)
@@ -42,7 +42,7 @@ class vtkPointPicker;
 class vtkCellPicker;
 class vtkProperty;
 
-class SVTK_RectPicker;
+class SVTK_AreaPicker;
 
 class VTKViewer_Trihedron;
 class VTKViewer_Transform;
@@ -242,8 +242,8 @@ protected:
   vtkSmartPointer<vtkPointPicker> myPointPicker;
   vtkSmartPointer<vtkCellPicker> myCellPicker;
 
-  vtkSmartPointer<SVTK_RectPicker> myPointRectPicker;
-  vtkSmartPointer<SVTK_RectPicker> myCellRectPicker;
+  vtkSmartPointer<SVTK_AreaPicker> myPointAreaPicker;
+  vtkSmartPointer<SVTK_AreaPicker> myCellAreaPicker;
 
   vtkSmartPointer<vtkProperty> myPreHighlightProperty;
   vtkSmartPointer<vtkProperty> myHighlightProperty;
index 8378968dfee3e0b666d8c3ff647c8e336aef8362..4104194e2d43e6e5df5e75b2fb8f20a8664f2e3e 100644 (file)
@@ -28,6 +28,8 @@
 #define SVTK_SELECTIONEVENT_H
 
 #include "SVTK_Selection.h"
+#include <QPoint>
+#include <QVector>
 
 //! The structure is used for passing all infromation necessary for claculation of the selection.
 /*!
@@ -44,6 +46,8 @@ struct SVTK_SelectionEvent
   int myLastX; //!< Last X position of the mouse before starting any complex operation (like rectangle selection)
   int myLastY; //!< Last Y position of the mouse before starting any complex operation
   bool myIsRectangle; //!< A flag to define is it necessary provide rectangle selection for current #Selection_Mode
+  bool myIsPolygon; //!< A flag to define is it necessary provide polygonal selection for current #Selection_Mode
+  QVector<QPoint> myPolygonPoints; //!< Vector of points for polygonal selection
   bool myIsCtrl; //!< Is Ctrl key are pressed
   bool myIsShift; //!< Is Shift key are pressed
   int myKeyCode; //!< Code of the pressed key
index c2dc77e281c1468879d1b4e907f72045c2e2a27f..f1eee7c6951f63c865cb8fa4452af274a726b03b 100644 (file)
@@ -1038,7 +1038,7 @@ void VTKViewer_InteractorStyle::onFinishOperation()
           case FaceSelection:
           case VolumeSelection: 
             {
-              vtkSmartPointer<VTKViewer_CellRectPicker> picker = VTKViewer_CellRectPicker::New();
+              vtkSmartPointer<VTKViewer_CellAreaPicker> picker = VTKViewer_CellRectPicker::New();
               picker->SetTolerance(0.001);
               picker->Pick(x1, y1, 0.0, x2, y2, 0.0, this->CurrentRenderer);
               
@@ -1077,7 +1077,7 @@ void VTKViewer_InteractorStyle::onFinishOperation()
             break;          
           case ActorSelection: // objects selection
             {
-              vtkSmartPointer<VTKViewer_RectPicker> picker = VTKViewer_RectPicker::New();
+              vtkSmartPointer<VTKViewer_AreaPicker> picker = VTKViewer_AreaPicker::New();
               picker->SetTolerance(0.001);
               picker->Pick(x1, y1, 0.0, x2, y2, 0.0, this->CurrentRenderer);