From: vsr Date: Thu, 4 Dec 2014 12:40:23 +0000 (+0300) Subject: 0022765: [EDF] Improvement of local selection mechanism X-Git-Tag: V7_6_0a1~32^2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2Focc%2Fshape_reparation_2;p=modules%2Fgui.git 0022765: [EDF] Improvement of local selection mechanism Addition modifications: - Allow navigating through selectable objects by pressing "N" and "P" - Enable selection by pressing "S" in "standard" navigation mode - Enable multiple selection by pressing Shift+S - Fix bug: extended local selection should not work if pre-selection (or selection) is disabled in a viewer - Fix bug: when multiple objects is selected and any of them is re-selected, other ones should be deselected --- diff --git a/doc/salome/gui/input/common_functionality.doc b/doc/salome/gui/input/common_functionality.doc index 6b0e9b536..1f6683959 100644 --- a/doc/salome/gui/input/common_functionality.doc +++ b/doc/salome/gui/input/common_functionality.doc @@ -52,9 +52,20 @@ VTK viewer via the \ref vtk_preferences "VTK 3D Viewer Preferences".

Selection

An element can be selected by clicking on it with the left mouse button. -Selecting objects with locked Shift key produces a multi selection. +Selecting objects with locked \em Shift key produces a multi selection. -In the viewers there are two selection mechanisms: rectangle and +Additionally, when the viewer owns an input focus, an object can be selected +by pressing \em "S" on the keyboard. Pressing \em "S" when holding +\em Shift key allows adding/removing an object to/from the current selection. + +OCC viewer provides a way to navigate between the selectable objects. +This feature (disabled by default) is used in some dialog boxes (for example, +in Geometry module). When there are several objects which suit current +selection requirements (specified by the dialog) under the current mouse cursor, +it is possible to switch between them by means of mouse scroll wheel. +The same can be also done by pressing \em "N" and \em "P" keys. + +There are also two additional selection mechanisms: rectangle and polyline selection.

Rectangle selection

@@ -69,10 +80,8 @@ As a result, the objects within the rectangle are selected. \image html rectselectionvtk2.png - \note It is possible to add an area to the existing selection by holding down -Shift key while selecting. - +\em Shift key while selecting.

Polyline selection

