From e288b183a1226d18bd9c7817226407737d2b45d1 Mon Sep 17 00:00:00 2001 From: mpv Date: Thu, 1 Jun 2017 13:19:31 +0300 Subject: [PATCH] Workaround for the problem that the local selection may be initialized without opening local context since OCCT 7.0. --- src/OCCViewer/OCCViewer_ViewModel.cxx | 26 ++++++++++++++++++++++++-- src/OCCViewer/OCCViewer_ViewModel.h | 5 ++++- src/OCCViewer/OCCViewer_ViewWindow.cxx | 2 +- 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/src/OCCViewer/OCCViewer_ViewModel.cxx b/src/OCCViewer/OCCViewer_ViewModel.cxx index 3285f015e..0b0ce6a97 100644 --- a/src/OCCViewer/OCCViewer_ViewModel.cxx +++ b/src/OCCViewer/OCCViewer_ViewModel.cxx @@ -120,7 +120,8 @@ OCCViewer_Viewer::OCCViewer_Viewer( bool DisplayTrihedron) myIsRelative(true), myTopLayerId( 0 ), myTrihedronSize(100), - myClippingDlg (NULL) + myClippingDlg (NULL), + myIsUseLocalSelection(false) { // init CasCade viewers myV3dViewer = OCCViewer_VService::CreateViewer( TCollection_ExtendedString("Viewer3d").ToExtString() ); @@ -454,7 +455,7 @@ void OCCViewer_Viewer::onKeyPress(SUIT_ViewWindow* theWindow, QKeyEvent* theEven break; case Qt::Key_N: if ( isPreselectionEnabled() ) { - if ( getAISContext()->HasOpenedContext() ) + if ( useLocalSelection() ) getAISContext()->HilightNextDetected( aView->getViewPort()->getView() ); } break; @@ -1355,6 +1356,27 @@ OCCViewer_ViewWindow* OCCViewer_Viewer::createSubWindow() return new OCCViewer_ViewWindow(0, this); } +/*! + Sets using local selection state + \param theIsUseLocalSelection - state +*/ +void OCCViewer_Viewer::setUseLocalSelection(bool theIsUseLocalSelection) +{ + myIsUseLocalSelection = theIsUseLocalSelection; +} + +/* + * Returns true if local context is opened or view model local state is set + */ +bool OCCViewer_Viewer::useLocalSelection() const +{ + if (myIsUseLocalSelection) + return true; + + Handle(AIS_InteractiveContext) ic = getAISContext(); + return !ic.IsNull() && ic->HasOpenedContext(); +} + // obsolete QColor OCCViewer_Viewer::backgroundColor( int theViewId ) const { diff --git a/src/OCCViewer/OCCViewer_ViewModel.h b/src/OCCViewer/OCCViewer_ViewModel.h index 63db7700b..329bb05bd 100755 --- a/src/OCCViewer/OCCViewer_ViewModel.h +++ b/src/OCCViewer/OCCViewer_ViewModel.h @@ -132,6 +132,9 @@ public: virtual OCCViewer_ViewWindow* createSubWindow(); + void setUseLocalSelection(bool theIsUseLocalSelection); + bool useLocalSelection() const; + public: Handle(V3d_Viewer) getViewer3d() const { return myV3dViewer;} Handle(AIS_InteractiveContext) getAISContext() const { return myAISContext; } @@ -279,7 +282,7 @@ protected: QString myClippingTexture; bool myTextureModulated; double myClippingTextureScale; - + bool myIsUseLocalSelection; }; #ifdef WIN32 diff --git a/src/OCCViewer/OCCViewer_ViewWindow.cxx b/src/OCCViewer/OCCViewer_ViewWindow.cxx index a4bce4220..b7d38eab4 100644 --- a/src/OCCViewer/OCCViewer_ViewWindow.cxx +++ b/src/OCCViewer/OCCViewer_ViewWindow.cxx @@ -393,7 +393,7 @@ bool OCCViewer_ViewWindow::eventFilter( QObject* watched, QEvent* e ) if ( aEvent->modifiers().testFlag(Qt::ControlModifier) ) { Handle(AIS_InteractiveContext) ic = myModel->getAISContext(); - if ( isPreselectionEnabled() && ic->HasOpenedContext() ) { + if ( isPreselectionEnabled() && myModel->useLocalSelection() ) { if ( aEvent->delta() > 0 ) { ic->HilightNextDetected( myViewPort->getView() ); } else { -- 2.39.2