From: vsv Date: Tue, 21 Apr 2020 12:52:27 +0000 (+0300) Subject: bos #18968 [CEA] Sometimes when clicking to add a face to a group two faces are added X-Git-Tag: V9_5_0b1~4 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b77aad4cd3966476063b49699b31f59d7731ba72;p=modules%2Fgui.git bos #18968 [CEA] Sometimes when clicking to add a face to a group two faces are added - Revert previously implemented workaroud --- diff --git a/src/OCCViewer/OCCViewer.cxx b/src/OCCViewer/OCCViewer.cxx index ffd136941..7fbf45cc2 100644 --- a/src/OCCViewer/OCCViewer.cxx +++ b/src/OCCViewer/OCCViewer.cxx @@ -45,14 +45,3 @@ QColor OCCViewer::color( const Quantity_Color& c ) int( c.Green() * 255 ), int( c.Blue() * 255 ) ); } - -/*! - \brief Check if size of given rectagle exceeds threshold value for mouse events. - \param rect Given rectangle - \return Result of comparison -*/ -bool OCCViewer::overThreshold( const QRect& rect ) -{ - const int threshold = 3; - return qMin( rect.height(), rect.width() ) >= threshold; -} diff --git a/src/OCCViewer/OCCViewer.h b/src/OCCViewer/OCCViewer.h index ff801bea7..173a7a1c8 100644 --- a/src/OCCViewer/OCCViewer.h +++ b/src/OCCViewer/OCCViewer.h @@ -40,13 +40,11 @@ #include #include -#include namespace OCCViewer { OCCVIEWER_EXPORT Quantity_Color color( const QColor& ); OCCVIEWER_EXPORT QColor color( const Quantity_Color& ); - OCCVIEWER_EXPORT bool overThreshold( const QRect& ); }; #endif //OCCVIEWER_H diff --git a/src/OCCViewer/OCCViewer_ViewModel.cxx b/src/OCCViewer/OCCViewer_ViewModel.cxx index b12f6b6c6..eb7ff1564 100644 --- a/src/OCCViewer/OCCViewer_ViewModel.cxx +++ b/src/OCCViewer/OCCViewer_ViewModel.cxx @@ -130,8 +130,7 @@ OCCViewer_Viewer::OCCViewer_Viewer( bool DisplayTrihedron) myIsUseLocalSelection(false), #endif myClippingDlg (NULL), - myFitter(0), - mySelectionDone(false) + myFitter(0) { // init CasCade viewers myV3dViewer = OCCViewer_VService::CreateViewer( TCollection_ExtendedString("Viewer3d").ToExtString() ); @@ -143,10 +142,6 @@ OCCViewer_Viewer::OCCViewer_Viewer( bool DisplayTrihedron) 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 ); @@ -378,8 +373,7 @@ void OCCViewer_Viewer::onMouseRelease(SUIT_ViewWindow* theWindow, QMouseEvent* t myEndPnt.setX(theEvent->x()); myEndPnt.setY(theEvent->y()); bool aHasShift = (theEvent->modifiers() & Qt::ShiftModifier); - // In case of small tremor of a mouse pointer, consider it as a click - if ( !OCCViewer::overThreshold( QRect( myStartPnt, myEndPnt ) ) && !mySelectionDone) + if (myStartPnt == myEndPnt) { if (!aHasShift) { myAISContext->ClearCurrents( false ); @@ -398,7 +392,6 @@ void OCCViewer_Viewer::onMouseRelease(SUIT_ViewWindow* theWindow, QMouseEvent* t myAISContext->Select( Standard_True ); emit selectionChanged(); } - mySelectionDone = false; //else //{ diff --git a/src/OCCViewer/OCCViewer_ViewModel.h b/src/OCCViewer/OCCViewer_ViewModel.h index 114ae093e..4bb4533b5 100644 --- a/src/OCCViewer/OCCViewer_ViewModel.h +++ b/src/OCCViewer/OCCViewer_ViewModel.h @@ -260,9 +260,6 @@ public: void initView( OCCViewer_ViewWindow* view ); - /// Sets a flag to ignore mouse release for selection. Used for Rectangle/Polygon selection - void doNotSelect() { mySelectionDone = true; } - signals: void selectionChanged(); void deselection(); @@ -329,7 +326,6 @@ protected: #endif OCCViewer_Fitter* myFitter; - bool mySelectionDone; }; #ifdef WIN32 diff --git a/src/OCCViewer/OCCViewer_ViewWindow.cxx b/src/OCCViewer/OCCViewer_ViewWindow.cxx index 4da72e376..a7a0bab06 100644 --- a/src/OCCViewer/OCCViewer_ViewWindow.cxx +++ b/src/OCCViewer/OCCViewer_ViewWindow.cxx @@ -3160,9 +3160,7 @@ void OCCViewer_ViewWindow::onSketchingFinished() case Rect: { QRect* aRect = (QRect*)mypSketcher->data(); - // Use rectangle selection only if the rect has a reasonable size - // If it is too small then it is very probably tremor of a mouse pointer - if ( aRect && OCCViewer::overThreshold( *aRect ) ) + if ( aRect ) { int aLeft = aRect->left(); int aRight = aRect->right(); @@ -3182,24 +3180,21 @@ void OCCViewer_ViewWindow::onSketchingFinished() QPolygon* aPolygon = (QPolygon*)mypSketcher->data(); if( aPolygon ) { - QRect aRect = aPolygon->boundingRect(); - if ( OCCViewer::overThreshold( aRect ) ) { - int size = aPolygon->size(); - TColgp_Array1OfPnt2d anArray(1, size); - - QPolygon::Iterator it = aPolygon->begin(); - QPolygon::Iterator itEnd = aPolygon->end(); - for (int index = 1; it != itEnd; ++it, index++) - { - QPoint aPoint = *it; - anArray.SetValue(index, gp_Pnt2d(aPoint.x(), aPoint.y())); - } + int size = aPolygon->size(); + TColgp_Array1OfPnt2d anArray(1, size); - if (append) - ic->ShiftSelect(anArray, getViewPort()->getView(), Standard_False); - else - ic->Select(anArray, getViewPort()->getView(), Standard_False); + QPolygon::Iterator it = aPolygon->begin(); + QPolygon::Iterator itEnd = aPolygon->end(); + for (int index = 1; it != itEnd; ++it, index++) + { + QPoint aPoint = *it; + anArray.SetValue(index, gp_Pnt2d(aPoint.x(), aPoint.y())); } + + if (append) + ic->ShiftSelect(anArray, getViewPort()->getView(), Standard_False); + else + ic->Select(anArray, getViewPort()->getView(), Standard_False); } } break; @@ -3209,7 +3204,6 @@ void OCCViewer_ViewWindow::onSketchingFinished() OCCViewer_ViewManager* aViewMgr = ( OCCViewer_ViewManager* )getViewManager(); aViewMgr->getOCCViewer()->performSelectionChanged(); - aViewMgr->getOCCViewer()->doNotSelect(); } }