@@ -92,8 +101,7 @@ As a result, the objects within the polygon are selected. \image html polyselectionvtk21.png To add an area to the existing selection it is necessary to hold down -Shift key while selecting. - +\em Shift key while selecting.
@@ -106,24 +114,27 @@ OCC and VTK 3D viewers support two different navigation modes: Rectangle selection in this mode is performed by the left mouse button and polyline selection by the right mouse button; - multiple selection is available when \b Shift button is pressed. + multiple selection is available when \em Shift button is pressed. - Also, holding \b Ctrl key with pressed mouse buttons performs the following view transformations: - - \b Ctrl + left mouse button - zooming; - - \b Ctrl + middle mouse button - panning; - - \b Ctrl + right mouse button - rotation. + Also, holding \em Ctrl key with pressed mouse buttons performs the following view transformations: + - \em Ctrl + left mouse button - zooming; + - \em Ctrl + middle mouse button - panning; + - \em Ctrl + right mouse button - rotation. - Keyboard free style This mode allows performing all view transformations without using the keyboard (only by the 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 the viewer is performed by pressing - "S" key or by the left mouse button click. Rectangle selection is done - by the left mouse button with \b Ctrl key pressed; polyline selection - is done by the right mouse button with \b Ctrl key pressed. + - Left mouse button performs view rotation; + - Middle mouse button performs panning; + - Right mouse button makes zooming. + + In this style rectangle selection is done by the left mouse button with \em Ctrl key pressed; + polyline selection is done by the right mouse button with \em Ctrl key pressed. + +In both styles selection of objects in the viewer can be performed by pressing +\em "S" key or by the left mouse button click. + +Zooming can be alternatively done by scrolling mouse wheel. */ diff --git a/src/OCCViewer/OCCViewer_ViewModel.cxx b/src/OCCViewer/OCCViewer_ViewModel.cxx index ae9e8639f..83574b196 100755 --- a/src/OCCViewer/OCCViewer_ViewModel.cxx +++ b/src/OCCViewer/OCCViewer_ViewModel.cxx @@ -303,7 +303,10 @@ void OCCViewer_Viewer::onMouseRelease(SUIT_ViewWindow* theWindow, QMouseEvent* t myEndPnt.setX(theEvent->x()); myEndPnt.setY(theEvent->y()); bool aHasShift = (theEvent->modifiers() & Qt::ShiftModifier); - if (!aHasShift) emit deselection(); + if (!aHasShift) { + myAISContext->ClearCurrents( false ); + emit deselection(); + } if (myStartPnt == myEndPnt) { @@ -353,25 +356,49 @@ void OCCViewer_Viewer::onMouseRelease(SUIT_ViewWindow* theWindow, QMouseEvent* t void OCCViewer_Viewer::onKeyPress(SUIT_ViewWindow* theWindow, QKeyEvent* theEvent) { if (!mySelectionEnabled) return; - if (theEvent->key() != Qt::Key_S) return; - if (!theWindow->inherits("OCCViewer_ViewWindow")) return; - OCCViewer_ViewWindow* aView = (OCCViewer_ViewWindow*) theWindow; - if (!aView || aView->interactionStyle() != SUIT_ViewModel::KEY_FREE) - return; + OCCViewer_ViewWindow* aView = qobject_cast( theWindow ); + if ( !aView ) return; - emit deselection(); + bool aHasShift = (theEvent->modifiers() & Qt::ShiftModifier); - if ( !isPreselectionEnabled() ) { - Handle(V3d_View) aView3d = aView->getViewPort()->getView(); - if ( !aView3d.IsNull() ) { - myAISContext->MoveTo(myCurPnt.x(), myCurPnt.y(), aView3d); + switch ( theEvent->key() ) { + case Qt::Key_S: + if (!aHasShift) { + myAISContext->ClearCurrents( false ); + emit deselection(); } - } - myAISContext->Select(); + if ( !isPreselectionEnabled() ) { + Handle(V3d_View) aView3d = aView->getViewPort()->getView(); + if ( !aView3d.IsNull() ) { + myAISContext->MoveTo(myCurPnt.x(), myCurPnt.y(), aView3d); + } + } + + if (aHasShift && myMultiSelectionEnabled) + myAISContext->ShiftSelect(); + else + myAISContext->Select(); + + emit selectionChanged(); - emit selectionChanged(); + break; + case Qt::Key_N: + if ( isPreselectionEnabled() ) { + if ( getAISContext()->HasOpenedContext() ) + getAISContext()->HilightNextDetected( aView->getViewPort()->getView() ); + } + break; + case Qt::Key_P: + if ( isPreselectionEnabled() ) { + if ( getAISContext()->HasOpenedContext() ) + getAISContext()->HilightPreviousDetected( aView->getViewPort()->getView() ); + } + break; + default: + break; + } } void OCCViewer_Viewer::onViewClosed(OCCViewer_ViewPort3d*) diff --git a/src/OCCViewer/OCCViewer_ViewWindow.cxx b/src/OCCViewer/OCCViewer_ViewWindow.cxx index 5b6558aa5..3b905cdfb 100755 --- a/src/OCCViewer/OCCViewer_ViewWindow.cxx +++ b/src/OCCViewer/OCCViewer_ViewWindow.cxx @@ -366,7 +366,7 @@ bool OCCViewer_ViewWindow::eventFilter( QObject* watched, QEvent* e ) if ( aEvent->modifiers().testFlag(Qt::ControlModifier) ) { Handle(AIS_InteractiveContext) ic = myModel->getAISContext(); - if ( ic->HasOpenedContext() ) { + if ( isPreselectionEnabled() && ic->HasOpenedContext() ) { if ( aEvent->delta() > 0 ) { ic->HilightNextDetected( myViewPort->getView() ); } else {