From cb496b285d89ffde627f6a5de34098f3311081ca Mon Sep 17 00:00:00 2001 From: vsv Date: Thu, 19 Mar 2020 16:27:33 +0300 Subject: [PATCH] NewGeom #3097 Improve extended selection in OCC viewer: selection by rectangle, polygon and circle is performed now in the same fashion - with left mouse button --- src/LightApp/LightApp_Application.cxx | 4 +- src/OCCViewer/CMakeLists.txt | 1 + src/OCCViewer/OCCViewer_ViewFrame.cxx | 4 +- src/OCCViewer/OCCViewer_ViewFrame.h | 4 +- src/OCCViewer/OCCViewer_ViewModel.cxx | 72 ++++---- src/OCCViewer/OCCViewer_ViewModel.h | 7 +- src/OCCViewer/OCCViewer_ViewSketcher.cxx | 93 ++++++---- src/OCCViewer/OCCViewer_ViewWindow.cxx | 170 ++++++++++-------- src/OCCViewer/OCCViewer_ViewWindow.h | 8 +- src/OCCViewer/resources/OCCViewer_images.ts | 4 + src/OCCViewer/resources/OCCViewer_msg_en.ts | 16 +- src/OCCViewer/resources/OCCViewer_msg_fr.ts | 16 +- .../resources/occ_view_polygon_style.png | Bin 0 -> 630 bytes .../resources/occ_view_rect_style.png | Bin 630 -> 195 bytes 14 files changed, 229 insertions(+), 170 deletions(-) create mode 100644 src/OCCViewer/resources/occ_view_polygon_style.png 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 0e546e195..9750c695d 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 9387f70d8..4b50176e7 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); } } @@ -3142,7 +3154,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: @@ -3157,9 +3169,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; @@ -3180,9 +3192,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 0000000000000000000000000000000000000000..acc3bc048f4ab4620a53fea177dd53b6193637c9 GIT binary patch literal 630 zcmV-+0*U>JP)N2bZe?^JG%hhNHvLWs=l}o#xJg7oR5(v#`2YVuRWVjU7zP3kY~uJZRzVO30u3Pk z4a9qZxB$e*rVbrr7i3_NU}xvPYhn^I!O1DJRzt&njijW;J)qcApxk^QjsRj2ta>p7 z7#MgsIQUMPnue|@FW;MqjFXb)lvr3q_9!cx?-CVN{KUb*dk(0+9f%!(7#utp26Ax; zZqU+l-iK}&HXIt-Uazn3J%^K%?+DPqzd$U2Vi*u~%gE@SFD%@Whs^+7*vqS|7^wFs z*bF4YGT7O9ZlHSR;_ QcK`qY07*qoM6N<$f|0K7U;qFB literal 0 HcmV?d00001 diff --git a/src/OCCViewer/resources/occ_view_rect_style.png b/src/OCCViewer/resources/occ_view_rect_style.png index acc3bc048f4ab4620a53fea177dd53b6193637c9..ff32048e0d28e2861ff7394ce2c04ae74eaaad49 100644 GIT binary patch delta 143 zcmV;A0C4~I1j7N4Bnkm@Qb$4nuFf3kks%v;5C8xR5CN?ty>$Qp09Z*xK~y+TWBmXB zKLa%Z6O^VJ82ko;!;pi6=f9w!G*pN@@c#W%h95t^FoF$~lvMv8A3r?{Dn}MrxG;0t x^XE4iM_{Ck8b~=9{07n{>roSoxJY4O005GXB^Bi4hgbjr002ovPDHLkV1oW>HdX)t delta 584 zcmV-O0=NCc0rmutB#|)~e-Qux3lRZ-WM7d0000McNliru)d(645d_>_#cKcn03CEi zSad^gZEa<4bO1wgWnpw>WFU8GbZ8({Xk{QrNlj4iWF>9@0000@px9HO+7zRQObpaVlY)r?;&nN@s zC=@f0IbZ=`T9lVJJci8xbZll8)(2ES9YsGf2P^=LEnt?qWMh*s7n>o-SW(gR08o7Z zihg7cT#$i5K82N)aEC0*vw!g+mRDRgirAp8){2 WbagfEL+5t@0000