- SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument();
- SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection());
- if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
- // VTK
- SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
- Handle(SALOME_InteractiveObject) anIObject;
- for(;It.More();It.Next()) {
- anIObject = It.Value();
- VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor();
-
- if(myRenderInter->isInViewer(anIObject)) {
- myRenderInter->Erase(anIObject);
- }
- else {
- SALOMEDS::SObject_var obj = aStudy->FindObjectID(anIObject->getEntry());
- SALOMEDS::GenericAttribute_var anAttr;
- SALOMEDS::AttributeIOR_var anIOR;
- if(!obj->_is_nil()) {
- if(obj->FindAttribute(anAttr, "AttributeIOR")) {
- // this SObject may be GEOM module root SObject
- SALOMEDS::ChildIterator_var anIter = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument()->NewChildIterator(obj);
- bool useSubItems = false;
- while(anIter->More() && !useSubItems) {
- SALOMEDS::SObject_var subobj = anIter->Value();
- SALOMEDS::GenericAttribute_var aTmpAttr;
- if(subobj->FindAttribute(aTmpAttr, "AttributeIOR")) {
- anAttr = aTmpAttr;
- obj = subobj;
- useSubItems = true;
- }
- else
- anIter->Next();
- }
-
- while(useSubItems?anIter->More():!anAttr->_is_nil()) {
- anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
- GEOM::GEOM_Shape_var aShape = myGeom->GetIORFromString(anIOR->Value());
- TopoDS_Shape Shape = myGeomGUI->GetShapeReader().GetShape(myGeom, aShape);
- if(obj->FindAttribute(anAttr, "AttributeName")) {
- // searchin for already displayed objects with the same shape
- vtkRenderer* theRenderer = ((VTKViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer();
- vtkActorCollection* theAllActors = theRenderer->GetActors();
- theAllActors->InitTraversal();
- vtkActor* actor = (vtkActor*)theAllActors->GetNextActor();
- Handle(SALOME_InteractiveObject) anIObj;
- // don't create new study object if it already exists
- bool isDisplayed = false;
- while(!(actor==NULL)) {
- SALOME_Actor* Gactor = SALOME_Actor::SafeDownCast(actor);
- if(Gactor!=NULL) {
- if(Gactor->hasIO()) {
- if(strcmp(Gactor->getIO()->getEntry(),obj->GetID())==0) {
- isDisplayed = true;
- anIObj = Gactor->getIO();
- if(!anIObj.IsNull())
- myRenderInter->Erase(anIObj);
- }
- }
- }
- actor=(vtkActor*)(theAllActors->GetNextActor());
- }
- }
- if(useSubItems) {
- anIter->Next();
- anAttr=SALOMEDS::GenericAttribute::_nil();
- while(anIter->More() && anAttr->_is_nil()) {
- SALOMEDS::SObject_var subobject = anIter->Value();
- SALOMEDS::GenericAttribute_var aTmpAttribute;
- if(subobject->FindAttribute(aTmpAttribute, "AttributeIOR")) {
- anAttr = aTmpAttribute;
- obj = subobject;
- }
- else
- anIter->Next();
- }
- }
- else
- anAttr = SALOMEDS::GenericAttribute::_nil();
- }
- }
- }
- }
- }
- }
- else if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) {
- // OCC
- OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
- Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
- SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
- Handle(SALOME_InteractiveObject) anIObject;
- for(;It.More();It.Next()) {
- anIObject = It.Value();
- if(v3d->isInViewer(anIObject, true)) {
- Standard_Boolean found;
- Handle(GEOM_AISShape) aSh = myGeomBase->ConvertIOinGEOMAISShape(anIObject, found, true);
- if(found) {
- ic->Erase(aSh);
- ic->AddOrRemoveCurrentObject(aSh, true);
- }
- }
- else {
- SALOMEDS::SObject_var obj = aStudy->FindObjectID(anIObject->getEntry());
- SALOMEDS::GenericAttribute_var anAttr;
- SALOMEDS::AttributeIOR_var anIOR;
- if(!obj->_is_nil()) {
- if(obj->FindAttribute(anAttr, "AttributeIOR")) {
- // this SObject may be GEOM module root SObject
- SALOMEDS::ChildIterator_var anIter = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument()->NewChildIterator(obj);
- bool useSubItems = false;
- while(anIter->More() && !useSubItems) {
- SALOMEDS::SObject_var subobj = anIter->Value();
- SALOMEDS::GenericAttribute_var aTmpAttr;
- if(subobj->FindAttribute(aTmpAttr, "AttributeIOR")) {
- anAttr = aTmpAttr;
- obj = subobj;
- useSubItems = true;
- }
- else
- anIter->Next();
- }
-
- while(useSubItems?anIter->More():!anAttr->_is_nil()) {
- anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
- GEOM::GEOM_Shape_var aShape = myGeom->GetIORFromString(anIOR->Value());
- TopoDS_Shape Shape = myGeomGUI->GetShapeReader().GetShape(myGeom, aShape);
- if(obj->FindAttribute(anAttr, "AttributeName")) {
- // searchin for already displayed objects with the same shape
- AIS_ListOfInteractive aDisplayed;
- ic->DisplayedObjects(aDisplayed);
- AIS_ListIteratorOfListOfInteractive anIObjects(aDisplayed);
- Handle(AIS_Shape) anAISShape;
- for(;anIObjects.More();anIObjects.Next()) {
- anAISShape = Handle(AIS_Shape)::DownCast(anIObjects.Value());
- if(!anAISShape.IsNull()) {
- if(anAISShape->Shape().IsSame(Shape))
- break;
- anAISShape.Nullify();
- }
- }
- if(!anAISShape.IsNull()) {
- if(ic->IsDisplayed(anAISShape))
- ic->Erase(anAISShape);
- }
- }
- if(useSubItems) {
- anIter->Next();
- anAttr=SALOMEDS::GenericAttribute::_nil();
- while(anIter->More() && anAttr->_is_nil()) {
- SALOMEDS::SObject_var subobject = anIter->Value();
- SALOMEDS::GenericAttribute_var aTmpAttribute;
- if(subobject->FindAttribute(aTmpAttribute, "AttributeIOR")) {
- anAttr = aTmpAttribute;
- obj = subobject;
- }
- else
- anIter->Next();
- }
- }
- else
- anAttr = SALOMEDS::GenericAttribute::_nil();
- }
- }
- }