1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-14 13:30:48 +03:00

0030124: Visualization, AIS_InteractiveObject - clean up confusing Presentation invalidation logic

Removed excess mechanism for invalidating presentations AIS_InteractiveObject::myRecomputeEveryPrs.
PrsMgr_PresentableObject::Update() has been deprecated and replaced by PrsMgr_PresentableObject::UpdatePresentations()
recomputing only explicitly invalidated presentations.
This commit is contained in:
mnv
2019-03-07 20:45:58 +03:00
committed by apn
parent ac8f17746b
commit 226fce20f0
28 changed files with 454 additions and 487 deletions

View File

@@ -115,80 +115,101 @@ void PrsMgr_PresentableObject::Compute(const Handle(Prs3d_Projector)& /* aProjec
}
//=======================================================================
//function : Update
//purpose :
//=======================================================================
void PrsMgr_PresentableObject::Update (const Standard_Boolean AllModes) {
Standard_Integer l = myPresentations.Length();
Handle(PrsMgr_PresentationManager) PM;
for (Standard_Integer i=1; i <= l; i++) {
PM = myPresentations(i).Presentation()->PresentationManager();
if(AllModes)
PM->Update(this,myPresentations(i).Mode());
else{
if(PM->IsDisplayed(this,myPresentations(i).Mode()) ||
PM->IsHighlighted(this,myPresentations(i).Mode())){
PM->Update(this,myPresentations(i).Mode());
}
else
SetToUpdate(myPresentations(i).Mode());
}
}
}
//=======================================================================
//function : Update
//purpose :
//=======================================================================
void PrsMgr_PresentableObject::Update (const Standard_Integer aMode, const Standard_Boolean ClearOther) {
Standard_Integer l = myPresentations.Length();
for (Standard_Integer i=1; i <= l; i++) {
if( myPresentations(i).Mode() == aMode){
Handle(PrsMgr_PresentationManager) PM=
myPresentations(i).Presentation()->PresentationManager();
if(PM->IsDisplayed(this,aMode) ||
PM->IsHighlighted(this,aMode)){
PM->Update(this,aMode);
myPresentations(i).Presentation()->SetUpdateStatus(Standard_False);
}
else
SetToUpdate(myPresentations(i).Mode());
}
}
if(ClearOther) {
PrsMgr_Presentations save;
save = myPresentations;
myPresentations.Clear();
for (Standard_Integer i=1; i <= l; i++) {
if( save(i).Mode() == aMode) myPresentations.Append(save(i));
}
}
}
//=======================================================================
//function : SetToUpdate
//purpose :
//=======================================================================
void PrsMgr_PresentableObject::SetToUpdate(const Standard_Integer aMode)
{
for(Standard_Integer IP =1; IP<=myPresentations.Length();IP++){
if(myPresentations(IP).Mode()==aMode)
myPresentations(IP).Presentation()->SetUpdateStatus(Standard_True);
}
}
//=======================================================================
//function : SetToUpdate
//function : ToBeUpdated
//purpose :
//=======================================================================
void PrsMgr_PresentableObject::SetToUpdate()
Standard_Boolean PrsMgr_PresentableObject::ToBeUpdated (Standard_Boolean theToIncludeHidden) const
{
for(Standard_Integer IP =1; IP<=myPresentations.Length();IP++){
myPresentations(IP).Presentation()->SetUpdateStatus(Standard_True);
for (PrsMgr_Presentations::Iterator aPrsIter (myPresentations); aPrsIter.More(); aPrsIter.Next())
{
const PrsMgr_ModedPresentation& aModedPrs = aPrsIter.Value();
if (aModedPrs.Presentation()->MustBeUpdated())
{
if (theToIncludeHidden)
{
return Standard_True;
}
Handle(PrsMgr_PresentationManager) aPrsMgr = aModedPrs.Presentation()->PresentationManager();
if (aPrsMgr->IsDisplayed (this, aModedPrs.Mode())
|| aPrsMgr->IsHighlighted(this, aModedPrs.Mode()))
{
return Standard_True;
}
}
}
return Standard_False;
}
//=======================================================================
//function : UpdatePresentations
//purpose :
//=======================================================================
Standard_Boolean PrsMgr_PresentableObject::UpdatePresentations (Standard_Boolean theToIncludeHidden)
{
Standard_Boolean hasUpdates = Standard_False;
for (PrsMgr_Presentations::Iterator aPrsIter (myPresentations); aPrsIter.More(); aPrsIter.Next())
{
const PrsMgr_ModedPresentation& aModedPrs = aPrsIter.Value();
if (aModedPrs.Presentation()->MustBeUpdated())
{
Handle(PrsMgr_PresentationManager) aPrsMgr = aModedPrs.Presentation()->PresentationManager();
if (theToIncludeHidden
|| aPrsMgr->IsDisplayed (this, aModedPrs.Mode())
|| aPrsMgr->IsHighlighted(this, aModedPrs.Mode()))
{
hasUpdates = Standard_True;
aPrsMgr->Update (this, aModedPrs.Mode());
}
}
}
return hasUpdates;
}
//=======================================================================
//function : Update
//purpose :
//=======================================================================
void PrsMgr_PresentableObject::Update (Standard_Integer theMode, Standard_Boolean theToClearOther)
{
for (PrsMgr_Presentations::Iterator aPrsIter (myPresentations); aPrsIter.More();)
{
if (aPrsIter.Value().Mode() == theMode)
{
Handle(PrsMgr_PresentationManager) aPrsMgr = aPrsIter.Value().Presentation()->PresentationManager();
if (aPrsMgr->IsDisplayed (this, theMode)
|| aPrsMgr->IsHighlighted(this, theMode))
{
aPrsMgr->Update (this, theMode);
aPrsIter.Value().Presentation()->SetUpdateStatus (Standard_False);
}
else
{
SetToUpdate (aPrsIter.Value().Mode());
}
}
else if (theToClearOther)
{
myPresentations.Remove (aPrsIter);
continue;
}
aPrsIter.Next();
}
}
//=======================================================================
//function : SetToUpdate
//purpose :
//=======================================================================
void PrsMgr_PresentableObject::SetToUpdate (Standard_Integer theMode)
{
for (PrsMgr_Presentations::Iterator aPrsIter (myPresentations); aPrsIter.More(); aPrsIter.Next())
{
if (theMode == -1
|| aPrsIter.Value().Mode() == theMode)
{
aPrsIter.ChangeValue().Presentation()->SetUpdateStatus(Standard_True);
}
}
}
@@ -196,19 +217,18 @@ void PrsMgr_PresentableObject::SetToUpdate()
//function : ToBeUpdated
//purpose : gets the list of modes to be updated
//=======================================================================
void PrsMgr_PresentableObject::ToBeUpdated(TColStd_ListOfInteger& OutList) const
void PrsMgr_PresentableObject::ToBeUpdated (TColStd_ListOfInteger& theOutList) const
{
OutList.Clear();
// on dimensionne les buckets a la taille de la seq.
theOutList.Clear();
TColStd_MapOfInteger MI(myPresentations.Length());
for(Standard_Integer IP =1; IP<=myPresentations.Length();IP++){
const PrsMgr_ModedPresentation& MP = myPresentations(IP);
if(MP.Presentation()->MustBeUpdated())
if(!MI.Contains(MP.Mode())){
OutList.Append(MP.Mode());
MI.Add(MP.Mode());
}
for (PrsMgr_Presentations::Iterator aPrsIter (myPresentations); aPrsIter.More(); aPrsIter.Next())
{
const PrsMgr_ModedPresentation& aModedPrs = aPrsIter.Value();
if (aModedPrs.Presentation()->MustBeUpdated()
&& MI.Add (aModedPrs.Mode()))
{
theOutList.Append (aModedPrs.Mode());
}
}
}
@@ -219,9 +239,9 @@ void PrsMgr_PresentableObject::ToBeUpdated(TColStd_ListOfInteger& OutList) const
void PrsMgr_PresentableObject::SetTypeOfPresentation (const PrsMgr_TypeOfPresentation3d theType)
{
myTypeOfPresentation3d = theType;
for(Standard_Integer aPrsIter = 1; aPrsIter <= myPresentations.Length(); ++aPrsIter)
for (PrsMgr_Presentations::Iterator aPrsIter (myPresentations); aPrsIter.More(); aPrsIter.Next())
{
const Handle(PrsMgr_Presentation)& aPrs = myPresentations (aPrsIter).Presentation();
const Handle(PrsMgr_Presentation)& aPrs = aPrsIter.Value().Presentation();
aPrs->Presentation()->SetVisual (myTypeOfPresentation3d == PrsMgr_TOP_ProjectorDependant
? Graphic3d_TOS_COMPUTED
: Graphic3d_TOS_ALL);
@@ -285,9 +305,9 @@ void PrsMgr_PresentableObject::UpdateTransformation()
myInvTransformation = myLocalTransformation->Trsf().Inverted();
}
for (Standard_Integer aPrsIter = 1; aPrsIter <= myPresentations.Length(); ++aPrsIter)
for (PrsMgr_Presentations::Iterator aPrsIter (myPresentations); aPrsIter.More(); aPrsIter.Next())
{
myPresentations (aPrsIter).Presentation()->SetTransformation (myTransformation);
aPrsIter.ChangeValue().Presentation()->SetTransformation (myTransformation);
}
for (PrsMgr_ListOfPresentableObjectsIter aChildIter (myChildren); aChildIter.More(); aChildIter.Next())
@@ -302,9 +322,9 @@ void PrsMgr_PresentableObject::UpdateTransformation()
//=======================================================================
void PrsMgr_PresentableObject::recomputeComputed() const
{
for (Standard_Integer aPrsIter = 1; aPrsIter <= myPresentations.Length(); ++aPrsIter)
for (PrsMgr_Presentations::Iterator aPrsIter (myPresentations); aPrsIter.More(); aPrsIter.Next())
{
const Handle(PrsMgr_Presentation)& aPrs3d = myPresentations (aPrsIter).Presentation();
const Handle(PrsMgr_Presentation)& aPrs3d = aPrsIter.Value().Presentation();
if (!aPrs3d.IsNull()
&& !aPrs3d->Presentation().IsNull())
{
@@ -320,9 +340,9 @@ void PrsMgr_PresentableObject::recomputeComputed() const
void PrsMgr_PresentableObject::SetTransformPersistence (const Handle(Graphic3d_TransformPers)& theTrsfPers)
{
myTransformPersistence = theTrsfPers;
for (Standard_Integer aPrsIter = 1; aPrsIter <= myPresentations.Length(); ++aPrsIter)
for (PrsMgr_Presentations::Iterator aPrsIter (myPresentations); aPrsIter.More(); aPrsIter.Next())
{
const Handle(PrsMgr_Presentation)& aPrs3d = myPresentations (aPrsIter).Presentation();
const Handle(PrsMgr_Presentation)& aPrs3d = aPrsIter.Value().Presentation();
if (!aPrs3d.IsNull()
&& !aPrs3d->Presentation().IsNull())
{
@@ -422,9 +442,9 @@ void PrsMgr_PresentableObject::SetZLayer (const Graphic3d_ZLayerId theLayerId)
}
myDrawer->SetZLayer (theLayerId);
for (Standard_Integer aPrsIter = 1; aPrsIter <= myPresentations.Length(); ++aPrsIter)
for (PrsMgr_Presentations::Iterator aPrsIter (myPresentations); aPrsIter.More(); aPrsIter.Next())
{
const PrsMgr_ModedPresentation& aModedPrs = myPresentations (aPrsIter);
const PrsMgr_ModedPresentation& aModedPrs = aPrsIter.Value();
if (aModedPrs.Presentation().IsNull()
|| aModedPrs.Presentation()->Presentation().IsNull())
{
@@ -501,19 +521,14 @@ void PrsMgr_PresentableObject::SetClipPlanes (const Handle(Graphic3d_SequenceOfH
// =======================================================================
void PrsMgr_PresentableObject::UpdateClipping()
{
// affect generated structures
for (Standard_Integer aPrsIt = 1; aPrsIt <= myPresentations.Length(); ++aPrsIt)
for (PrsMgr_Presentations::Iterator aPrsIter (myPresentations); aPrsIter.More(); aPrsIter.Next())
{
// pass over presentation manager 3d mechanism right to the structures -
// we do not interested in display mode collections.
const PrsMgr_ModedPresentation& aModedPrs = myPresentations (aPrsIt);
if (aModedPrs.Presentation().IsNull()
|| aModedPrs.Presentation()->Presentation().IsNull())
const PrsMgr_ModedPresentation& aModedPrs = aPrsIter.Value();
if (!aModedPrs.Presentation().IsNull()
&& !aModedPrs.Presentation()->Presentation().IsNull())
{
continue;
aModedPrs.Presentation()->Presentation()->SetClipPlanes (myClipPlanes);
}
aModedPrs.Presentation()->Presentation()->SetClipPlanes (myClipPlanes);
}
}
@@ -529,16 +544,14 @@ void PrsMgr_PresentableObject::SetMutable (const Standard_Boolean theIsMutable)
}
myIsMutable = theIsMutable;
for (Standard_Integer aPrsIter = 1; aPrsIter <= myPresentations.Length(); ++aPrsIter)
for (PrsMgr_Presentations::Iterator aPrsIter (myPresentations); aPrsIter.More(); aPrsIter.Next())
{
const PrsMgr_ModedPresentation& aModedPrs = myPresentations (aPrsIter);
if (aModedPrs.Presentation().IsNull()
|| aModedPrs.Presentation()->Presentation().IsNull())
const PrsMgr_ModedPresentation& aModedPrs = aPrsIter.Value();
if (!aModedPrs.Presentation().IsNull()
&& !aModedPrs.Presentation()->Presentation().IsNull())
{
continue;
aModedPrs.Presentation()->Presentation()->SetMutable (theIsMutable);
}
aModedPrs.Presentation()->Presentation()->SetMutable (theIsMutable);
}
}

View File

@@ -109,14 +109,19 @@ public:
Standard_EXPORT void SetTypeOfPresentation (const PrsMgr_TypeOfPresentation3d aType);
//! flags the Prs of mode <AMode> to be Updated.
//! the Update will be done when needed.
Standard_EXPORT void SetToUpdate (const Standard_Integer aMode);
//! Returns TRUE if any active presentation has invalidation flag.
//! @param theToIncludeHidden when TRUE, also checks hidden presentations
Standard_EXPORT Standard_Boolean ToBeUpdated (Standard_Boolean theToIncludeHidden = Standard_False) const;
//! Flags presentation to be updated; UpdatePresentations() will recompute these presentations.
//! @param theMode presentation (display mode) to invalidate, or -1 to invalidate them all
Standard_EXPORT void SetToUpdate (Standard_Integer theMode);
//! flags all the Presentations to be Updated.
Standard_EXPORT void SetToUpdate();
void SetToUpdate() { SetToUpdate (-1); }
//! gives the list of modes which are flagged "to be updated".
Standard_DEPRECATED("This method is deprecated - UpdatePresentations() should be called instead")
Standard_EXPORT void ToBeUpdated (TColStd_ListOfInteger& ListOfMode) const;
//! Return the local transformation.
@@ -297,12 +302,24 @@ Standard_EXPORT virtual ~PrsMgr_PresentableObject();
//! object before computation.
Standard_EXPORT virtual void Compute (const Handle(Prs3d_Projector)& aProjector, const Handle(Geom_Transformation)& aTrsf, const Handle(Prs3d_Presentation)& aPresentation);
//! recomputes all presentations of the object.
Standard_EXPORT void Update (const Standard_Boolean AllModes = Standard_False);
//! Recomputes invalidated presentations of the object.
//! @param theToIncludeHidden if TRUE, then even hidden invalidated presentations will be updated
//! @return TRUE if some presentations were recomputed
Standard_EXPORT Standard_Boolean UpdatePresentations (Standard_Boolean theToIncludeHidden = Standard_False);
//! Recomputes all presentations of the object.
Standard_DEPRECATED("This method is deprecated - SetToUpdate() + UpdatePresentations() should be called instead")
void Update (Standard_Boolean theToIncludeHidden = Standard_False)
{
SetToUpdate();
UpdatePresentations (theToIncludeHidden);
}
//! Recomputes the presentation in the given mode.
//! If ClearOther is true, other presentation will be cleared.
Standard_EXPORT void Update (const Standard_Integer aMode, const Standard_Boolean ClearOther);
//! @param theMode presentation (display mode) to recompute
//! @param theToClearOther when TRUE, other presentations (display modes) will be removed
Standard_DEPRECATED("This method is deprecated - SetToUpdate() + UpdatePresentations() should be called instead")
Standard_EXPORT void Update (Standard_Integer theMode, Standard_Boolean theToClearOther);
//! High-level interface for controlling polygon offsets
Standard_EXPORT virtual void Fill (const Handle(PrsMgr_PresentationManager)& aPresentationManager, const Handle(PrsMgr_Presentation)& aPresentation, const Standard_Integer aMode);