]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
0021883 [CEA 674] Deactivate pre-selection in OCC and VTK viewer
authorvsr <vsr@opencascade.com>
Fri, 9 Aug 2013 06:11:48 +0000 (06:11 +0000)
committervsr <vsr@opencascade.com>
Fri, 9 Aug 2013 06:11:48 +0000 (06:11 +0000)
0022174 [CEA 793] De-activate entirely selection in order to have a fast view usage

13 files changed:
doc/salome/gui/images/occviewer_toolbar.png
doc/salome/gui/input/occ_3d_viewer.doc
src/OCCViewer/OCCViewer_ViewFrame.cxx
src/OCCViewer/OCCViewer_ViewFrame.h
src/OCCViewer/OCCViewer_ViewModel.cxx
src/OCCViewer/OCCViewer_ViewModel.h
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_preselection.png [new file with mode: 0755]
src/OCCViewer/resources/occ_view_selection.png [new file with mode: 0644]

index 3d8a919923b237188d77f3eeaeeeb4ad99256846..5a16df1760acf3ab06712be44c34fce7c7497ebd 100644 (file)
Binary files a/doc/salome/gui/images/occviewer_toolbar.png and b/doc/salome/gui/images/occviewer_toolbar.png differ
index 4eb31fce691a33ee7fb554f89995ddd68eda6a90..783adee96bcb340f6c88cd82b3255f01eb6f8f35 100644 (file)
@@ -37,6 +37,16 @@ current cursor position) zooming styles.
 <b>Show/Hide Trihedron</b> - shows or hides coordinate axes.
 <hr>
 
+\image html occ_view_preselection.png
+
+<b>Enable/Disable preselection</b> - enables or disables preselection in the view.
+<hr>
+
+\image html occ_view_selection.png
+
+<b>Enable/Disable selection</b> - enables or disables selection in the view.
+<hr>
+
 \image html occ_view_fitall.png
 
 <b>Fit all</b> - allows to select a point to be the center of a scene
index 6e7667829bfacc6d56b6298e62d693cf1e13c6f1..dae1db07ea0604bf3c5c37650d50b57807a5c0e8 100644 (file)
@@ -513,3 +513,17 @@ void OCCViewer_ViewFrame::updateWindowTitle(OCCViewer_ViewWindow* theView)
   if ( !title.isEmpty() )
     theView->setWindowTitle( windowTitle() + " - " + title );
 }
+
+void OCCViewer_ViewFrame::enableSelection( bool isEnabled )
+{
+  foreach (OCCViewer_ViewWindow* aView, myViews) {
+    aView->enableSelection(isEnabled); 
+  }
+}
+
+void OCCViewer_ViewFrame::enablePreselection( bool isEnabled )
+{
+  foreach (OCCViewer_ViewWindow* aView, myViews) {
+    aView->enablePreselection(isEnabled); 
+  }
+}
index 99cfdb064ffa051887d678ba71d666f2ada2f365..35935b630b8541e44a5bd257086f4628125de2a0 100644 (file)
@@ -72,6 +72,12 @@ public:
   virtual int  zoomingStyle() const { return getView(MAIN_VIEW)->zoomingStyle(); }
   virtual void setZoomingStyle( const int );
 
+  virtual bool isSelectionEnabled() const { return getView(MAIN_VIEW)->isSelectionEnabled(); }
+  virtual void enableSelection( bool );
+
+  virtual bool isPreselectionEnabled() const { return getView(MAIN_VIEW)->isPreselectionEnabled(); }
+  virtual void enablePreselection( bool );
+
   virtual void setViewManager( SUIT_ViewManager* );
 
   virtual bool eventFilter(QObject* watched, QEvent* e) { return SUIT_ViewWindow::eventFilter(watched, e); }
index 71f94cbe4db1449d89690ca99af4ade60275d911..b728482f16e32c342b4c361e9ca408cf94221bd2 100755 (executable)
@@ -154,6 +154,9 @@ OCCViewer_Viewer::OCCViewer_Viewer( bool DisplayTrihedron)
   // set zooming style to standard
   myZoomingStyle = 0;
 
+  // preselection
+  myPreselectionEnabled = true;
+
   // selection
   mySelectionEnabled = true;
   myMultiSelectionEnabled = true;
@@ -220,6 +223,8 @@ void OCCViewer_Viewer::initView( OCCViewer_ViewWindow* view )
     view->initSketchers();
     view->setInteractionStyle( interactionStyle() );
     view->setZoomingStyle( zoomingStyle() );
