Salome HOME
0022765: [EDF] Improvement of local selection mechanism
authorana <ana@opencascade.com>
Wed, 19 Nov 2014 12:29:52 +0000 (15:29 +0300)
committervsr <vsr@opencascade.com>
Sat, 22 Nov 2014 08:22:40 +0000 (11:22 +0300)
src/OCCViewer/OCCViewer_ViewWindow.cxx
src/Prs/SALOME_Prs.cxx
src/Prs/SALOME_Prs.h
src/SOCC/SOCC_ViewModel.cxx
src/SOCC/SOCC_ViewModel.h

index 2fa68a577e0317016ab4664bc643cc620fffe8b3..5b6558aa5dab7cdb4bd4264b4eada485b63918cb 100755 (executable)
@@ -363,14 +363,26 @@ bool OCCViewer_ViewWindow::eventFilter( QObject* watched, QEvent* e )
     case QEvent::Wheel:
       {
         QWheelEvent* aEvent = (QWheelEvent*) e;
-  myViewPort->startZoomAtPoint( aEvent->x(), aEvent->y() );
-  double delta = (double)( aEvent->delta() ) / ( 15 * 8 );
-  int x  = aEvent->x();
-  int y  = aEvent->y();
-  int x1 = (int)( aEvent->x() + width()*delta/100 );
-  int y1 = (int)( aEvent->y() + height()*delta/100 );
-  myViewPort->zoom( x, y, x1, y1 );
-  myViewPort->getView()->ZFitAll();
+     
+        if ( aEvent->modifiers().testFlag(Qt::ControlModifier) ) {
+          Handle(AIS_InteractiveContext) ic = myModel->getAISContext();
+          if ( ic->HasOpenedContext() ) {
+            if ( aEvent->delta() > 0 ) {
+              ic->HilightNextDetected( myViewPort->getView() );
+            } else {
+              ic->HilightPreviousDetected( myViewPort->getView() );
+            }
+          }
+        } else {
+          myViewPort->startZoomAtPoint( aEvent->x(), aEvent->y() );
+          double delta = (double)( aEvent->delta() ) / ( 15 * 8 );
+          int x  = aEvent->x();
+          int y  = aEvent->y();
+          int x1 = (int)( aEvent->x() + width()*delta/100 );
+          int y1 = (int)( aEvent->y() + height()*delta/100 );
+          myViewPort->zoom( x, y, x1, y1 );
+          myViewPort->getView()->ZFitAll();
+        }
       }
       return true;
 
index 8f952cda876b8b5181f2d87f5646f1300db8c1e9..45960968bb6467973a94b9f536392d23c1762645 100755 (executable)
@@ -41,6 +41,14 @@ const char* SALOME_Prs::GetEntry() const
   return myEntry.c_str();
 }
 
+/*!
+  Dispatches operation of activation of sub-shapes selection
+*/
+void SALOME_Prs::LocalSelectionIn( SALOME_View*, const std::list<int> ) const
+{
+  // base implementation does nothing
+}
+
 /*!
   Dispatches display operation to proper Display() method of SALOME_View
 */
@@ -94,7 +102,17 @@ void SALOME_OCCPrs::AfterEraseIn( SALOME_Displayer* d, SALOME_View* v ) const
 */
 void SALOME_OCCPrs::LocalSelectionIn( SALOME_View* v, const int mode ) const
 {
-  if ( v ) v->LocalSelection( this, mode );
+  std::list<int> modes;
+  modes.push_back( mode );
+  LocalSelectionIn( v, modes );
+}
+
+/*!
+  Dispatches operation to proper LocalSelectionIn() method of SALOME_View
+*/
+void SALOME_OCCPrs::LocalSelectionIn( SALOME_View* v, const std::list<int> modes ) const
+{
+  if ( v && !modes.empty() ) v->LocalSelection( this, modes );
 }
 
 /*!
@@ -256,7 +274,17 @@ void SALOME_View::Erase( SALOME_Displayer* d, const SALOME_Prs* prs, const bool
 */
 void SALOME_View::LocalSelection( const SALOME_Prs* prs, const int mode )
 {
-  prs->LocalSelectionIn( this, mode );
+  std::list<int> modes;
+  modes.push_back( mode );
+  LocalSelection( prs, modes );
+}
+
+/*!
+  Gives control to SALOME_Prs object, so that it could perform double dispatch
+*/
+void SALOME_View::LocalSelection( const SALOME_Prs* prs, const std::list<int> modes )
+{
+  prs->LocalSelectionIn( this, modes );
 }
 
 /*!
@@ -325,6 +353,15 @@ void SALOME_View::LocalSelection( const SALOME_OCCPrs*, const int )
 //   Probably, selection is being activated in uncompatible viewframe." );
 }
 
+/*!
+  Virtual method, should be reimplemented in successors, by default issues a warning and does nothing.
+*/
+void SALOME_View::LocalSelection( const SALOME_OCCPrs*, const std::list<int> )
+{
+//  MESSAGE( "SALOME_View::LocalSelection( const SALOME_OCCPrs* ) called!
+//   Probably, selection is being activated in uncompatible viewframe." );
+}
+
 /*!
   Virtual method, should be reimplemented in successors, by default issues a warning and does nothing.
 */
