]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
Improve selection mode according to request #3097 in NewGeom redmine vsv/improve_selection_mode
authorvsv <vsv@opencascade.com>
Thu, 19 Mar 2020 13:27:33 +0000 (16:27 +0300)
committervsv <vsv@opencascade.com>
Thu, 19 Mar 2020 13:27:33 +0000 (16:27 +0300)
15 files changed:
CMakeLists.txt
src/LightApp/LightApp_Application.cxx
src/OCCViewer/CMakeLists.txt
src/OCCViewer/OCCViewer_ViewFrame.cxx
src/OCCViewer/OCCViewer_ViewFrame.h
src/OCCViewer/OCCViewer_ViewModel.cxx
src/OCCViewer/OCCViewer_ViewModel.h
src/OCCViewer/OCCViewer_ViewSketcher.cxx
src/OCCViewer/OCCViewer_ViewWindow.cxx
src/OCCViewer/OCCViewer_ViewWindow.h
src/OCCViewer/resources/OCCViewer_images.ts
src/OCCViewer/resources/OCCViewer_msg_en.ts
src/OCCViewer/resources/OCCViewer_msg_fr.ts
src/OCCViewer/resources/occ_view_polygon_style.png [new file with mode: 0644]
src/OCCViewer/resources/occ_view_rect_style.png

index 9575399f7e930f90b5d7b87e56a6decb91273034..dfc8dad169e444aeb44a86fbfc24fe31bccb9300 100644 (file)
@@ -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)
index ba73f8d245b6fb3036c2430a13c18a735bca234f..10cca2c578fa0242da27f6c9101701a0d58a0821 100644 (file)
@@ -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
index 5590a5c29ebb6f19a42717423bac909256928cc6..aff671dd4208c120d89696545fde43c3cfc68d1b 100644 (file)
@@ -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
 )
 
index 91e39769e8a6951ca1b8a54e32e24a3dbaa01b41..2e5dbef84424a537cd976fc9c26b2ffbdac88b11 100644 (file)
@@ -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);
index 755afb5ea83b5057b05e20fa9e9d1ce656163738..9b8ca0da81c25ea2f077e15c01f390e9bc835ecd 100644 (file)
@@ -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 );
index 0acca6fc514813cef08c138401a88ce96d6ab95c..8efceb215cfc4d497e875d905465da920a5f01bc 100644 (file)
@@ -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 <AIS_Axis.hxx>
 #include <Prs3d_Drawer.hxx>
 #include <AIS_ListIteratorOfListOfInteractive.hxx>
+#include <StdSelect_ViewerSelector3d.hxx>
 
 #include <Graphic3d_Texture2Dmanual.hxx>
 #include <Graphic3d_MaterialAspect.hxx>
@@ -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;
index dddf9d11a5827136d76986e47232042ec0afd52c..b5b4171dcad1a3472d5a727d5ddfb4bf387785ec 100644 (file)
@@ -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;
index 676a13e7e49fd90357fc5657d98ad2e5baef7286..d2441027d366746d1fdf8d7b605cb0c1db89e9a5 100644 (file)
@@ -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 ) ) )
   {
index a5826fd381ee26b4690b145fe8ec9ced2e3dd2fb..e0d26c6a3cd0d408e4df56b77345350ec769b01e 100644 (file)
@@ -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<OCCViewer_ViewSketcher*>::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<OCCViewer_ViewSketcher*>::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;
index ac3967995d4df28481492ac188fae6cef84e49ff..4bc47c8f11a7fecae6044dc2c134c5d50101a993 100644 (file)
@@ -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 );
index a9fc35485bd0472d1e3e44269405255f6214cf0d..465a7b7a790657a14949302d0b1c3e7c5bd47332 100644 (file)
         <source>ICON_OCCVIEWER_RECT_STYLE</source>
         <translation>occ_view_rect_style.png</translation>
     </message>
+    <message>
+        <source>ICON_OCCVIEWER_POLY_STYLE</source>
+        <translation>occ_view_polygon_style.png</translation>
+    </message>
     <message>
         <source>ICON_OCCVIEWER_CIRCLE_STYLE</source>
         <translation>occ_view_circle_style.png</translation>
index 2f7fd70fec5fc8d611f921d83b442b8ba69c860f..147711ef3a9a759527548fa761156cc79513610b 100644 (file)
     </message>
     <message>
         <source>MNU_RECTANGLE_SELECTION_STYLE</source>
-        <translation>Advanced selection by polygon</translation>
+        <translation>Selection by rectangle</translation>
     </message>
     <message>
         <source>DSC_RECTANGLE_SELECTION_STYLE</source>
-        <translation>Advanced selection by polygon</translation>
+        <translation>Selection by rectangle</translation>
+    </message>
+    <message>
+        <source>MNU_POLYGON_SELECTION_STYLE</source>
+        <translation>Selection by polygon</translation>
+    </message>
+    <message>
+        <source>DSC_POLYGON_SELECTION_STYLE</source>
+        <translation>Selection by polygon</translation>
     </message>
     <message>
         <source>MNU_CIRCLE_SELECTION_STYLE</source>
-        <translation>Advanced selection by circle</translation>
+        <translation>Selection by circle</translation>
     </message>
     <message>
         <source>DSC_CIRCLE_SELECTION_STYLE</source>
-        <translation>Advanced selection by circle</translation>
+        <translation>Selection by circle</translation>
     </message>
     <message>
         <source>MNU_ENABLE_PRESELECTION</source>
index 76c7e57b7eeb0459ba66b288f2f1ef0a0fdbedd9..0fd0bcd77cca5821c968de5f4b6f0c63cdf70ac9 100644 (file)
     </message>
     <message>
         <source>MNU_RECTANGLE_SELECTION_STYLE</source>
-        <translation>Advanced selection by polygon</translation>
+        <translation>Sélection par rectangle</translation>
     </message>
     <message>
         <source>DSC_RECTANGLE_SELECTION_STYLE</source>
-        <translation>Advanced selection by polygon</translation>
+        <translation>Sélection par rectangle</translation>
+    </message>
+    <message>
+        <source>MNU_POLYGON_SELECTION_STYLE</source>
+        <translation>La sélection par polygone</translation>
+    </message>
+    <message>
+        <source>DSC_POLYGON_SELECTION_STYLE</source>
+        <translation>La sélection par polygone</translation>
     </message>
     <message>
         <source>MNU_CIRCLE_SELECTION_STYLE</source>
-        <translation>Advanced selection by circle</translation>
+        <translation>Sélection par cercle</translation>
     </message>
     <message>
         <source>DSC_CIRCLE_SELECTION_STYLE</source>
-        <translation>Advanced selection by circle</translation>
+        <translation>Sélection par cercle</translation>
     </message>
     <message>
         <source>MNU_ENABLE_PRESELECTION</source>
diff --git a/src/OCCViewer/resources/occ_view_polygon_style.png b/src/OCCViewer/resources/occ_view_polygon_style.png
new file mode 100644 (file)
index 0000000..acc3bc0
Binary files /dev/null and b/src/OCCViewer/resources/occ_view_polygon_style.png differ
index acc3bc048f4ab4620a53fea177dd53b6193637c9..ff32048e0d28e2861ff7394ce2c04ae74eaaad49 100644 (file)
Binary files a/src/OCCViewer/resources/occ_view_rect_style.png and b/src/OCCViewer/resources/occ_view_rect_style.png differ