1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-07 18:30:55 +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; Display (me : mutable;
theIsHighlight : Boolean from Standard) theIsHighlight : Boolean from Standard)
is static private; is static private;
---Purpose: Displays myStructure and sets myDisplayReason to theIsHighlight value if ---Purpose: Displays myStructure.
-- myStructure was not displayed or was invisible
Erase (me : mutable) Erase (me : mutable)
is virtual private; is virtual private;
@ -92,7 +91,7 @@ is
Color (me : mutable; Color (me : mutable;
theColor : NameOfColor from Quantity) theColor : NameOfColor from Quantity)
is static private; is virtual private;
BoundBox (me) BoundBox (me)
is static private; is static private;
@ -188,7 +187,7 @@ fields
myStructure : Prs from PrsMgr; myStructure : Prs from PrsMgr;
myPresentableObject : PresentableObjectPointer from PrsMgr; myPresentableObject : PresentableObjectPointer from PrsMgr;
myMustBeUpdated : Boolean from Standard; myMustBeUpdated : Boolean from Standard;
myDisplayReason : Boolean from Standard; myBeforeHighlightState: Integer from Standard;
friends friends

View File

@ -21,16 +21,33 @@
#include <Visual3d_View.hxx> #include <Visual3d_View.hxx>
#include <Precision.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 //function : PrsMgr_Presentation
//purpose : //purpose :
//======================================================================= //=======================================================================
PrsMgr_Presentation::PrsMgr_Presentation (const Handle(PrsMgr_PresentationManager3d)& thePrsMgr, PrsMgr_Presentation::PrsMgr_Presentation (const Handle(PrsMgr_PresentationManager3d)& thePrsMgr,
const Handle(PrsMgr_PresentableObject)& thePrsObject) const Handle(PrsMgr_PresentableObject)& thePrsObject)
: myPresentationManager (thePrsMgr), : myPresentationManager (thePrsMgr),
myPresentableObject (thePrsObject.operator->()), myPresentableObject (thePrsObject.operator->()),
myMustBeUpdated (Standard_False), myMustBeUpdated (Standard_False),
myDisplayReason (Standard_False) myBeforeHighlightState (State_Empty)
{ {
myStructure = new PrsMgr_Prs (thePrsMgr->StructureManager(), myStructure = new PrsMgr_Prs (thePrsMgr->StructureManager(),
this, thePrsObject->TypeOfPresentation3d()); this, thePrsObject->TypeOfPresentation3d());
@ -44,24 +61,22 @@ PrsMgr_Presentation::PrsMgr_Presentation (const Handle(PrsMgr_PresentationManage
void PrsMgr_Presentation::Display() void PrsMgr_Presentation::Display()
{ {
Display (Standard_False); Display (Standard_False);
myDisplayReason = Standard_False; myBeforeHighlightState = State_Visible;
} }
//======================================================================= //=======================================================================
//function : Display //function : Display
//purpose : //purpose :
//======================================================================= //=======================================================================
void PrsMgr_Presentation::Display (const Standard_Boolean theIsHighlight) void PrsMgr_Presentation::Display (const Standard_Boolean /*theIsHighlight*/)
{ {
if (!myStructure->IsDisplayed()) if (!myStructure->IsDisplayed())
{ {
myStructure->Display(); myStructure->Display();
myDisplayReason = theIsHighlight;
} }
else if (!myStructure->IsVisible()) else if (!myStructure->IsVisible())
{ {
myStructure->SetVisible (Standard_True); SetVisible (Standard_True);
myDisplayReason = theIsHighlight;
} }
} }
@ -100,6 +115,11 @@ void PrsMgr_Presentation::SetVisible (const Standard_Boolean theValue)
//======================================================================= //=======================================================================
void PrsMgr_Presentation::Highlight() void PrsMgr_Presentation::Highlight()
{ {
if (!IsHighlighted())
{
myBeforeHighlightState = StructureState (myStructure);
}
Display (Standard_True); Display (Standard_True);
myStructure->Highlight(); myStructure->Highlight();
} }
@ -111,9 +131,16 @@ void PrsMgr_Presentation::Highlight()
void PrsMgr_Presentation::Unhighlight() const void PrsMgr_Presentation::Unhighlight() const
{ {
myStructure->UnHighlight(); myStructure->UnHighlight();
if (myDisplayReason) switch (myBeforeHighlightState)
{ {
case State_Visible:
return;
case State_Hidden:
myStructure->SetVisible (Standard_False); 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) void PrsMgr_Presentation::Color (const Quantity_NameOfColor theColor)
{ {
if (!IsHighlighted())
{
myBeforeHighlightState = StructureState (myStructure);
}
Display (Standard_True); Display (Standard_True);
myStructure->Color (theColor); myStructure->Color (theColor);
} }
@ -165,8 +197,7 @@ void PrsMgr_Presentation::BoundBox() const
Standard_Boolean PrsMgr_Presentation::IsDisplayed() const Standard_Boolean PrsMgr_Presentation::IsDisplayed() const
{ {
return myStructure->IsDisplayed() return myStructure->IsDisplayed()
&& myStructure->IsVisible() && myStructure->IsVisible();
&& !myDisplayReason;
} }
//======================================================================= //=======================================================================
@ -375,6 +406,8 @@ void PrsMgr_Presentation::Destroy()
{ {
if (!myStructure.IsNull()) if (!myStructure.IsNull())
{ {
// Remove structure from the list of displayed structures.
myStructure->Erase();
myStructure->Clear(); myStructure->Clear();
myStructure.Nullify(); 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