- void DeletePrs3d (Prs3d_ptr thePrs3d)
- {
- Prs3d_i* aPrs3d = dynamic_cast<Prs3d_i*>(GetServant(thePrs3d).in());
- if (!aPrs3d)
- return;
-
- // 1. Find appropriate application (code like in VISU_ViewManager_i.cxx)
- SALOMEDS::Study_var myStudyDocument = aPrs3d->GetStudyDocument();
- SalomeApp_Application* anApp = NULL;
- CORBA::String_var studyName = myStudyDocument->Name();
- std::string aStudyName = studyName.in();
- SUIT_Session* aSession = SUIT_Session::session();
- QPtrList<SUIT_Application> anApplications = aSession->applications();
- QPtrListIterator<SUIT_Application> anIter (anApplications);
- while (SUIT_Application* aSUITApp = anIter.current()) {
- ++anIter;
- if (SUIT_Study* aSStudy = aSUITApp->activeStudy()) {
- if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy)) {
- if (_PTR(Study) aCStudy = aStudy->studyDS()) {
- if (aStudyName == aCStudy->Name()) {
- anApp = dynamic_cast<SalomeApp_Application*>(aSUITApp);
- break;
- }
- }
- }
- }
- }
- if (!anApp)
- return;
-
- // 2. Remove corresponding IO from selection
- SALOMEDS::SObject_var aSObject = aPrs3d->GetSObject();
- CORBA::String_var anEntry = aSObject->GetID();
-
- SalomeApp_SelectionMgr* aSelectionMgr = anApp->selectionMgr();
- SALOME_ListIO aListIO, aNewListIO;
- aSelectionMgr->selectedObjects(aListIO);
-
- for (SALOME_ListIteratorOfListIO it (aListIO); it.More(); it.Next()) {
- if (it.Value()->hasEntry()) {
- std::string aCurEntry (it.Value()->getEntry());
- if (aCurEntry != anEntry) {
- aNewListIO.Append(it.Value());
- }
- }
- }
-
- aSelectionMgr->setSelectedObjects(aNewListIO);
-
- // 3. Remove Actors
- ViewManagerList aViewManagerList;
- anApp->viewManagers(SVTK_Viewer::Type(), aViewManagerList);
- QPtrListIterator<SUIT_ViewManager> anVMIter (aViewManagerList);
- for (; anVMIter.current(); ++anVMIter) {
- SUIT_ViewManager* aViewManager = anVMIter.current();
- QPtrVector<SUIT_ViewWindow> aViews = aViewManager->getViews();
- for (int i = 0, iEnd = aViews.size(); i < iEnd; i++) {
- if (SUIT_ViewWindow* aViewWindow = aViews.at(i)) {
- if (SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>(aViewWindow)) {
- //VISU_Actor* anActor = aVISUViewManager->GetActor(aPrs3d, vw);
- VISU_Actor* anActor = NULL;
- vtkActorCollection *anActColl = vw->getRenderer()->GetActors();
- anActColl->InitTraversal();
- vtkActor *aVTKActor = anActColl->GetNextActor();
- for (; !anActor && aVTKActor; aVTKActor = anActColl->GetNextActor()) {
- if (VISU_Actor* anVISUActor = dynamic_cast<VISU_Actor*>(aVTKActor)) {
- if (aPrs3d == anVISUActor->GetPrs3d()) {
- anActor = anVISUActor->GetParent();
- }
- }
- }
- if (anActor) {
- vw->RemoveActor(anActor);
- anActor->Delete();
- }
- }
- }
- }
- }
-
- aPrs3d->RemoveFromStudy();
- aPrs3d->Destroy();
-
- //jfa tmp:theModule->updateObjBrowser(); //update Object browser
- }
-