1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-03 17:56:21 +03:00

0029353: Optimization of TPrsStd_AISPresentation::SetSelectionMode()

This commit is contained in:
vro 2017-11-29 16:36:21 +03:00 committed by bugmaster
parent 992ed6b3c0
commit ab3ff92cc0
2 changed files with 47 additions and 31 deletions

View File

@ -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);
}
}
}
}

View File

@ -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