From: vsv Date: Thu, 19 Mar 2020 13:27:33 +0000 (+0300) Subject: Improve selection mode according to request #3097 in NewGeom redmine X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2Fvsv%2Fimprove_selection_mode;p=modules%2Fgui.git Improve selection mode according to request #3097 in NewGeom redmine --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 9575399f7..dfc8dad16 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -69,8 +69,8 @@ SET(BUILD_SHARED_LIBS TRUE) # User options # ============ -OPTION(SALOME_BUILD_DOC "Generate SALOME GUI documentation" ON) -OPTION(SALOME_BUILD_TESTS "Build SALOME tests" ON) +OPTION(SALOME_BUILD_DOC "Generate SALOME GUI documentation" OFF) +OPTION(SALOME_BUILD_TESTS "Build SALOME tests" OFF) OPTION(SALOME_GUI_USE_OBSERVERS "Use study observers in GUI (advanced)" ON) CMAKE_DEPENDENT_OPTION(SALOME_GUI_BUILD_FRENCH_DOC "Generate SALOME GUI French documentation" OFF "SALOME_BUILD_DOC" OFF) diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index ba73f8d24..10cca2c57 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -1650,7 +1650,7 @@ SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType resMgr->doubleValue( "OCCViewer", "focus_value", vm->stereographicFocusValue() )); vm->setInterocularDistance( resMgr->integerValue( "OCCViewer", "iod_type", vm->interocularDistanceType() ), resMgr->doubleValue( "OCCViewer", "iod_value", vm->interocularDistanceValue() )); - vm->setSelectionStyle( resMgr->integerValue( "OCCViewer", "adv_selection_mode", vm->selectionStyle() ) ); + vm->setSelectionStyle((OCCViewer_ViewWindow::SelectionStyle) resMgr->integerValue( "OCCViewer", "adv_selection_mode", vm->selectionStyle() ) ); vm->setReverseStereo( resMgr->booleanValue( "OCCViewer", "reverse_stereo", vm->isReverseStereo() ) ); vm->setVSync( resMgr->booleanValue( "OCCViewer", "enable_vsync", vm->isVSync() ) ); @@ -3355,7 +3355,7 @@ void LightApp_Application::preferencesChanged( const QString& sec, const QString continue; OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm; - occVM->setSelectionStyle(mode); + occVM->setSelectionStyle((OCCViewer_ViewWindow::SelectionStyle)mode); } } #endif diff --git a/src/OCCViewer/CMakeLists.txt b/src/OCCViewer/CMakeLists.txt index 5590a5c29..aff671dd4 100644 --- a/src/OCCViewer/CMakeLists.txt +++ b/src/OCCViewer/CMakeLists.txt @@ -150,6 +150,7 @@ SET(_other_RESOURCES resources/occ_view_env_texture.png resources/occ_view_light_source.png resources/occ_view_circle_style.png + resources/occ_view_polygon_style.png resources/occ_view_rect_style.png ) diff --git a/src/OCCViewer/OCCViewer_ViewFrame.cxx b/src/OCCViewer/OCCViewer_ViewFrame.cxx index 91e39769e..2e5dbef84 100644 --- a/src/OCCViewer/OCCViewer_ViewFrame.cxx +++ b/src/OCCViewer/OCCViewer_ViewFrame.cxx @@ -355,13 +355,13 @@ void OCCViewer_ViewFrame::setProjectionType( int t) } //************************************************************************************** -int OCCViewer_ViewFrame::selectionStyle() const +OCCViewer_ViewWindow::SelectionStyle OCCViewer_ViewFrame::selectionStyle() const { return getView(MAIN_VIEW)->selectionStyle(); } //************************************************************************************** -void OCCViewer_ViewFrame::setSelectionStyle(int t) +void OCCViewer_ViewFrame::setSelectionStyle(OCCViewer_ViewWindow::SelectionStyle t) { foreach(OCCViewer_ViewWindow* aView, myViews) { aView->setSelectionStyle(t); diff --git a/src/OCCViewer/OCCViewer_ViewFrame.h b/src/OCCViewer/OCCViewer_ViewFrame.h index 755afb5ea..9b8ca0da8 100644 --- a/src/OCCViewer/OCCViewer_ViewFrame.h +++ b/src/OCCViewer/OCCViewer_ViewFrame.h @@ -75,8 +75,8 @@ public: virtual int projectionType() const; virtual void setProjectionType( int ); - virtual int selectionStyle() const; - virtual void setSelectionStyle(int); + virtual OCCViewer_ViewWindow::SelectionStyle selectionStyle() const; + virtual void setSelectionStyle(OCCViewer_ViewWindow::SelectionStyle); virtual int stereoType() const; virtual void setStereoType( const int ); diff --git a/src/OCCViewer/OCCViewer_ViewModel.cxx b/src/OCCViewer/OCCViewer_ViewModel.cxx index 0acca6fc5..8efceb215 100644 --- a/src/OCCViewer/OCCViewer_ViewModel.cxx +++ b/src/OCCViewer/OCCViewer_ViewModel.cxx @@ -22,7 +22,6 @@ #include "OCCViewer_ViewModel.h" #include "OCCViewer.h" -#include "OCCViewer_ViewWindow.h" #include "OCCViewer_ViewFrame.h" #include "OCCViewer_VService.h" #include "OCCViewer_ViewPort3d.h" @@ -54,6 +53,7 @@ #include #include #include +#include #include #include @@ -127,6 +127,10 @@ OCCViewer_Viewer::OCCViewer_Viewer( bool DisplayTrihedron) myAISContext = new AIS_InteractiveContext( myV3dViewer ); myAISContext->HighlightStyle(Prs3d_TypeOfHighlight_LocalSelected)->SetColor( Quantity_NOC_WHITE ); myAISContext->HighlightStyle(Prs3d_TypeOfHighlight_Selected)->SetColor( Quantity_NOC_WHITE ); + + // Set overlap detection for common behaviour of Rect selection and Polygon selection + // (both selects an object with partial overlap) + myAISContext->MainSelector()->AllowOverlapDetection(true); // display isoline on planar faces (box for ex.) myAISContext->IsoOnPlane( true ); @@ -171,7 +175,7 @@ OCCViewer_Viewer::OCCViewer_Viewer( bool DisplayTrihedron) // set projection type to orthographic myProjectionType = 0; - mySelectionStyle = 0; + mySelectionStyle = OCCViewer_ViewWindow::RectStyle; // set stereo parameters myStereoType = 0; myAnaglyphFilter = 0; @@ -359,17 +363,17 @@ 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) { - myAISContext->ClearCurrents( false ); - emit deselection(); - } if (myStartPnt == myEndPnt) { + if (!aHasShift) { + myAISContext->ClearCurrents( false ); + emit deselection(); + } if ( !isPreselectionEnabled() ) { Handle(V3d_View) aView3d = aView->getViewPort()->getView(); if ( !aView3d.IsNull() ) { - myAISContext->MoveTo( myEndPnt.x(), myEndPnt.y(), aView3d, Standard_True ); + myAISContext->MoveTo( myEndPnt.x(), myEndPnt.y(), aView3d, Standard_True ); } } @@ -378,31 +382,31 @@ void OCCViewer_Viewer::onMouseRelease(SUIT_ViewWindow* theWindow, QMouseEvent* t else myAISContext->Select( Standard_True ); } - else - { - if (aHasShift && myMultiSelectionEnabled) - myAISContext->ShiftSelect(myStartPnt.x(), myStartPnt.y(), - myEndPnt.x(), myEndPnt.y(), - aView->getViewPort()->getView(), Standard_False ); - else - myAISContext->Select(myStartPnt.x(), myStartPnt.y(), - myEndPnt.x(), myEndPnt.y(), - aView->getViewPort()->getView(), Standard_False ); - - int Nb = myAISContext->NbSelected(); - if( Nb>1 && !myMultiSelectionEnabled ) - { - myAISContext->InitSelected(); - Handle( SelectMgr_EntityOwner ) anOwner = myAISContext->SelectedOwner(); - if( !anOwner.IsNull() ) - { - myAISContext->ClearSelected( Standard_False ); - myAISContext->AddOrRemoveSelected( anOwner, Standard_False ); - } - } - - myAISContext->UpdateCurrentViewer(); - } + //else + //{ + // if (aHasShift && myMultiSelectionEnabled) + // myAISContext->ShiftSelect(myStartPnt.x(), myStartPnt.y(), + // myEndPnt.x(), myEndPnt.y(), + // aView->getViewPort()->getView(), Standard_False ); + // else + // myAISContext->Select(myStartPnt.x(), myStartPnt.y(), + // myEndPnt.x(), myEndPnt.y(), + // aView->getViewPort()->getView(), Standard_False ); + + // int Nb = myAISContext->NbSelected(); + // if( Nb>1 && !myMultiSelectionEnabled ) + // { + // myAISContext->InitSelected(); + // Handle( SelectMgr_EntityOwner ) anOwner = myAISContext->SelectedOwner(); + // if( !anOwner.IsNull() ) + // { + // myAISContext->ClearSelected( Standard_False ); + // myAISContext->AddOrRemoveSelected( anOwner, Standard_False ); + // } + // } + + // myAISContext->UpdateCurrentViewer(); + //} emit selectionChanged(); } @@ -549,12 +553,12 @@ void OCCViewer_Viewer::setProjectionType( const int theType ) } -int OCCViewer_Viewer::selectionStyle() const +OCCViewer_ViewWindow::SelectionStyle OCCViewer_Viewer::selectionStyle() const { return mySelectionStyle; } -void OCCViewer_Viewer::setSelectionStyle(const int theMode) +void OCCViewer_Viewer::setSelectionStyle(OCCViewer_ViewWindow::SelectionStyle theMode) { if (mySelectionStyle != theMode) { mySelectionStyle = theMode; diff --git a/src/OCCViewer/OCCViewer_ViewModel.h b/src/OCCViewer/OCCViewer_ViewModel.h index dddf9d11a..b5b4171dc 100644 --- a/src/OCCViewer/OCCViewer_ViewModel.h +++ b/src/OCCViewer/OCCViewer_ViewModel.h @@ -29,6 +29,7 @@ #include "OCCViewer.h" #include "OCCViewer_ClipPlane.h" +#include "OCCViewer_ViewWindow.h" #include "Qtx.h" #include "SUIT_ViewModel.h" @@ -184,8 +185,8 @@ public: int stereoType() const; void setStereoType( const int ); - int selectionStyle() const; - void setSelectionStyle(const int); + OCCViewer_ViewWindow::SelectionStyle selectionStyle() const; + void setSelectionStyle(OCCViewer_ViewWindow::SelectionStyle); int anaglyphFilter() const; void setAnaglyphFilter( const int ); @@ -288,7 +289,7 @@ protected: int myAnaglyphFilter; int myStereographicFocusType; int myInterocularDistanceType; - int mySelectionStyle; + OCCViewer_ViewWindow::SelectionStyle mySelectionStyle; double myStereographicFocusValue; double myInterocularDistanceValue; diff --git a/src/OCCViewer/OCCViewer_ViewSketcher.cxx b/src/OCCViewer/OCCViewer_ViewSketcher.cxx index 676a13e7e..d2441027d 100644 --- a/src/OCCViewer/OCCViewer_ViewSketcher.cxx +++ b/src/OCCViewer/OCCViewer_ViewSketcher.cxx @@ -234,6 +234,7 @@ void OCCViewer_RectSketcher::onDeactivate() delete (QRect*)mypData; mypData = 0; mypRectRB->clearGeometry(); + mypRectRB->hide(); } bool OCCViewer_RectSketcher::onKey( QKeyEvent* e ) @@ -316,7 +317,7 @@ OCCViewer_PolygonSketcher::OCCViewer_PolygonSketcher( OCCViewer_ViewWindow* vw, myDelButton ( 0 ), myMode ( Poligone ) { - mySketchButton = Qt::RightButton; + mySketchButton = Qt::LeftButton; if ( vw ) { OCCViewer_ViewPort3d* avp = mypViewWindow->getViewPort(); @@ -357,43 +358,82 @@ void OCCViewer_PolygonSketcher::onActivate() void OCCViewer_PolygonSketcher::onDeactivate() { - if ( mypPolyRB ) - mypPolyRB->clearGeometry(); - if (mypCircleRB) + if (mypPolyRB) { + mypPolyRB->clearGeometry(); + mypPolyRB->hide(); + } + if (mypCircleRB) { mypCircleRB->clearGeometry(); + mypCircleRB->hide(); + } ((QPolygon*)mypData)->clear(); } -bool OCCViewer_PolygonSketcher::onKey( QKeyEvent* e ) +bool OCCViewer_PolygonSketcher::onKey(QKeyEvent* e) { - if ( e->key() == Qt::Key_Escape ) + int aKey = e->key(); + if (aKey == Qt::Key_Escape) { myResult = Reject; return true; } - else if ( e->key() == Qt::Key_Enter || e->key() == Qt::Key_Return ) + else if (aKey == Qt::Key_Enter || aKey == Qt::Key_Return) { QPolygon* points = (QPolygon*)data(); - if ( points->count() ) + if (points->count()) { - QPoint last = points->point( points->count() - 1 ); - if ( last != myCurr ) + QPoint last = points->point(points->count() - 1); + if (last != myCurr) { - points->resize( points->count() + 1 ); - points->setPoint( points->count() - 1, myCurr ); + points->resize(points->count() + 1); + points->setPoint(points->count() - 1, myCurr); } } myResult = Accept; return true; } - else if ( e->key() == Qt::Key_Backspace && e->type() == QEvent::KeyRelease ) + else if (aKey == Qt::Key_Backspace && e->type() == QEvent::KeyRelease) { QPolygon* points = (QPolygon*)data(); - if ( points->count() > 1 ) - points->resize( points->count() - 1 ); - onMouse( 0 ); + if (points->count() > 1) + points->resize(points->count() - 1); + onMouse(0); return true; } + else if (aKey == Qt::Key_Space && e->type() == QEvent::KeyRelease) + { + OCCViewer_ViewPort3d* avp = mypViewWindow->getViewPort(); + bool closed = false; + QPolygon* points = (QPolygon*)data(); + bool valid = avp->rect().contains(myCurr); + if (!myStart.isNull()) + { + QRect aRect(myStart.x() - myToler.width(), myStart.y() - myToler.height(), + 2 * myToler.width(), 2 * myToler.height()); + closed = aRect.contains(myCurr); + } + valid = valid && isValid(points, myCurr); + if (closed && !valid) + closed = false; + if (closed) + myResult = Accept; + else + { + if (myStart.isNull()) + myStart = myCurr; + else + { + QPoint last = points->point(points->count() - 1); + if (last != myCurr && valid) + { + points->resize(points->count() + 1); + points->setPoint(points->count() - 1, myCurr); + } + if (valid && myDbl) + myResult = Accept; + } + } + } return true; } @@ -438,27 +478,6 @@ void OCCViewer_PolygonSketcher::onMouse( QMouseEvent* e ) e->globalPos(), e->button(), e->buttons(), e->modifiers() ) ); } - else if ( e->type() == QEvent::MouseButtonRelease && ( e->button() & myAddButton ) ) - { - if ( closed ) - myResult = Accept; - else - { - if ( myStart.isNull() ) - myStart = myCurr; - else - { - QPoint last = points->point( points->count() - 1 ); - if ( last != myCurr && valid ) - { - points->resize( points->count() + 1 ); - points->setPoint( points->count() - 1, myCurr ); - } - if ( valid && myDbl ) - myResult = Accept; - } - } - } else if ( ( e->type() == QEvent::MouseButtonRelease && ( e->button() & myDelButton ) ) || ( e->type() == QEvent::MouseButtonDblClick && ( e->button() & myDelButton ) ) ) { diff --git a/src/OCCViewer/OCCViewer_ViewWindow.cxx b/src/OCCViewer/OCCViewer_ViewWindow.cxx index a5826fd38..e0d26c6a3 100644 --- a/src/OCCViewer/OCCViewer_ViewWindow.cxx +++ b/src/OCCViewer/OCCViewer_ViewWindow.cxx @@ -1012,45 +1012,57 @@ void OCCViewer_ViewWindow::vpMouseMoveEvent( QMouseEvent* theEvent ) aButton == Qt::LeftButton && ( aState == Qt::ControlModifier || aState == ( Qt::ControlModifier|Qt::ShiftModifier ) ) ) ) { myDrawRect = myEnableDrawMode; if ( myDrawRect ) { - drawRect(); - if ( !myCursorIsHand ) { // we are going to sketch a rectangle - QCursor handCursor (Qt::PointingHandCursor); - myCursorIsHand = true; - saveCursor(); - myViewPort->setCursor( handCursor ); + //drawRect(); + //if ( !myCursorIsHand ) { // we are going to sketch a rectangle + // QCursor handCursor (Qt::PointingHandCursor); + // myCursorIsHand = true; + // saveCursor(); + // myViewPort->setCursor( handCursor ); + //} + if (!mypSketcher) { + SelectionStyle aStyle = selectionStyle(); + activateSketching(aStyle == RectStyle ? Rect : Polygon); } - } - emit mouseMoving( this, theEvent ); - } - else if ( ( anInteractionStyle == SUIT_ViewModel::STANDARD && - aButton == Qt::RightButton && ( aState == Qt::NoModifier || Qt::ShiftModifier ) ) || - ( anInteractionStyle == SUIT_ViewModel::KEY_FREE && - aButton == Qt::RightButton && ( aState == Qt::ControlModifier || aState == ( Qt::ControlModifier|Qt::ShiftModifier ) ) ) ) { - OCCViewer_ViewSketcher* sketcher = 0; - QList::Iterator it; - for ( it = mySketchers.begin(); it != mySketchers.end() && !sketcher; ++it ) - { - OCCViewer_ViewSketcher* sk = (*it); - if( sk->isDefault() && sk->sketchButton() == aButton ) - sketcher = sk; - } - if ( sketcher && myCurSketch == -1 ) - { - activateSketching( sketcher->type() ); - if ( mypSketcher ) - { - myCurSketch = mypSketcher->sketchButton(); - - if ( l_mbPressEvent ) - { - QApplication::sendEvent( getViewPort(), l_mbPressEvent ); + if (mypSketcher) { + if (l_mbPressEvent) { + QApplication::sendEvent(getViewPort(), l_mbPressEvent); delete l_mbPressEvent; l_mbPressEvent = 0; } - QApplication::sendEvent( getViewPort(), theEvent ); + QApplication::sendEvent(getViewPort(), theEvent); } } + emit mouseMoving( this, theEvent ); } + //else if ( ( anInteractionStyle == SUIT_ViewModel::STANDARD && + // aButton == Qt::RightButton && ( aState == Qt::NoModifier || Qt::ShiftModifier ) ) || + // ( anInteractionStyle == SUIT_ViewModel::KEY_FREE && + // aButton == Qt::RightButton && ( aState == Qt::ControlModifier || aState == ( Qt::ControlModifier|Qt::ShiftModifier ) ) ) ) { + // OCCViewer_ViewSketcher* sketcher = 0; + // QList::Iterator it; + // for ( it = mySketchers.begin(); it != mySketchers.end() && !sketcher; ++it ) + // { + // OCCViewer_ViewSketcher* sk = (*it); + // if( sk->isDefault() && sk->sketchButton() == aButton ) + // sketcher = sk; + // } + // if ( sketcher && myCurSketch == -1 ) + // { + // activateSketching( sketcher->type() ); + // if ( mypSketcher ) + // { + // myCurSketch = mypSketcher->sketchButton(); + + // if ( l_mbPressEvent ) + // { + // QApplication::sendEvent( getViewPort(), l_mbPressEvent ); + // delete l_mbPressEvent; + // l_mbPressEvent = 0; + // } + // QApplication::sendEvent( getViewPort(), theEvent ); + // } + // } + //} else emit mouseMoving( this, theEvent ); } @@ -1134,8 +1146,7 @@ void OCCViewer_ViewWindow::vpMouseReleaseEvent(QMouseEvent* theEvent) myViewPort->update(); } - if ( l_mbPressEvent ) - { + if ( l_mbPressEvent ) { delete l_mbPressEvent; l_mbPressEvent = 0; } @@ -1178,11 +1189,7 @@ void OCCViewer_ViewWindow::drawRect() { if ( !myRectBand ) { myRectBand = new QtxRectRubberBand( myViewPort ); - //QPalette palette; - //palette.setColor(myRectBand->foregroundRole(), Qt::white); - //myRectBand->setPalette(palette); } - //myRectBand->hide(); myRectBand->setUpdatesEnabled ( false ); QRect aRect = SUIT_Tools::makeRect(myStartX, myStartY, myCurrX, myCurrY); @@ -1192,14 +1199,6 @@ void OCCViewer_ViewWindow::drawRect() myRectBand->show(); myRectBand->setUpdatesEnabled ( true ); - //myRectBand->repaint(); - - //myRectBand->setVisible( aRect.isValid() ); - //if ( myRectBand->isVisible() ) - // myRectBand->repaint(); - //else - // myRectBand->show(); - //myRectBand->repaint(); } /*! @@ -1207,13 +1206,10 @@ void OCCViewer_ViewWindow::drawRect() */ void OCCViewer_ViewWindow::endDrawRect() { - //delete myRectBand; - //myRectBand = 0; - if ( myRectBand ) - { - myRectBand->clearGeometry(); - myRectBand->hide(); - } + if ( myRectBand ) { + myRectBand->clearGeometry(); + myRectBand->hide(); + } } /*! @@ -1488,6 +1484,12 @@ void OCCViewer_ViewWindow::createActions() aAction->setCheckable(true); toolMgr()->registerAction( aAction, RectangleSelectionStyleId); + aAction = new QtxAction(tr("MNU_POLYGON_SELECTION_STYLE"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_POLY_STYLE" ) ), + tr( "MNU_POLYGON_SELECTION_STYLE" ), 0, this); + aAction->setStatusTip(tr("DSC_POLYGON_SELECTION_STYLE")); + aAction->setCheckable(true); + toolMgr()->registerAction( aAction, PolygonSelectionStyleId); + aAction = new QtxAction(tr("MNU_CIRCLE_SELECTION_STYLE"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_CIRCLE_STYLE" ) ), tr( "MNU_CIRCLE_SELECTION_STYLE" ), 0, this); aAction->setStatusTip(tr("DSC_CIRCLE_SELECTION_STYLE")); @@ -1497,6 +1499,7 @@ void OCCViewer_ViewWindow::createActions() // - add exclusive action group QActionGroup* aSelectionGroup = new QActionGroup(this); aSelectionGroup->addAction(toolMgr()->action(RectangleSelectionStyleId)); + aSelectionGroup->addAction(toolMgr()->action(PolygonSelectionStyleId)); aSelectionGroup->addAction(toolMgr()->action(CircleSelectionStyleId)); connect(aSelectionGroup, SIGNAL(triggered(QAction*)), this, SLOT(onSwitchSelectionStyle(QAction*))); @@ -1571,8 +1574,13 @@ void OCCViewer_ViewWindow::createToolBar() toolMgr()->append( SwitchZoomingStyleId, tid ); toolMgr()->append( SwitchPreselectionId, tid ); toolMgr()->append( SwitchSelectionId, tid ); - toolMgr()->append(RectangleSelectionStyleId, tid ); - toolMgr()->append(CircleSelectionStyleId, tid ); + + QtxMultiAction* aSelectionAction = new QtxMultiAction(this); + aSelectionAction->insertAction(toolMgr()->action(RectangleSelectionStyleId)); + aSelectionAction->insertAction(toolMgr()->action(PolygonSelectionStyleId)); + aSelectionAction->insertAction(toolMgr()->action(CircleSelectionStyleId)); + toolMgr()->append(aSelectionAction, tid ); + if( myModel->trihedronActivated() ) toolMgr()->append( TrihedronShowId, tid ); @@ -2230,7 +2238,7 @@ void OCCViewer_ViewWindow::onSwitchSelectionStyle(QAction* theAction) // selection OCCViewer_ViewSketcher* aSkecher = getSketcher(Polygon); if (aSkecher) { - if (theAction == toolMgr()->action(RectangleSelectionStyleId)) { + if (theAction == toolMgr()->action(PolygonSelectionStyleId)) { aSkecher->setSketcherMode(OCCViewer_PolygonSketcher::Poligone); } else if (theAction == toolMgr()->action(CircleSelectionStyleId)) { @@ -2239,28 +2247,32 @@ void OCCViewer_ViewWindow::onSwitchSelectionStyle(QAction* theAction) } } -int OCCViewer_ViewWindow::selectionStyle() const +/*! +Returns currently selected selection style +*/ +OCCViewer_ViewWindow::SelectionStyle OCCViewer_ViewWindow::selectionStyle() const { - OCCViewer_ViewSketcher* aSkecher = getSketcher(Polygon); - if (aSkecher) { - return aSkecher->sketcherMode(); - } - return 0; + if (toolMgr()->action(PolygonSelectionStyleId)->isChecked()) + return PolygonStyle; + if (toolMgr()->action(CircleSelectionStyleId)->isChecked()) + return CyrcleStyle; + return RectStyle; } -void OCCViewer_ViewWindow::setSelectionStyle(int theMode) +void OCCViewer_ViewWindow::setSelectionStyle(SelectionStyle theMode) { - OCCViewer_ViewSketcher* aSkecher = getSketcher(Polygon); - if (aSkecher) { - aSkecher->setSketcherMode(theMode); - if (theMode == 0) { - toolMgr()->action(RectangleSelectionStyleId)->setChecked(true); - toolMgr()->action(CircleSelectionStyleId)->setChecked(false); - } - else { - toolMgr()->action(RectangleSelectionStyleId)->setChecked(false); - toolMgr()->action(CircleSelectionStyleId)->setChecked(true); - } + toolMgr()->action(RectangleSelectionStyleId)->setChecked(false); + toolMgr()->action(PolygonSelectionStyleId)->setChecked(false); + toolMgr()->action(CircleSelectionStyleId)->setChecked(false); + switch (theMode) { + case RectStyle: + toolMgr()->action(RectangleSelectionStyleId)->setChecked(true); + break; + case PolygonStyle: + toolMgr()->action(PolygonSelectionStyleId)->setChecked(true); + break; + case CyrcleStyle: + toolMgr()->action(CircleSelectionStyleId)->setChecked(true); } } @@ -3140,7 +3152,7 @@ void OCCViewer_ViewWindow::onSketchingFinished() if ( mypSketcher && mypSketcher->result() == OCCViewer_ViewSketcher::Accept ) { Handle(AIS_InteractiveContext) ic = myModel->getAISContext(); - bool append = bool( mypSketcher->buttonState() && mypSketcher->isHasShift() ); + bool append = mypSketcher->isHasShift(); switch( mypSketcher->type() ) { case Rect: @@ -3155,9 +3167,9 @@ void OCCViewer_ViewWindow::onSketchingFinished() // myRect = aRect; if( append ) - ic->ShiftSelect( aLeft, aBottom, aRight, aTop, getViewPort()->getView(), Standard_False ); + ic->ShiftSelect( aLeft, aBottom, aRight, aTop, getViewPort()->getView(), Standard_False); else - ic->Select( aLeft, aBottom, aRight, aTop, getViewPort()->getView(), Standard_False ); + ic->Select( aLeft, aBottom, aRight, aTop, getViewPort()->getView(), Standard_False); } } break; @@ -3178,9 +3190,9 @@ void OCCViewer_ViewWindow::onSketchingFinished() } if( append ) - ic->ShiftSelect( anArray, getViewPort()->getView(), Standard_False ); + ic->ShiftSelect( anArray, getViewPort()->getView(), Standard_False); else - ic->Select( anArray, getViewPort()->getView(), Standard_False ); + ic->Select( anArray, getViewPort()->getView(), Standard_False); } } break; diff --git a/src/OCCViewer/OCCViewer_ViewWindow.h b/src/OCCViewer/OCCViewer_ViewWindow.h index ac3967995..4bc47c8f1 100644 --- a/src/OCCViewer/OCCViewer_ViewWindow.h +++ b/src/OCCViewer/OCCViewer_ViewWindow.h @@ -152,7 +152,7 @@ public: SwitchPreselectionId, SwitchSelectionId, MaximizedId, SynchronizeId, ReturnTo3dViewId, OrthographicId, PerspectiveId, StereoId, RayTracingId, EnvTextureId, LightSourceId, - RectangleSelectionStyleId, CircleSelectionStyleId, + RectangleSelectionStyleId, PolygonSelectionStyleId, CircleSelectionStyleId, UserId }; enum OperationType{ NOTHING, PANVIEW, ZOOMVIEW, ROTATE, @@ -164,6 +164,8 @@ public: enum SketchingType { NoSketching, Rect, Polygon }; + enum SelectionStyle { RectStyle, PolygonStyle, CyrcleStyle }; + enum Mode2dType { No2dMode, XYPlane, XZPlane, YZPlane }; enum ProjectionType { Orthographic, Perspective, Stereo }; @@ -220,8 +222,8 @@ public: virtual int projectionType() const; virtual void setProjectionType( int ); - virtual int selectionStyle() const; - virtual void setSelectionStyle(int); + virtual SelectionStyle selectionStyle() const; + virtual void setSelectionStyle(SelectionStyle); virtual int stereoType() const; virtual void setStereoType( const int ); diff --git a/src/OCCViewer/resources/OCCViewer_images.ts b/src/OCCViewer/resources/OCCViewer_images.ts index a9fc35485..465a7b7a7 100644 --- a/src/OCCViewer/resources/OCCViewer_images.ts +++ b/src/OCCViewer/resources/OCCViewer_images.ts @@ -123,6 +123,10 @@ ICON_OCCVIEWER_RECT_STYLE occ_view_rect_style.png + + ICON_OCCVIEWER_POLY_STYLE + occ_view_polygon_style.png + ICON_OCCVIEWER_CIRCLE_STYLE occ_view_circle_style.png diff --git a/src/OCCViewer/resources/OCCViewer_msg_en.ts b/src/OCCViewer/resources/OCCViewer_msg_en.ts index 2f7fd70fe..147711ef3 100644 --- a/src/OCCViewer/resources/OCCViewer_msg_en.ts +++ b/src/OCCViewer/resources/OCCViewer_msg_en.ts @@ -238,19 +238,27 @@ MNU_RECTANGLE_SELECTION_STYLE - Advanced selection by polygon + Selection by rectangle DSC_RECTANGLE_SELECTION_STYLE - Advanced selection by polygon + Selection by rectangle + + + MNU_POLYGON_SELECTION_STYLE + Selection by polygon + + + DSC_POLYGON_SELECTION_STYLE + Selection by polygon MNU_CIRCLE_SELECTION_STYLE - Advanced selection by circle + Selection by circle DSC_CIRCLE_SELECTION_STYLE - Advanced selection by circle + Selection by circle MNU_ENABLE_PRESELECTION diff --git a/src/OCCViewer/resources/OCCViewer_msg_fr.ts b/src/OCCViewer/resources/OCCViewer_msg_fr.ts index 76c7e57b7..0fd0bcd77 100644 --- a/src/OCCViewer/resources/OCCViewer_msg_fr.ts +++ b/src/OCCViewer/resources/OCCViewer_msg_fr.ts @@ -237,19 +237,27 @@ MNU_RECTANGLE_SELECTION_STYLE - Advanced selection by polygon + Sélection par rectangle DSC_RECTANGLE_SELECTION_STYLE - Advanced selection by polygon + Sélection par rectangle + + + MNU_POLYGON_SELECTION_STYLE + La sélection par polygone + + + DSC_POLYGON_SELECTION_STYLE + La sélection par polygone MNU_CIRCLE_SELECTION_STYLE - Advanced selection by circle + Sélection par cercle DSC_CIRCLE_SELECTION_STYLE - Advanced selection by circle + Sélection par cercle MNU_ENABLE_PRESELECTION diff --git a/src/OCCViewer/resources/occ_view_polygon_style.png b/src/OCCViewer/resources/occ_view_polygon_style.png new file mode 100644 index 000000000..acc3bc048 Binary files /dev/null and b/src/OCCViewer/resources/occ_view_polygon_style.png differ diff --git a/src/OCCViewer/resources/occ_view_rect_style.png b/src/OCCViewer/resources/occ_view_rect_style.png index acc3bc048..ff32048e0 100644 Binary files a/src/OCCViewer/resources/occ_view_rect_style.png and b/src/OCCViewer/resources/occ_view_rect_style.png differ