#include <Visual3d_View.hxx>
#include <Precision.hxx>
+namespace
+{
+ enum BeforeHighlightState
+ {
+ State_Empty,
+ State_Hidden,
+ State_Visible
+ };
+
+ static BeforeHighlightState StructureState(const Handle(PrsMgr_Prs) theStructure)
+ {
+ return !theStructure->IsDisplayed() ?
+ State_Empty : !theStructure->IsVisible() ?
+ State_Hidden : State_Visible;
+ }
+}
+
//=======================================================================
//function : PrsMgr_Presentation
//purpose :
//=======================================================================
PrsMgr_Presentation::PrsMgr_Presentation (const Handle(PrsMgr_PresentationManager3d)& thePrsMgr,
const Handle(PrsMgr_PresentableObject)& thePrsObject)
-: myPresentationManager (thePrsMgr),
- myPresentableObject (thePrsObject.operator->()),
- myMustBeUpdated (Standard_False),
- myDisplayReason (Standard_False)
+: myPresentationManager (thePrsMgr),
+ myPresentableObject (thePrsObject.operator->()),
+ myMustBeUpdated (Standard_False),
+ myBeforeHighlightState (State_Empty)
{
myStructure = new PrsMgr_Prs (thePrsMgr->StructureManager(),
this, thePrsObject->TypeOfPresentation3d());
void PrsMgr_Presentation::Display()
{
Display (Standard_False);
- myDisplayReason = Standard_False;
+ myBeforeHighlightState = State_Visible;
}
//=======================================================================
//function : Display
//purpose :
//=======================================================================
-void PrsMgr_Presentation::Display (const Standard_Boolean theIsHighlight)
+void PrsMgr_Presentation::Display (const Standard_Boolean /*theIsHighlight*/)
{
if (!myStructure->IsDisplayed())
{
myStructure->Display();
- myDisplayReason = theIsHighlight;
}
else if (!myStructure->IsVisible())
{
- myStructure->SetVisible (Standard_True);
- myDisplayReason = theIsHighlight;
+ SetVisible (Standard_True);
}
}
//=======================================================================
void PrsMgr_Presentation::Highlight()
{
+ if (!IsHighlighted())
+ {
+ myBeforeHighlightState = StructureState (myStructure);
+ }
+
Display (Standard_True);
myStructure->Highlight();
}
void PrsMgr_Presentation::Unhighlight() const
{
myStructure->UnHighlight();
- if (myDisplayReason)
+ switch (myBeforeHighlightState)
{
+ case State_Visible:
+ return;
+ case State_Hidden:
myStructure->SetVisible (Standard_False);
+ break;
+ case State_Empty:
+ myStructure->Erase();
+ break;
}
}
//=======================================================================
void PrsMgr_Presentation::Color (const Quantity_NameOfColor theColor)
{
+ if (!IsHighlighted())
+ {
+ myBeforeHighlightState = StructureState (myStructure);
+ }
+
Display (Standard_True);
myStructure->Color (theColor);
}
Standard_Boolean PrsMgr_Presentation::IsDisplayed() const
{
return myStructure->IsDisplayed()
- && myStructure->IsVisible()
- && !myDisplayReason;
+ && myStructure->IsVisible();
}
//=======================================================================
{
if (!myStructure.IsNull())
{
+ // Remove structure from the list of displayed structures.
+ myStructure->Erase();
myStructure->Clear();
myStructure.Nullify();
}