]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
bos #18968 [CEA] Sometimes when clicking to add a face to a group two faces are added
authorvsv <vsv@opencascade.com>
Tue, 21 Apr 2020 12:52:27 +0000 (15:52 +0300)
committervsr <vsr@opencascade.com>
Tue, 21 Apr 2020 14:31:32 +0000 (17:31 +0300)
- Revert previously implemented workaroud

src/OCCViewer/OCCViewer.cxx
src/OCCViewer/OCCViewer.h
src/OCCViewer/OCCViewer_ViewModel.cxx
src/OCCViewer/OCCViewer_ViewModel.h
src/OCCViewer/OCCViewer_ViewWindow.cxx

index ffd136941e6c4eee04281d1e110b850ba11bef31..7fbf45cc270e583e78cdb98b95e1246a743190a1 100644 (file)
@@ -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;
-}
index ff801bea71cb8119b8103f6ab0878bb363d4a068..173a7a1c8056c269f748bf7c697df1de10a923e6 100644 (file)
 #include <Quantity_Color.hxx>
 
 #include <QColor>
-#include <QRect>
 
 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
index b12f6b6c62bd861c56af46aa4292a27e23b02a6a..eb7ff1564746fbd1d0a4dcbc30827d83f24ee52a 100644 (file)
@@ -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
   //{
index 114ae093e7d8bef2598dddfed6ea01e2acc0b502..4bb4533b5dcda39137ac348b5395e7cbcab1d48b 100644 (file)
@@ -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
index 4da72e37683333e5a3d7e49e104a100b6eb3fe7b..a7a0bab06defbb336e2394f8e4384b017aebce51 100644 (file)
@@ -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();
   }
 }