From: ana Date: Wed, 19 Nov 2014 12:29:52 +0000 (+0300) Subject: 0022765: [EDF] Improvement of local selection mechanism X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2Fana%2F22765;p=modules%2Fgui.git 0022765: [EDF] Improvement of local selection mechanism First step --- diff --git a/src/OCCViewer/OCCViewer_ViewWindow.cxx b/src/OCCViewer/OCCViewer_ViewWindow.cxx index 4f38b4110..f23e4975b 100755 --- a/src/OCCViewer/OCCViewer_ViewWindow.cxx +++ b/src/OCCViewer/OCCViewer_ViewWindow.cxx @@ -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; diff --git a/src/Prs/SALOME_Prs.cxx b/src/Prs/SALOME_Prs.cxx index 871a4ca84..480f43195 100755 --- a/src/Prs/SALOME_Prs.cxx +++ b/src/Prs/SALOME_Prs.cxx @@ -25,6 +25,13 @@ #include "SALOME_Prs.h" +/*! + Dispatches operation of activation of sub-shapes selection +*/ +void SALOME_Prs::LocalSelectionIn( SALOME_View*, const std::list ) const +{ +} + /*! Dispatches display operation to proper Display() method of SALOME_View */ @@ -73,12 +80,22 @@ void SALOME_OCCPrs::AfterEraseIn( SALOME_Displayer* d, SALOME_View* v ) const d->AfterErase( v, this ); } +/*! + Dispatches operation to proper LocalSelectionIn() method of SALOME_View +*/ +void SALOME_OCCPrs::LocalSelectionIn( SALOME_View* v, const std::list modes ) const +{ + if ( v && !modes.empty() ) v->LocalSelection( this, modes ); +} + /*! Dispatches operation to proper LocalSelectionIn() method of SALOME_View */ void SALOME_OCCPrs::LocalSelectionIn( SALOME_View* v, const int mode ) const { - if ( v ) v->LocalSelection( this, mode ); + std::list modes; + modes.push_back( mode ); + LocalSelectionIn( v, modes ); } /*! @@ -233,12 +250,22 @@ void SALOME_View::Erase( const SALOME_Prs* prs, const bool forced ) prs->EraseIn( this, forced ); } +/*! + Gives control to SALOME_Prs object, so that it could perform double dispatch +*/ +void SALOME_View::LocalSelection( const SALOME_Prs* prs, const std::list modes ) +{ + prs->LocalSelectionIn( this, modes ); +} + /*! Gives control to SALOME_Prs object, so that it could perform double dispatch */ void SALOME_View::LocalSelection( const SALOME_Prs* prs, const int mode ) { - prs->LocalSelectionIn( this, mode ); + std::list modes; + modes.push_back( mode ); + LocalSelection( prs, modes ); } /*! @@ -297,6 +324,15 @@ void SALOME_View::EraseAll( const bool ) // MESSAGE( "SALOME_View::EraseAll() called!" ); } +/*! + 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 ) +{ +// 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. */ diff --git a/src/Prs/SALOME_Prs.h b/src/Prs/SALOME_Prs.h index ebef97acd..4ca2ec00c 100755 --- a/src/Prs/SALOME_Prs.h +++ b/src/Prs/SALOME_Prs.h @@ -33,6 +33,8 @@ #define PRS_EXPORT #endif +#include + class SALOME_View; class SALOME_Displayer; class SALOME_ListIO; @@ -79,6 +81,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 ) const; // checks if shape is clippable inline bool IsClippable() const @@ -135,6 +138,7 @@ public: virtual void Update( SALOME_Displayer* ); //! Key method for double dispatch of activation of sub-shapes selection + virtual void LocalSelectionIn( SALOME_View*, const std::list ) const; virtual void LocalSelectionIn( SALOME_View*, const int ) const; }; @@ -243,6 +247,7 @@ public: //! This LocalSelection() method should be called to activate sub-shapes selection //! 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 std::list ); void LocalSelection( const SALOME_Prs*, const int ); // Interface for derived views @@ -261,9 +266,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 std::list );//!< Local selection of different types of entities SALOME_OCCPrs + 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 //! Deactivates selection of sub-shapes (must be redefined with OCC viewer) virtual void GlobalSelection( const bool = false ) const; diff --git a/src/SOCC/SOCC_ViewModel.cxx b/src/SOCC/SOCC_ViewModel.cxx index 985d1fed7..ae68073e7 100755 --- a/src/SOCC/SOCC_ViewModel.cxx +++ b/src/SOCC/SOCC_ViewModel.cxx @@ -549,7 +549,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 modes ) { Handle(AIS_InteractiveContext) ic = getAISContext(); @@ -577,20 +577,33 @@ void SOCC_Viewer::LocalSelection( const SALOME_OCCPrs* thePrs, const int theMode Handle(AIS_InteractiveObject) anAIS = aIter.Value(); if ( !anAIS.IsNull() ) { + std::list::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 modes; + modes.push_back( theMode ); + LocalSelection( thePrs, modes ); +} + /*! Deactivates selection of sub-shapes */ diff --git a/src/SOCC/SOCC_ViewModel.h b/src/SOCC/SOCC_ViewModel.h index e46e0bfe1..c53d37148 100755 --- a/src/SOCC/SOCC_ViewModel.h +++ b/src/SOCC/SOCC_ViewModel.h @@ -31,6 +31,8 @@ #include "SALOME_Prs.h" #include "OCCViewer_ViewModel.h" +#include + class SALOME_ListIO; class Handle(SALOME_InteractiveObject); @@ -61,6 +63,7 @@ public: virtual void EraseAll( const bool = false ); virtual SALOME_Prs* CreatePrs( const char* entry = 0 ); + virtual void LocalSelection( const SALOME_OCCPrs*, const std::list ); virtual void LocalSelection( const SALOME_OCCPrs*, const int ); virtual void GlobalSelection( const bool = false ) const; virtual bool isVisible( const Handle(SALOME_InteractiveObject)& );