- SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
- if ( app ) {
- SalomeApp_SelectionMgr* aSelMgr = app->selectionMgr();
- SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
- if ( aSelMgr && appStudy ) {
- aSelMgr->selectedObjects( selected );
- if ( !selected.IsEmpty() ) {
- _PTR(Study) aStudy = appStudy->studyDS();
-
- bool aLocked = (_PTR(AttributeStudyProperties)(aStudy->GetProperties()))->IsLocked();
- if ( aLocked ) {
- SUIT_MessageBox::warn1 ( app->desktop(),
- QObject::tr("WRN_WARNING"),
- QObject::tr("WRN_STUDY_LOCKED"),
- QObject::tr("BUT_OK") );
- return;
- }
-
- // VSR 17/11/04: check if all objects selected belong to GEOM component --> start
- // modifications of ASV 01.06.05
- QString parentComp = getParentComponent( aStudy, selected );
- const char* geomIOR = app->orb()->object_to_string( GeometryGUI::GetGeomGen() );
- QString geomComp = getParentComponent( aStudy->FindObjectIOR( geomIOR ) );
-
- if ( parentComp != geomComp ) {
- SUIT_MessageBox::warn1 ( app->desktop(),
- QObject::tr("ERR_ERROR"),
- QObject::tr("NON_GEOM_OBJECTS_SELECTED").arg( getGeometryGUI()->moduleName() ),
- QObject::tr("BUT_OK") );
- return;
- }
- // VSR 17/11/04: check if all objects selected belong to GEOM component <-- finish
-
- if ( SUIT_MessageBox::warn2( app->desktop(),
- QObject::tr( "GEOM_WRN_WARNING" ),
- QObject::tr( "GEOM_REALLY_DELETE" ),
- QObject::tr( "GEOM_BUT_YES" ),
- QObject::tr( "GEOM_BUT_NO" ), 1, 0, 0 ) != 1 )
- return;
-
- // QAD_Operation* op = new SALOMEGUI_ImportOperation(.....);
- // op->start();
-
- // prepare list of SALOME_Views
- QPtrList<SALOME_View> views;
- SALOME_View* view;
- // fill the list
- ViewManagerList vmans = app->viewManagers();
- SUIT_ViewManager* vman;
- for ( vman = vmans.first(); vman; vman = vmans.next() ) {
- SUIT_ViewModel* vmod = vman->getViewModel();
- view = dynamic_cast<SALOME_View*> ( vmod ); // must work for OCC and VTK views
- if ( view )
- views.append( view );
- }
-
- _PTR(StudyBuilder) aStudyBuilder (aStudy->NewBuilder());
- _PTR(GenericAttribute) anAttr;
- GEOM_Displayer* disp = new GEOM_Displayer( appStudy );
-
- // MAIN LOOP OF SELECTED OBJECTS
- for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
-
- Handle(SALOME_InteractiveObject) io = It.Value();
- if ( !io->hasEntry() )
- continue;
-
- _PTR(SObject) obj ( aStudy->FindObjectID( io->getEntry() ) );
-
- // disable removal of "Geometry" component object
- if ( !strcmp( obj->GetIOR().c_str(), geomIOR ) )
- continue;
-
- // iterate through all children of obj, find IOR attributes on children
- // and remove shapes that correspond to these IORs
- for (_PTR(ChildIterator) it (aStudy->NewChildIterator(obj)); it->More(); it->Next()) {
- _PTR(SObject) child (it->Value());
- if (child->FindAttribute(anAttr, "AttributeIOR")) {
- _PTR(AttributeIOR) anIOR (anAttr);
-
- // Delete child( s ) shape in Client :
- const TCollection_AsciiString ASCior ((char*)anIOR->Value().c_str());
- getGeometryGUI()->GetShapeReader().RemoveShapeFromBuffer(ASCior);
-
- CORBA::Object_var corbaObj = GeometryGUI::ClientSObjectToObject(child);
- GEOM::GEOM_Object_var geomObj = GEOM::GEOM_Object::_narrow(corbaObj);
- if (!CORBA::is_nil(geomObj)) {
- for (view = views.first(); view; view = views.next()) {
- disp->Erase(geomObj, true, view);
- }
- }
- }
- } // for ( children of obj )
-
- // Erase main graphical object
- for ( view = views.first(); view; view = views.next() )
- disp->Erase( io, true, view );
-
- // Delete main shape in Client :
- if ( obj->FindAttribute( anAttr, "AttributeIOR" ) ) {
- _PTR(AttributeIOR) anIOR( anAttr );
- const TCollection_AsciiString ASCIor( (char*)anIOR->Value().c_str() );
- getGeometryGUI()->GetShapeReader().RemoveShapeFromBuffer( ASCIor );
- }
-
- CORBA::Object_var corbaObj = GeometryGUI::ClientSObjectToObject(obj);
- GEOM::GEOM_Object_var geomObj = GEOM::GEOM_Object::_narrow( corbaObj );
- if ( !CORBA::is_nil( geomObj ) )
- GeometryGUI::GetGeomGen()->RemoveObject( geomObj );
-
- // Remove objects from Study
- aStudyBuilder->RemoveObject( obj );
-
- //deleted = true;
- } // MAIN LOOP of selected
-
- selected.Clear();
- aSelMgr->setSelectedObjects( selected );
- getGeometryGUI()->updateObjBrowser();
- } // if ( selected not empty )
- } // if ( selMgr && appStudy )
-
- app->updateActions(); //SRN: To update a Save button in the toolbar
-
- } // if ( app )
-
-
- // if ( deleted )
- // op->finish();
- // else
- // op->abort();
-}
-
-
-//==============================================================================
-// function : OnEditCopy()
-// purpose :
-//==============================================================================
-void GEOMToolsGUI::OnEditCopy()
-{
-/*
- SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection() );
- GEOM::string_array_var listIOR = new GEOM::string_array;
-
- const SALOME_ListIO& List = Sel->StoredIObjects();
-
- myGeomBase->ConvertListOfIOInListOfIOR(List, listIOR);
-
- Sel->ClearIObjects();