From ab3ff92cc07c89d7f665268f6e7db79568c02958 Mon Sep 17 00:00:00 2001 From: vro Date: Wed, 29 Nov 2017 16:36:21 +0300 Subject: [PATCH] 0029353: Optimization of TPrsStd_AISPresentation::SetSelectionMode() --- src/TPrsStd/TPrsStd_AISPresentation.cxx | 74 ++++++++++++++----------- src/TPrsStd/TPrsStd_AISPresentation.hxx | 4 ++ 2 files changed, 47 insertions(+), 31 deletions(-) diff --git a/src/TPrsStd/TPrsStd_AISPresentation.cxx b/src/TPrsStd/TPrsStd_AISPresentation.cxx index f108b71594..cc8d75f530 100644 --- a/src/TPrsStd/TPrsStd_AISPresentation.cxx +++ b/src/TPrsStd/TPrsStd_AISPresentation.cxx @@ -595,7 +595,11 @@ void TPrsStd_AISPresentation::SetSelectionMode(const Standard_Integer theSelecti { Backup(); getData()->SetSelectionMode (theSelectionMode); - AISUpdate(); + + if ( myAIS.IsNull() ) + AISUpdate(); + else + ActivateSelectionMode(); } //======================================================================= @@ -871,36 +875,7 @@ void TPrsStd_AISPresentation::AISUpdate() myAIS->SetDisplayMode(aMode); } - if ( !aContext.IsNull() && IsDisplayed() ) - aContext->Redisplay(myAIS, Standard_False); - - if (HasOwnSelectionMode()) { - if (!aContext.IsNull()) - { - TColStd_ListOfInteger anActivatedModes; - aContext->ActivatedModes (myAIS, anActivatedModes); - Standard_Boolean isActivated = Standard_False; - Standard_Integer aSelectionMode = SelectionMode(); - if (aSelectionMode == -1) - { - aContext->Deactivate(myAIS); - } - else - { - for (TColStd_ListIteratorOfListOfInteger aModeIter (anActivatedModes); aModeIter.More(); aModeIter.Next()) - { - if (aModeIter.Value() == aSelectionMode) - { - isActivated = Standard_True; - break; - } - } - if (!isActivated) - aContext->Activate (myAIS, aSelectionMode, Standard_False); - } - } - } - + ActivateSelectionMode(); } if (IsDisplayed() && !aContext.IsNull()) @@ -1013,3 +988,40 @@ Handle(AIS_InteractiveContext) TPrsStd_AISPresentation::getAISContext() const return Handle_AIS_InteractiveContext(); } + +//======================================================================= +//function : ActivateSelectionMode +//purpose : Activates selection mode of the interactive object. +// It is called internally on change of selection mode and AISUpdate(). +//======================================================================= +void TPrsStd_AISPresentation::ActivateSelectionMode() +{ + if (!myAIS.IsNull() && HasOwnSelectionMode()) + { + Handle(AIS_InteractiveContext) aContext = getAISContext(); + if (!aContext.IsNull()) + { + TColStd_ListOfInteger anActivatedModes; + aContext->ActivatedModes (myAIS, anActivatedModes); + Standard_Boolean isActivated = Standard_False; + Standard_Integer aSelectionMode = SelectionMode(); + if (aSelectionMode == -1) + { + aContext->Deactivate(myAIS); + } + else + { + for (TColStd_ListIteratorOfListOfInteger aModeIter (anActivatedModes); aModeIter.More(); aModeIter.Next()) + { + if (aModeIter.Value() == aSelectionMode) + { + isActivated = Standard_True; + break; + } + } + if (!isActivated) + aContext->Activate (myAIS, aSelectionMode, Standard_False); + } + } + } +} diff --git a/src/TPrsStd/TPrsStd_AISPresentation.hxx b/src/TPrsStd/TPrsStd_AISPresentation.hxx index 672ff5f9b4..e72b75982c 100644 --- a/src/TPrsStd/TPrsStd_AISPresentation.hxx +++ b/src/TPrsStd/TPrsStd_AISPresentation.hxx @@ -197,6 +197,10 @@ protected: private: Handle(AIS_InteractiveContext) getAISContext() const; + + //! Activates selection mode of the interactive object. + //! It is called internally on change of selection mode and AISUpdate(). + void ActivateSelectionMode(); //! Updates AIS_InteractiveObject stored in the attribute //! and applies the visualization settings -- 2.20.1