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

0024391: Erased AIS object can not be displayed in AIS_InteractiveContext after AIS_InteractiveContext::Remove(): added presentations removing after presentable object is removed from context.

vremove command was corrected. Test case was corrected.

few mistakes corrected
This commit is contained in:
aba 2013-11-28 19:50:58 +04:00 committed by abv
parent 6c7ddf00ce
commit eef7fc6447
7 changed files with 192 additions and 6 deletions

View File

@ -102,6 +102,8 @@ void OpenGl_GraphicDriver::RemoveStructure (const Graphic3d_CStructure& theCStru
OpenGl_Structure* aStructure = myMapOfStructure.Find (theCStructure.Id);
myMapOfStructure.UnBind (theCStructure.Id);
Graphic3d_CStructure& aCStruct = const_cast<Graphic3d_CStructure&>(theCStructure);
aCStruct.ptrStructure = 0;
OpenGl_Element::Destroy (GetSharedContext(), aStructure);
}

View File

@ -39,7 +39,7 @@ is
Display(me: mutable) is deferred private;
Erase(me) is deferred private;
Erase(me: mutable) is deferred private;
SetVisible (me: mutable; theValue: Boolean from Standard) is deferred private;

View File

@ -61,7 +61,7 @@ is
---Purpose: displays myStructure and sets myDisplayReason to theIsHighlight value if
-- myStructure was not displayed or was invisible
Erase(me) is redefined static private;
Erase(me: mutable) is redefined static private;
SetVisible (me: mutable; theValue: Boolean from Standard) is redefined static private;

View File

