1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-04 18:06:22 +03:00

0024835: Graphic structure for highlighting is not erased if presentable object for highlight is deleted

Corrections in highlight state checks.
This commit is contained in:
aba 2014-05-22 18:15:21 +04:00 committed by apn
parent f56518cdbe
commit 3ae590318e
3 changed files with 69 additions and 16 deletions

View File

@ -50,8 +50,7 @@ is
Display (me : mutable;
theIsHighlight : Boolean from Standard)
is static private;
---Purpose: Displays myStructure and sets myDisplayReason to theIsHighlight value if
-- myStructure was not displayed or was invisible
---Purpose: Displays myStructure.
Erase (me : mutable)
is virtual private;
@ -92,7 +91,7 @@ is
Color (me : mutable;
theColor : NameOfColor from Quantity)
is static private;
is virtual private;
BoundBox (me)
is static private;
@ -188,7 +187,7 @@ fields
myStructure : Prs from PrsMgr;
myPresentableObject : PresentableObjectPointer from PrsMgr;
myMustBeUpdated : Boolean from Standard;
myDisplayReason : Boolean from Standard;
myBeforeHighlightState: Integer from Standard;
friends

View File

@ -21,16 +21,33 @@
#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());
@ -44,24 +61,22 @@ PrsMgr_Presentation::PrsMgr_Presentation (const Handle(PrsMgr_PresentationManage
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);
}
}
@ -100,6 +115,11 @@ void PrsMgr_Presentation::SetVisible (const Standard_Boolean theValue)
//=======================================================================
void PrsMgr_Presentation::Highlight()
{
if (!IsHighlighted())
{
myBeforeHighlightState = StructureState (myStructure);
}
Display (Standard_True);
myStructure->Highlight();
}
@ -111,9 +131,16 @@ void PrsMgr_Presentation::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;
}
}
@ -145,6 +172,11 @@ void PrsMgr_Presentation::Clear()
//=======================================================================
void PrsMgr_Presentation::Color (const Quantity_NameOfColor theColor)
{
if (!IsHighlighted())
{
myBeforeHighlightState = StructureState (myStructure);
}
Display (Standard_True);
myStructure->Color (theColor);
}
@ -165,8 +197,7 @@ void PrsMgr_Presentation::BoundBox() const
Standard_Boolean PrsMgr_Presentation::IsDisplayed() const
{
return myStructure->IsDisplayed()
&& myStructure->IsVisible()
&& !myDisplayReason;
&& myStructure->IsVisible();
}
//=======================================================================
@ -375,6 +406,8 @@ void PrsMgr_Presentation::Destroy()
{
if (!myStructure.IsNull())
{
// Remove structure from the list of displayed structures.
myStructure->Erase();
myStructure->Clear();
myStructure.Nullify();
}

21
tests/bugs/vis/bug24835 Normal file
View File

@ -0,0 +1,21 @@
puts "============"
puts "CR24835"
puts "============"
puts ""
####################################################################################################
# Graphic structure for highlighting is not erased if presentable object for highlight is deleted.
####################################################################################################
pload ALL
vinit v
box b 1 1 1
vdisplay b
vfit
vselmode b 1 1
vmoveto 380 104
vmoveto 29 103
vremove b
vclose v 1
vinit
set only_screen 1