Remove object in local context

I want to remove an object in the local context so I write these lines:
for(myAISContext->InitSelected();myAISContext->MoreSelected();myAISContext->InitSelected())
myAISContext->Remove(myAISContext->SelectedInteractive(),Standard_True);
but it doesn't work.
does it have any idea to remove the object in local context.

Thanks

Dennis G.'s picture

I'm not that familiar with the AIS concept, but did you try ::Erase(...) instead of ::Remove(...)?

Dennis

ATTIA's picture

Thank you very much Dennis for your help.
I have used this solution but It erase the shape and not only the object selected
if(myAISContext->NbSelected()!=0)

{
myAISContext->InitSelected();
myAISContext->Erase(myAISContext->SelectedInteractive(),Standard_True); }
and I have used these lines

if(myAISContext->NbSelected()!=0)

{
myAISContext->InitSelected();
myAISContext->EraseSelected(Standard_True);}
but no object is deleted.

ATTIA's picture

there is any one who can help me?

Regards

JuryS's picture

Hi ! In my program I delete objects with next function:
and It's working with OCAF application and without this . You may know is object deleted or not with saving your document before and after remove. In my program empty file is ~573 bytes after removing all objects and before create objects.

void objectView::DeleteObject()
{
MainWindow* myApp = MainWindow::getApplication();
QWorkspace* Space = myApp->getWorkspace();
DocumentCommon* doc = ((MDIWindow*) Space->activeWindow())->getDocument();

AIS_SequenceOfInteractive aSequence;
for(myContext->InitCurrent();myContext->MoreCurrent();myContext->NextCurrent())
aSequence.Append(myContext->Current());

doc->GetOCAFDoc()->NewCommand(); //! Íà÷èíàþ çàïèñü äëÿ îòìåíû
for(int iter=1;iter <=aSequence.Length();iter++)
{

Handle(TPrsStd_AISPresentation) CurrentPrs
= Handle(TPrsStd_AISPresentation)::DownCast(aSequence(iter)->GetOwner());
if (!CurrentPrs.IsNull()) //Åñëè ýòî èíòåðàêòèâíûé îáúåêò
{
TDF_Label LabObject = CurrentPrs->Label();

if (grtools->IsFatherGroup(LabObject)) //Åñëè ýòîò îáúåêò íå ïðèíàäëåæèò íè ê êàêèì ãðóïïàì
LabObject.ForgetAllAttributes(Standard_True); //Çàáûòü âñå ïðèñâîåííûå àòðèáóòû
else onDeleteGroup(LabObject);

doc->AnyChanged(true);
}
else //Åñëè ýòî îáû÷íûé ãðàôè÷åñêèé îáúåêò
{
myContext->Erase( aSequence(iter), false, false );
}
}
doc->GetOCAFDoc()->CommitCommand(); //! Çàêîí÷èë çàïèñü äëÿ îòìåíû

//Ïîñëå óäàëåíèÿ îáúåêòà îáíîâëÿþ òåêñòóðèðîâàííûå îáúåêòû

if (myApp->getMyMode()==3) doc->onTexture();
else
{
if (myApp->getMyMode()==0) doc->onWireframe();
if (myApp->getMyMode()==1) doc->onShading();
}
}

ATTIA's picture

Thank you for your help.
But I want to delete an object from local context.
In fact, the type of the object detected in local context is topoDS_shape.(myAISContext->selectedshape()).
Then I use myAISContext to display these object.

Please help me.