<h2>Selection</h2>
An element can be selected by clicking on it with the left mouse button.
-Selecting objects with locked <b>Shift</b> 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.
<h3>Rectangle selection</h3>
\image html rectselectionvtk2.png
-
\note It is possible to add an area to the existing selection by holding down
-<b>Shift</b> key while selecting.
-
+\em Shift key while selecting.
<h3>Polyline selection</h3>
\image html polyselectionvtk21.png
To add an area to the existing selection it is necessary to hold down
-<b>Shift</b> key while selecting.
-
+\em Shift key while selecting.
<hr>
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.
- <b>Keyboard free style</b>
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.
*/
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)
{
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<OCCViewer_ViewWindow*>( 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*)