index bb7b5243aca36cc936e837cf56265f22bb52654a..0bab968abee2398d9e0800a3c3caeaa6aab15077 100755 (executable)
@@ -39,6 +39,7 @@ class SALOME_ListIO;
 class Handle_SALOME_InteractiveObject;
 
 #include <string>
+#include <list>
 
 /*!
  \class SALOME_Prs
@@ -84,6 +85,7 @@ public:
 
   //! Key method for double dispatch of activation of sub-shapes selection
   virtual void LocalSelectionIn( SALOME_View*, const int ) const = 0;
+  virtual void LocalSelectionIn( SALOME_View*, const std::list<int> ) const;
 
     // checks if shape is clippable
   inline bool IsClippable() const
@@ -144,6 +146,7 @@ public:
 
   //! Key method for double dispatch of activation of sub-shapes selection
   virtual void LocalSelectionIn( SALOME_View*, const int ) const;
+  virtual void LocalSelectionIn( SALOME_View*, const std::list<int> ) const;
 };
 
 /*!
@@ -262,6 +265,7 @@ public:
   //! created anywhere by anybody. It simply passes control to SALOME_Prs object
   //! so that it could perform double dispatch.
   void LocalSelection( const SALOME_Prs*, const int );
+  void LocalSelection( const SALOME_Prs*, const std::list<int> );
 
   // Interface for derived views
 
@@ -278,9 +282,10 @@ public:
   // Add new Erase() methods here...
 
   // LocalSelection() methods for ALL kinds of presentation should appear here
-  virtual void LocalSelection( const SALOME_OCCPrs*, const int );//!< Local selection SALOME_OCCPrs
-  virtual void LocalSelection( const SALOME_VTKPrs*, const int );//!< Local selection SALOME_VTKPrs
-  virtual void LocalSelection( const SALOME_Prs2d* , const int );//!< Local selection SALOME_Prs2d
+  virtual void LocalSelection( const SALOME_OCCPrs*, const int );           //!< Local selection SALOME_OCCPrs
+  virtual void LocalSelection( const SALOME_OCCPrs*, const std::list<int> );//!< Multiple local selection SALOME_OCCPrs
+  virtual void LocalSelection( const SALOME_VTKPrs*, const int );           //!< Local selection SALOME_VTKPrs
+  virtual void LocalSelection( const SALOME_Prs2d* , const int );           //!< Local selection SALOME_Prs2d
 
   //! Deactivates selection of sub-shapes (must be redefined with OCC viewer)
   virtual void GlobalSelection( const bool = false ) const;
index 69f17119d1c3d06aad73f9a8c54152b49e9e01ed..224e2de7662a29adf2f07d3d093718865bfeb50d 100755 (executable)
@@ -550,7 +550,7 @@ SALOME_Prs* SOCC_Viewer::CreatePrs( const char* entry )
 /*!
   Activates selection of sub-shapes
 */
-void SOCC_Viewer::LocalSelection( const SALOME_OCCPrs* thePrs, const int theMode )
+void SOCC_Viewer::LocalSelection( const SALOME_OCCPrs* thePrs, const std::list<int> modes )
 {
   Handle(AIS_InteractiveContext) ic = getAISContext();
   
@@ -578,20 +578,33 @@ void SOCC_Viewer::LocalSelection( const SALOME_OCCPrs* thePrs, const int theMode
     Handle(AIS_InteractiveObject) anAIS = aIter.Value();
     if ( !anAIS.IsNull() )
     {
+      std::list<int>::const_iterator it;
       if ( anAIS->IsKind( STANDARD_TYPE( AIS_Shape ) ) )
       {
         ic->Load( anAIS, -1, false );
-        ic->Activate( anAIS, AIS_Shape::SelectionMode( (TopAbs_ShapeEnum)theMode ) );
+        for( it = modes.begin(); it != modes.end(); ++it )
+          ic->Activate( anAIS, AIS_Shape::SelectionMode( (TopAbs_ShapeEnum)*it ) );
       }
       else if ( anAIS->DynamicType() != STANDARD_TYPE(AIS_Trihedron) )
       {
         ic->Load( anAIS, -1, false );
-        ic->Activate( anAIS, theMode );
+        for( it = modes.begin(); it != modes.end(); ++it )
+          ic->Activate( anAIS, *it );
       }
     }
   }
 }
 
+/*!
+  Activates selection of sub-shapes
+*/
+void SOCC_Viewer::LocalSelection( const SALOME_OCCPrs* thePrs, const int theMode )
+{
+  std::list<int> modes;
+  modes.push_back( theMode );
+  LocalSelection( thePrs, modes );
+}
+
 /*!
   Deactivates selection of sub-shapes
 */
index 9206e7109f53f447e93ed1c406a58f5f8efa0748..00fad4bf8c146a20a91f84e33e9672a15de098ac 100755 (executable)
@@ -62,6 +62,7 @@ public:
   virtual SALOME_Prs*         CreatePrs( const char* entry = 0 );
 
   virtual void                LocalSelection( const SALOME_OCCPrs*, const int );
+  virtual void                LocalSelection( const SALOME_OCCPrs*, const std::list<int> );
   virtual void                GlobalSelection( const bool = false ) const;
   virtual bool                isVisible( const Handle(SALOME_InteractiveObject)& );
   virtual void                GetVisible( SALOME_ListIO& );