mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-10 18:51: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:
parent
6c7ddf00ce
commit
eef7fc6447
@ -102,6 +102,8 @@ void OpenGl_GraphicDriver::RemoveStructure (const Graphic3d_CStructure& theCStru
|
|||||||
|
|
||||||
OpenGl_Structure* aStructure = myMapOfStructure.Find (theCStructure.Id);
|
OpenGl_Structure* aStructure = myMapOfStructure.Find (theCStructure.Id);
|
||||||
myMapOfStructure.UnBind (theCStructure.Id);
|
myMapOfStructure.UnBind (theCStructure.Id);
|
||||||
|
Graphic3d_CStructure& aCStruct = const_cast<Graphic3d_CStructure&>(theCStructure);
|
||||||
|
aCStruct.ptrStructure = 0;
|
||||||
OpenGl_Element::Destroy (GetSharedContext(), aStructure);
|
OpenGl_Element::Destroy (GetSharedContext(), aStructure);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ is
|
|||||||
|
|
||||||
Display(me: mutable) is deferred private;
|
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;
|
SetVisible (me: mutable; theValue: Boolean from Standard) is deferred private;
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ is
|
|||||||
---Purpose: displays myStructure and sets myDisplayReason to theIsHighlight value if
|
---Purpose: displays myStructure and sets myDisplayReason to theIsHighlight value if
|
||||||
-- myStructure was not displayed or was invisible
|
-- 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;
|
SetVisible (me: mutable; theValue: Boolean from Standard) is redefined static private;
|
||||||
|
|
||||||
|
@ -68,8 +68,13 @@ void PrsMgr_Presentation3d::Display(const Standard_Boolean theIsHighlight)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrsMgr_Presentation3d::Erase () const {
|
void PrsMgr_Presentation3d::Erase ()
|
||||||
myStructure->Erase();}
|
{
|
||||||
|
// Erase structure from structure manager
|
||||||
|
myStructure->Erase();
|
||||||
|
// Clear groups and remove graphic structure
|
||||||
|
myStructure.Nullify();
|
||||||
|
}
|
||||||
|
|
||||||
void PrsMgr_Presentation3d::SetVisible (const Standard_Boolean theValue)
|
void PrsMgr_Presentation3d::SetVisible (const Standard_Boolean theValue)
|
||||||
{
|
{
|
||||||
|
@ -49,11 +49,19 @@ void PrsMgr_PresentationManager::Erase(
|
|||||||
const Handle(PrsMgr_PresentableObject)& aPresentableObject,
|
const Handle(PrsMgr_PresentableObject)& aPresentableObject,
|
||||||
const Standard_Integer aMode)
|
const Standard_Integer aMode)
|
||||||
{
|
{
|
||||||
if (HasPresentation(aPresentableObject,aMode)){
|
if (HasPresentation(aPresentableObject,aMode))
|
||||||
|
{
|
||||||
if(myImmediateMode)
|
if(myImmediateMode)
|
||||||
|
{
|
||||||
Remove(aPresentableObject,aMode);
|
Remove(aPresentableObject,aMode);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
Presentation(aPresentableObject,aMode)->Erase();}
|
{
|
||||||
|
Presentation(aPresentableObject,aMode)->Erase();
|
||||||
|
}
|
||||||
|
|
||||||
|
RemovePresentation (aPresentableObject,aMode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrsMgr_PresentationManager::Clear(const Handle(PrsMgr_PresentableObject)& aPresentableObject,
|
void PrsMgr_PresentationManager::Clear(const Handle(PrsMgr_PresentableObject)& aPresentableObject,
|
||||||
|
@ -1587,6 +1587,141 @@ static int VDonly2(Draw_Interpretor& , Standard_Integer argc, const char** argv)
|
|||||||
return 0;
|
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
|
//function : VErase
|
||||||
//purpose : Erase some selected or named objects
|
//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.",
|
"\n\t\t: If there are no selected or named objects the whole viewer is erased.",
|
||||||
__FILE__, VErase, group);
|
__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",
|
theCommands.Add("vdonly",
|
||||||
"vdonly [name1] ... [name n]"
|
"vdonly [name1] ... [name n]"
|
||||||
"\n\t\t: Displays only selected or named objects",
|
"\n\t\t: Displays only selected or named objects",
|
||||||
|
28
tests/bugs/vis/bug24391
Normal file
28
tests/bugs/vis/bug24391
Normal 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
|
Loading…
x
Reference in New Issue
Block a user