From 81233137a689a48edb1b080cffcaaa39048a598d Mon Sep 17 00:00:00 2001 From: ana Date: Wed, 19 Nov 2014 15:29:52 +0300 Subject: [PATCH] 0022765: [EDF] Improvement of local selection mechanism --- src/OCCViewer/OCCViewer_ViewWindow.cxx | 28 +++++++++++++----- src/Prs/SALOME_Prs.cxx | 41 ++++++++++++++++++++++++-- src/Prs/SALOME_Prs.h | 11 +++++-- src/SOCC/SOCC_ViewModel.cxx | 19 ++++++++++-- src/SOCC/SOCC_ViewModel.h | 1 + 5 files changed, 84 insertions(+), 16 deletions(-) diff --git a/src/OCCViewer/OCCViewer_ViewWindow.cxx b/src/OCCViewer/OCCViewer_ViewWindow.cxx index 2fa68a577..5b6558aa5 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 8f952cda8..45960968b 100755 --- a/src/Prs/SALOME_Prs.cxx +++ b/src/Prs/SALOME_Prs.cxx @@ -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 ) 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 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 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 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 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 ) +{ +// 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 bb7b5243a..0bab968ab 100755 --- a/src/Prs/SALOME_Prs.h +++ b/src/Prs/SALOME_Prs.h @@ -39,6 +39,7 @@ class SALOME_ListIO; class Handle_SALOME_InteractiveObject; #include +#include /*! \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 ) 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 ) 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 ); // 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 );//!< 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; diff --git a/src/SOCC/SOCC_ViewModel.cxx b/src/SOCC/SOCC_ViewModel.cxx index 69f17119d..224e2de76 100755 --- a/src/SOCC/SOCC_ViewModel.cxx +++ b/src/SOCC/SOCC_ViewModel.cxx @@ -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 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::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 9206e7109..00fad4bf8 100755 --- a/src/SOCC/SOCC_ViewModel.h +++ b/src/SOCC/SOCC_ViewModel.h @@ -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 ); virtual void GlobalSelection( const bool = false ) const; virtual bool isVisible( const Handle(SALOME_InteractiveObject)& ); virtual void GetVisible( SALOME_ListIO& ); -- 2.39.2