@ -68,8 +68,13 @@ void PrsMgr_Presentation3d::Display(const Standard_Boolean theIsHighlight)
}
}
void PrsMgr_Presentation3d::Erase () const {
myStructure->Erase();}
void PrsMgr_Presentation3d::Erase ()
{
// Erase structure from structure manager
myStructure->Erase();
// Clear groups and remove graphic structure
myStructure.Nullify();
}
void PrsMgr_Presentation3d::SetVisible (const Standard_Boolean theValue)
{

View File

@ -49,11 +49,19 @@ void PrsMgr_PresentationManager::Erase(
const Handle(PrsMgr_PresentableObject)& aPresentableObject,
const Standard_Integer aMode)
{
if (HasPresentation(aPresentableObject,aMode)){
if (HasPresentation(aPresentableObject,aMode))
{
if(myImmediateMode)
{
Remove(aPresentableObject,aMode);
}
else
Presentation(aPresentableObject,aMode)->Erase();}
{
Presentation(aPresentableObject,aMode)->Erase();
}
RemovePresentation (aPresentableObject,aMode);
}
}
void PrsMgr_PresentationManager::Clear(const Handle(PrsMgr_PresentableObject)& aPresentableObject,

View File

@ -1587,6 +1587,141 @@ static int VDonly2(Draw_Interpretor& , Standard_Integer argc, const char** argv)
return 0;
}
//==============================================================================
//function : VRemove
//purpose : Removes selected or named objects.
// If there is no selected or named objects,
// all objects in the viewer can be removed with argument -all.
// If -context is in arguments, the object is not deleted from the map of
// objects (deleted only from the current context).
//==============================================================================
int VRemove (Draw_Interpretor& theDI,
Standard_Integer theArgNb,
const char** theArgVec)
{
if (a3DView().IsNull())
{
return 1;
}
TheAISContext()->CloseAllContexts (Standard_False);
//Standard_Boolean isStayedInMap = Standard_False;
TCollection_AsciiString aContextOnlyStr ("-context");
TCollection_AsciiString aRemoveAllStr ("-all");
Standard_Boolean isContextOnly = (theArgNb > 1 && TCollection_AsciiString (theArgVec[1]) == aContextOnlyStr);
Standard_Boolean isRemoveAll = (theArgNb == 3 && TCollection_AsciiString (theArgVec[2]) == aRemoveAllStr) ||
(theArgNb == 2 && TCollection_AsciiString (theArgVec[1]) == aRemoveAllStr);
NCollection_List<TCollection_AsciiString> anIONameList;
if (isRemoveAll)
{
for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIter (GetMapOfAIS());
anIter.More(); anIter.Next())
{
anIONameList.Append (anIter.Key2());
}
}
else if (isContextOnly ? theArgNb > 2 : theArgNb > 1) // removed objects names are in argument list
{
for (Standard_Integer anIt = isContextOnly ? 2 : 1; anIt < theArgNb; ++anIt)
{
TCollection_AsciiString aName = theArgVec[anIt];
if (!GetMapOfAIS().IsBound2 (aName))
{
theDI << aName.ToCString() << " was not bound to some object.\n";
continue;
}
const Handle(Standard_Transient)& aTransientObj = GetMapOfAIS().Find2 (aName);
const Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast (aTransientObj);
if (!anIO.IsNull())
{
if (anIO->GetContext() != TheAISContext())
{
theDI << aName.ToCString() << " was not displayed in current context.\n";
theDI << "Please activate view with this object displayed and try again.\n";
continue;
}
anIONameList.Append (aName);
continue;
}
const Handle(NIS_InteractiveObject) aNisIO = Handle(NIS_InteractiveObject)::DownCast (aTransientObj);
if (!aNisIO.IsNull())
{
anIONameList.Append (aName);
}
}
}
else if (TheAISContext()->NbCurrents() > 0
|| TheNISContext()->GetSelected().Extent() > 0)
{
for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIter (GetMapOfAIS());
anIter.More(); anIter.Next())
{
const Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast (anIter.Key1());
if (!anIO.IsNull())
{
if (!TheAISContext()->IsCurrent (anIO))
{
continue;
}
anIONameList.Append (anIter.Key2());
continue;
}
const Handle(NIS_InteractiveObject) aNisIO = Handle(NIS_InteractiveObject)::DownCast (anIter.Key1());
if (!aNisIO.IsNull())
{
if (!TheNISContext()->IsSelected (aNisIO))
{
continue;
}
anIONameList.Append (anIter.Key2());
}
}
}
// Unbind all removed objects from the map of displayed IO.
for (NCollection_List<TCollection_AsciiString>::Iterator anIter (anIONameList);
anIter.More(); anIter.Next())
{
const Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast (GetMapOfAIS().Find2 (anIter.Value()));
if (!anIO.IsNull())
{
TheAISContext()->Remove (anIO, Standard_False);
theDI << anIter.Value().ToCString() << " was removed\n";
}
else
{
const Handle(NIS_InteractiveObject) aNisIO = Handle(NIS_InteractiveObject)::DownCast (GetMapOfAIS().Find2 (anIter.Value()));
if (!aNisIO.IsNull())
{
TheNISContext()->Remove (aNisIO);
theDI << anIter.Value().ToCString() << " was removed\n";
}
}
if (!isContextOnly)
{
GetMapOfAIS().UnBind2 (anIter.Value());
}
}
TheAISContext()->UpdateCurrentViewer();
return 0;
}
//==============================================================================
//function : VErase
//purpose : Erase some selected or named objects
@ -3138,6 +3273,14 @@ void ViewerTest::Commands(Draw_Interpretor& theCommands)
"\n\t\t: If there are no selected or named objects the whole viewer is erased.",
__FILE__, VErase, group);
theCommands.Add("vremove",
"vremove [-context] [name1] ... [name n]"
"or vremove [-context] -all to remove all objects"
"\n\t\t: Removes selected or named objects."
"\n\t\t If -context is in arguments, the objects are not deleted"
"\n\t\t from the map of objects and names.",
__FILE__, VRemove, group);
theCommands.Add("vdonly",
"vdonly [name1] ... [name n]"
"\n\t\t: Displays only selected or named objects",

28
tests/bugs/vis/bug24391 Normal file
View File

@ -0,0 +1,28 @@
puts "============"
puts "OCC24391"
puts "============"
puts ""
#######################################################################
# Erased AIS object can not be displayed in AIS_InteractiveContext
# after AIS_InteractiveContext::Remove
#######################################################################
pload VISUALLIZATION
vinit
box a 1 1 1
vdisplay a
verase a
vremove -context a
vdisplay a
vfit
vmoveto 204 205
set x_coord 204
set y_coord 205
checkcolor $x_coord $y_coord 0 1 1
if { $stat != 1 } {
puts "Error : Erased object is not displayed after its removing."
}
set only_screen 1