+    view->enablePreselection( isPreselectionEnabled() );
+    view->enableSelection( isSelectionEnabled() );
     
     OCCViewer_ViewPort3d* vp3d = view->getViewPort();
     if ( vp3d )
@@ -288,7 +293,9 @@ void OCCViewer_Viewer::onMouseMove(SUIT_ViewWindow* theWindow, QMouseEvent* theE
 
   OCCViewer_ViewWindow* aView = (OCCViewer_ViewWindow*) theWindow;
 
-  if ( isSelectionEnabled() ) {
+  myCurPnt.setX(theEvent->x()); myCurPnt.setY(theEvent->y());
+
+  if ( isSelectionEnabled() && isPreselectionEnabled() ) {
     if (aView->getViewPort()->isBusy()) {
       QCoreApplication::processEvents();
       return; // Check that the ViewPort initialization completed
@@ -323,6 +330,13 @@ void OCCViewer_Viewer::onMouseRelease(SUIT_ViewWindow* theWindow, QMouseEvent* t
 
   if (myStartPnt == myEndPnt)
   {
+    if ( !isPreselectionEnabled() ) {
+      Handle(V3d_View) aView3d = aView->getViewPort()->getView();
+      if ( !aView3d.IsNull() ) {
+       myAISContext->MoveTo(myEndPnt.x(), myEndPnt.y(), aView3d);
+      }
+    }
+
     if (aHasShift && myMultiSelectionEnabled)
       myAISContext->ShiftSelect();
     else
@@ -370,6 +384,14 @@ void OCCViewer_Viewer::onKeyPress(SUIT_ViewWindow* theWindow, QKeyEvent* theEven
     return;
 
   emit deselection();
+
+  if ( !isPreselectionEnabled() ) {
+    Handle(V3d_View) aView3d = aView->getViewPort()->getView();
+    if ( !aView3d.IsNull() ) {
+      myAISContext->MoveTo(myCurPnt.x(), myCurPnt.y(), aView3d);
+    }
+  }
+
   myAISContext->Select();
 
   emit selectionChanged();
@@ -453,12 +475,50 @@ void OCCViewer_Viewer::setZoomingStyle( const int theStyle )
 }
 
 /*!
-  Sets selection enabled status
+  \return true if preselection is enabled
+*/
+bool OCCViewer_Viewer::isPreselectionEnabled() const 
+{ 
+  return myPreselectionEnabled; 
+}
+
+/*!
+  Enables/disables preselection
+  \param isEnabled - new status
+*/
+void OCCViewer_Viewer::enablePreselection(bool isEnabled)
+{
+  myPreselectionEnabled = isEnabled;
+
+  if ( !myViewManager )
+    return;
+
+  QVector<SUIT_ViewWindow*> wins = myViewManager->getViews();
+  for ( int i = 0; i < (int)wins.count(); i++ )
+  {
+    OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
+    if ( win ) {
+      win->enablePreselection( isEnabled );
+    }
+  }
+}
+
+/*!
+  \return true if selection is enabled
+*/
+bool OCCViewer_Viewer::isSelectionEnabled() const 
+{ 
+  return mySelectionEnabled; 
+}
+
+/*!
+  Enables/disables selection
   \param isEnabled - new status
 */
 void OCCViewer_Viewer::enableSelection(bool isEnabled)
 {
   mySelectionEnabled = isEnabled;
+
   //!! To be done for view windows
   if ( !myViewManager )
     return;
@@ -467,8 +527,10 @@ void OCCViewer_Viewer::enableSelection(bool isEnabled)
   for ( int i = 0; i < (int)wins.count(); i++ )
   {
     OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
-    if ( win )
+    if ( win ) {
       win->updateEnabledDrawMode();
+      win->enableSelection( isEnabled );
+    }
   }
 }
 
@@ -627,12 +689,22 @@ bool OCCViewer_Viewer::highlight( const Handle(AIS_InteractiveObject)& obj,
   Unhilights all objects in viewer
   \param updateviewer - update current viewer
 */
-bool OCCViewer_Viewer::unHighlightAll( bool updateviewer )
+bool OCCViewer_Viewer::unHighlightAll( bool updateviewer, bool unselect )
 {
-  if ( myAISContext->HasOpenedContext() )
-    myAISContext->ClearSelected( updateviewer );
-  else
-    myAISContext->ClearCurrents( updateviewer );
+  if ( myAISContext->HasOpenedContext() ) {
+    if ( unselect ) {
+      myAISContext->ClearSelected( updateviewer );
+    } else {
+      myAISContext->UnhilightSelected( updateviewer );
+    }
+  } else {
+    if ( unselect ) {
+      myAISContext->ClearCurrents( updateviewer );
+    } else {
+      myAISContext->UnhilightCurrents( updateviewer );
+    }
+  }
+
   return false;
 }
 
@@ -924,3 +996,14 @@ void OCCViewer_Viewer::updateTrihedron() {
     myTrihedron->SetSize(myTrihedronSize);
   }
 }
+
+/*!
+  Set number of isolines
+  \param u - u-isolines (first parametric co-ordinate)
+  \param v - v-isolines (second parametric co-ordinate)
+*/
+void OCCViewer_Viewer::setSelectionOptions( bool isPreselectionEnabled, bool isSelectionEnabled )
+{
+  myPreselectionEnabled = isPreselectionEnabled;
+  mySelectionEnabled = isSelectionEnabled;
+}
index 456ddfcbfa0d3c24c1254fb1269af68a6e12ae02..1ad1ddd4f6043acc5649c781fdc053ff709c8eb5 100755 (executable)
@@ -129,8 +129,13 @@ public:
   int                             zoomingStyle() const;
   void                            setZoomingStyle( const int );
 
+  void                            enablePreselection(bool isEnabled);
+  bool                            isPreselectionEnabled() const;
+  
   void                            enableSelection(bool isEnabled);
-  bool                            isSelectionEnabled() const { return mySelectionEnabled; }
+  bool                            isSelectionEnabled() const;
+
+  void                            setSelectionOptions( bool, bool );
 
   void                            enableMultiselection(bool isEnable);
   bool                            isMultiSelectionEnabled() const { return myMultiSelectionEnabled; }
@@ -142,7 +147,7 @@ public:
 
   /* Selection management */
   bool    highlight( const Handle(AIS_InteractiveObject)&, bool, bool=true );
-  bool    unHighlightAll( bool=true ); 
+  bool    unHighlightAll( bool=true, bool=true ); 
   bool    isInViewer( const Handle(AIS_InteractiveObject)&, bool=false );
   bool    isVisible( const Handle(AIS_InteractiveObject)& );
 
@@ -178,6 +183,7 @@ protected:
   int                             myInteractionStyle;
   int                             myZoomingStyle;
 
+  bool                            myPreselectionEnabled;
   bool                            mySelectionEnabled;
   bool                            myMultiSelectionEnabled;
   bool                            myIsRelative;
@@ -185,7 +191,7 @@ protected:
   int                             myTopLayerId;
 
   //QColor                          myBgColor;
-  QPoint                          myStartPnt, myEndPnt;
+  QPoint                          myStartPnt, myEndPnt, myCurPnt;
 
   bool                            myShowStaticTrihedron;
 
index 8b3340dbd9a3b6cb4a53249d3f5842a227ee717a..9fb1b26198429fd0d4f7b6c6daf3d453d7fb9f35 100755 (executable)
@@ -237,6 +237,9 @@ OCCViewer_ViewWindow::OCCViewer_ViewWindow( SUIT_Desktop*     theDesktop,
   my2dMode = No2dMode;
 
   myInteractionStyle = SUIT_ViewModel::STANDARD;
+  myPreselectionEnabled = true;
+  mySelectionEnabled = true;
+
 
   clearViewAspects();
   
@@ -1236,6 +1239,22 @@ void OCCViewer_ViewWindow::createActions()
   connect(aAction, SIGNAL(triggered()), this, SLOT(onAxialScale()));
   toolMgr()->registerAction( aAction, AxialScaleId );
 
+  // Enable/disable preselection
+  aAction = new QtxAction(tr("MNU_ENABLE_PRESELECTION"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_PRESELECTION" ) ),
+                          tr( "MNU_ENABLE_PRESELECTION" ), 0, this);
+  aAction->setStatusTip(tr("DSC_ENABLE_PRESELECTION"));
+  aAction->setCheckable(true);
+  connect(aAction, SIGNAL(toggled(bool)), this, SLOT(onSwitchPreselection(bool)));
+  toolMgr()->registerAction( aAction, SwitchPreselectionId );
+
+  // Enable/disable selection
+  aAction = new QtxAction(tr("MNU_ENABLE_SELECTION"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_SELECTION" ) ),
+                          tr( "MNU_ENABLE_SELECTION" ), 0, this);
+  aAction->setStatusTip(tr("DSC_ENABLE_SELECTION"));
+  aAction->setCheckable(true);
+  connect(aAction, SIGNAL(toggled(bool)), this, SLOT(onSwitchSelection(bool)));
+  toolMgr()->registerAction( aAction, SwitchSelectionId );
+
   // Graduated axes 
   aAction = new QtxAction(tr("MNU_GRADUATED_AXES"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_GRADUATED_AXES" ) ),
                            tr( "MNU_GRADUATED_AXES" ), 0, this);
@@ -1304,6 +1323,8 @@ void OCCViewer_ViewWindow::createToolBar()
 #if OCC_VERSION_LARGE > 0x0603000A // available only with OCC-6.3-sp11 and higher version
   toolMgr()->append( SwitchZoomingStyleId, tid );
 #endif
+  toolMgr()->append( SwitchPreselectionId, tid );
+  toolMgr()->append( SwitchSelectionId, tid );
   if( myModel->trihedronActivated() )
     toolMgr()->append( TrihedronShowId, tid );
 
@@ -1719,6 +1740,49 @@ void OCCViewer_ViewWindow::onTrihedronShow()
   myModel->toggleTrihedron();
 }
 
+/*!
+  \brief Toggles preselection (highlighting) on/off
+*/
+void OCCViewer_ViewWindow::onSwitchPreselection( bool on )
+{
+  myPreselectionEnabled = on;
+  myModel->setSelectionOptions( isPreselectionEnabled(), myModel->isSelectionEnabled() );
+
+  // unhighlight all highlighted objects
+  /*if ( !on ) {
+    myModel->unHighlightAll( true, false );
+  }*/
+
+  // update action state if method is called outside
+  QtxAction* a = dynamic_cast<QtxAction*>( toolMgr()->action( SwitchPreselectionId ) );
+  if ( a && a->isChecked() != on ) {
+    a->setChecked( on );
+  }
+}
+
+/*!
+  \brief Toggles selection on/off
+*/
+void OCCViewer_ViewWindow::onSwitchSelection( bool on )
+{
+  mySelectionEnabled = on;
+  myModel->setSelectionOptions( myModel->isPreselectionEnabled(), isSelectionEnabled() );
+  
+  // update action state if method is called outside
+
+  // preselection
+  QtxAction* a = dynamic_cast<QtxAction*>( toolMgr()->action( SwitchPreselectionId ) );
+  if ( a ) {
+    a->setEnabled( on );
+  }
+
+  // selection
+  a = dynamic_cast<QtxAction*>( toolMgr()->action( SwitchSelectionId ) );
+  if ( a && a->isChecked() != on ) {
+    a->setChecked( on );
+  }
+}
+
 /*!
   \brief Switches "keyboard free" interaction style on/off
 */
@@ -2693,3 +2757,39 @@ void OCCViewer_ViewWindow::synchronize( SUIT_ViewWindow* theView )
 
   blockSignals( blocked );
 }
+
+/*!
+  \brief Indicates whether preselection is enabled
+  \return true if preselection is enabled
+*/
+bool OCCViewer_ViewWindow::isPreselectionEnabled() const
+{
+  return myPreselectionEnabled;
+}
+
+/*!
+  \brief Enables/disables preselection
+  \param theIsToEnable if true - preselection will be enabled
+*/
+void OCCViewer_ViewWindow::enablePreselection( bool theIsToEnable )
+{
+  onSwitchPreselection( theIsToEnable );
+}
+
+/*!
+  \brief Indicates whether selection is enabled
+  \return true if selection is enabled
+*/
+bool OCCViewer_ViewWindow::isSelectionEnabled() const
+{
+  return mySelectionEnabled;
+}
+
+/*!
+  \brief Enables/disables selection
+  \param theIsToEnable if true - selection will be enabled
+*/
+void OCCViewer_ViewWindow::enableSelection( bool theIsToEnable )
+{
+  onSwitchSelection( theIsToEnable );
+}
index a445b5a86e668b3b0f60f32f1d3609bac2cdb32f..a203a2bf2fd3e3d6e887ec80211026edf1dfc55f 100755 (executable)
@@ -121,7 +121,10 @@ public:
          FrontId, BackId, TopId, BottomId, LeftId, RightId, ClockWiseId, AntiClockWiseId,
         ResetId, CloneId, ClippingId, MemId, RestoreId,
          TrihedronShowId, AxialScaleId, GraduatedAxesId, AmbientId,
-        SwitchInteractionStyleId, SwitchZoomingStyleId, MaximizedId, SynchronizeId, UserId };
+        SwitchInteractionStyleId, SwitchZoomingStyleId, 
+        SwitchPreselectionId, SwitchSelectionId,
+        MaximizedId, SynchronizeId,
+        UserId };
 
   enum OperationType{ NOTHING, PANVIEW, ZOOMVIEW, ROTATE, 
                       PANGLOBAL, WINDOWFIT, FITALLVIEW, RESETVIEW,
@@ -170,6 +173,11 @@ public:
  
   virtual int                     zoomingStyle() const;
   virtual void                    setZoomingStyle( const int );
+
+  virtual bool                    isPreselectionEnabled() const;
+  virtual void                    enablePreselection( bool );   
+  virtual bool                    isSelectionEnabled() const;
+  virtual void                    enableSelection( bool );
  
   void setTransformEnabled( const OperationType, const bool );
   bool transformEnabled( const OperationType ) const;
@@ -226,6 +234,8 @@ public slots:
   virtual void setRestoreFlag();
   virtual void onSwitchInteractionStyle( bool on );
   virtual void onSwitchZoomingStyle( bool on );
+  virtual void onSwitchPreselection( bool on );
+  virtual void onSwitchSelection( bool on );
 
   virtual void activateSetRotationGravity();
   virtual void activateSetRotationSelected( double theX, double theY, double theZ );
@@ -332,6 +342,8 @@ private:
 
   QtxRectRubberBand* myRectBand; //!< selection rectangle rubber band
 
+  bool mySelectionEnabled;
+  bool myPreselectionEnabled;
   int myInteractionStyle;
 
   typedef QMap<OperationType, bool> MapOfTransformStatus;
index 40bb075112c5cb4bdc789dc2005573086f1c920c..98804e2c7fbc561108427ae59ac6ce2164aeebdc 100644 (file)
         <source>ICON_OCCVIEWER_MINIMIZE</source>
         <translation>occ_view_minimized.png</translation>
     </message>
+    <message>
+        <source>ICON_OCCVIEWER_PRESELECTION</source>
+        <translation>occ_view_preselection.png</translation>
+    </message>
+    <message>
+        <source>ICON_OCCVIEWER_SELECTION</source>
+        <translation>occ_view_selection.png</translation>
+    </message>
 </context>
 </TS>
index e505ec1ab6bd647767b67c6b36eb0c7a4f94d32a..d9d1f0d99104746f081fbe8267be045c9fb739f1 100644 (file)
         <source>MNU_ZOOMING_STYLE_SWITCH</source>
         <translation>Zooming style switch</translation>
     </message>
+    <message>
+        <source>DSC_ENABLE_PRESELECTION</source>
+        <translation>Enable/disable preselection</translation>
+    </message>
+    <message>
+        <source>MNU_ENABLE_PRESELECTION</source>
+        <translation>Enable/disable preselection</translation>
+    </message>
+    <message>
+        <source>DSC_ENABLE_SELECTION</source>
+        <translation>Enable/disable selection</translation>
+    </message>
+    <message>
+        <source>MNU_ENABLE_SELECTION</source>
+        <translation>Enable/disable selection</translation>
+    </message>
     <message>
         <source>OCC_IMAGE_FILES</source>
         <translation>Images Files (*.bmp *.png *.jpg *.jpeg *.eps *.ps)</translation>
index 74b9bfeb30cb7fe835985a1c3838f681a50e88d3..0f09189f07806a8537cd547327721859e8933ba3 100755 (executable)
         <source>MNU_ZOOMING_STYLE_SWITCH</source>
         <translation>Changer le style de zoom</translation>
     </message>
+    <message>
+        <source>DSC_ENABLE_PRESELECTION</source>
+        <translation type="unfinished">Enable/disable preselection</translation>
+    </message>
+    <message>
+        <source>MNU_ENABLE_PRESELECTION</source>
+        <translation type="unfinished">Enable/disable preselection</translation>
+    </message>
+    <message>
+        <source>DSC_ENABLE_SELECTION</source>
+        <translation type="unfinished">Enable/disable selection</translation>
+    </message>
+    <message>
+        <source>MNU_ENABLE_SELECTION</source>
+        <translation type="unfinished">Enable/disable selection</translation>
+    </message>
     <message>
         <source>OCC_IMAGE_FILES</source>
         <translation>Fichiers images (*.bmp *.png *.jpg *.jpeg *.eps *.ps)</translation>
diff --git a/src/OCCViewer/resources/occ_view_preselection.png b/src/OCCViewer/resources/occ_view_preselection.png
new file mode 100755 (executable)
index 0000000..cd5baec
Binary files /dev/null and b/src/OCCViewer/resources/occ_view_preselection.png differ
diff --git a/src/OCCViewer/resources/occ_view_selection.png b/src/OCCViewer/resources/occ_view_selection.png
new file mode 100644 (file)
index 0000000..21d18e9
Binary files /dev/null and b/src/OCCViewer/resources/occ_view_selection.png differ