X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGEOMToolsGUI%2FGEOMToolsGUI.cxx;h=61a6cd38124488ac34ea88ee6a9f71839f4432a9;hb=b6f0965afb72083a5234f9b4fb0b233adaaf8d9d;hp=7a437d272feb4ac70e75578ae7ca2add8c70c7d1;hpb=2735fef8fc422fd39a59490e6bb22f2a650d5f5e;p=modules%2Fgeom.git diff --git a/src/GEOMToolsGUI/GEOMToolsGUI.cxx b/src/GEOMToolsGUI/GEOMToolsGUI.cxx index 7a437d272..61a6cd381 100644 --- a/src/GEOMToolsGUI/GEOMToolsGUI.cxx +++ b/src/GEOMToolsGUI/GEOMToolsGUI.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2022 CEA/DEN, EDF R&D, OPEN CASCADE // // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -77,11 +77,12 @@ static QString getParentComponent( _PTR( SObject ) obj ) //===================================================================================== // function : inUse -// purpose : check if the object(s) passed as the the second arguments are used +// purpose : check if the object(s) passed as the second arguments are used // by the other objects in the study //===================================================================================== -static bool inUse( _PTR(Study) study, const QString& component, const QMap& objects ) +static bool inUse( const QString& component, const QMap& objects ) { + _PTR(Study) study = SalomeApp_Application::getStudy(); _PTR(SObject) comp = study->FindObjectID( component.toLatin1().data() ); if ( !comp ) return false; @@ -90,54 +91,61 @@ static bool inUse( _PTR(Study) study, const QString& component, const QMap gobjects; QMap::ConstIterator oit; std::list<_PTR(SObject)> aSelectedSO; - for ( oit = objects.begin(); oit != objects.end(); ++oit ) { - _PTR(SObject) so = study->FindObjectID( oit.key().toLatin1().data() ); - if ( !so ) + for ( oit = objects.begin(); oit != objects.end(); ++oit ) + { + _PTR(SObject) so = study->FindObjectID( oit.key().toUtf8().data() ); + if ( !GeometryGUI::IsInGeomComponent( so )) continue; aSelectedSO.push_back(so); - CORBA::Object_var corbaObj_rem = GeometryGUI::ClientSObjectToObject( so ); + CORBA::Object_var corbaObj_rem = GeometryGUI::ClientSObjectToObject( so ); GEOM::GEOM_BaseObject_var geomObj_rem = GEOM::GEOM_BaseObject::_narrow( corbaObj_rem ); - if( CORBA::is_nil( geomObj_rem ) ) - continue; - gobjects.insert( oit.key(), geomObj_rem ); + if ( ! CORBA::is_nil( geomObj_rem )) + gobjects.insert( oit.key(), geomObj_rem ); } // Search References with other Modules std::list< _PTR(SObject) >::iterator itSO = aSelectedSO.begin(); - for ( ; itSO != aSelectedSO.end(); ++itSO ) { + for ( ; itSO != aSelectedSO.end(); ++itSO ) + { std::vector<_PTR(SObject)> aReferences = study->FindDependances( *itSO ); int aRefLength = aReferences.size(); - if (aRefLength) { - for (int i = 0; i < aRefLength; i++) { - _PTR(SObject) firstSO( aReferences[i] ); - _PTR(SComponent) aComponent = firstSO->GetFatherComponent(); - QString type = aComponent->ComponentDataType().c_str(); - if ( type == "SMESH" ) - return true; - } + for ( int i = 0; i < aRefLength; i++ ) + { + _PTR(SObject) firstSO( aReferences[i] ); + _PTR(SComponent) aComponent = firstSO->GetFatherComponent(); + QString type = aComponent->ComponentDataType().c_str(); + if ( type == "SMESH" ) + return true; } } - // browse through all GEOM data tree + // browse through all GEOM data tree to find an object with is not deleted and depends + // on a deleted object _PTR(ChildIterator) it ( study->NewChildIterator( comp ) ); - for ( it->InitEx( true ); it->More(); it->Next() ) { - _PTR(SObject) child( it->Value() ); - CORBA::Object_var corbaObj = GeometryGUI::ClientSObjectToObject( child ); + for ( it->InitEx( true ); it->More(); it->Next() ) + { + _PTR(SObject) child = it->Value(); + QString childID = child->GetID().c_str(); + bool deleted = objects.contains( childID ); + if ( deleted ) + continue; // deleted object + + CORBA::Object_var corbaObj = GeometryGUI::ClientSObjectToObject( child ); GEOM::GEOM_Object_var geomObj = GEOM::GEOM_Object::_narrow( corbaObj ); - if( CORBA::is_nil( geomObj ) ) + if ( CORBA::is_nil( geomObj ) ) continue; - GEOM::ListOfGBO_var list = geomObj->GetDependency(); - if( list->length() == 0 ) - continue; + GEOM::ListOfGBO_var dep = geomObj->GetDependency(); // child depends on dep + for( CORBA::ULong i = 0; i < dep->length(); i++ ) + { + CORBA::String_var id = dep[i]->GetStudyEntry(); + bool depends = objects.contains( id.in() ); // depends on deleted - for( int i = 0; i < list->length(); i++ ) { - bool depends = false; - bool deleted = false; QMap::Iterator git; - for ( git = gobjects.begin(); git != gobjects.end() && ( !depends || !deleted ); ++git ) { - depends = depends || list[i]->_is_equivalent( *git ); - deleted = deleted || git.key() == child->GetID().c_str() ;//geomObj->_is_equivalent( *git ); + for ( git = gobjects.begin(); git != gobjects.end() && ( !depends || !deleted ); ++git ) + { + depends = depends || dep[i]->_is_equivalent( *git ); + deleted = deleted || git.key() == childID ;//geomObj->_is_equivalent( *git ) } if ( depends && !deleted ) return true; @@ -150,11 +158,11 @@ static bool inUse( _PTR(Study) study, const QString& component, const QMap& geomObjList, +static void getGeomChildrenAndFolders( _PTR(SObject) theSO, + QMap& geomObjList, QMap& folderList ) { if ( !theSO ) return; - _PTR(Study) aStudy = theSO->GetStudy(); + _PTR(Study) aStudy = SalomeApp_Application::getStudy(); if ( !aStudy ) return; _PTR(UseCaseBuilder) aUseCaseBuilder = aStudy->GetUseCaseBuilder(); @@ -182,7 +190,7 @@ static void getGeomChildrenAndFolders( _PTR(SObject) theSO, // purpose : Constructor //======================================================================= GEOMToolsGUI::GEOMToolsGUI( GeometryGUI* parent ) -: GEOMGUI( parent ) + : GEOMGUI( parent ) { } @@ -198,7 +206,7 @@ GEOMToolsGUI::~GEOMToolsGUI() // function : OnGUIEvent() // purpose : //======================================================================= -bool GEOMToolsGUI::OnGUIEvent(int theCommandID, SUIT_Desktop* parent) +bool GEOMToolsGUI::OnGUIEvent(int theCommandID, SUIT_Desktop* /*parent*/) { getGeometryGUI()->EmitSignalDeactivateDialog(); @@ -327,7 +335,7 @@ bool GEOMToolsGUI::OnGUIEvent(int theCommandID, SUIT_Desktop* parent) // function : OnGUIEvent() // purpose : //======================================================================= -bool GEOMToolsGUI::OnGUIEvent(int theCommandID, SUIT_Desktop* parent, const QVariant& theParam ) +bool GEOMToolsGUI::OnGUIEvent(int theCommandID, SUIT_Desktop* /*parent*/, const QVariant& theParam ) { getGeometryGUI()->EmitSignalDeactivateDialog(); @@ -355,8 +363,7 @@ void GEOMToolsGUI::OnEditDelete() return; LightApp_SelectionMgr* aSelMgr = app->selectionMgr(); - SalomeApp_Study* appStudy = dynamic_cast( app->activeStudy() ); - if ( !aSelMgr || !appStudy ) + if ( !aSelMgr ) return; // get selection @@ -364,7 +371,7 @@ void GEOMToolsGUI::OnEditDelete() if ( selected.IsEmpty() ) return; - _PTR(Study) aStudy = appStudy->studyDS(); + _PTR(Study) aStudy = SalomeApp_Application::getStudy(); _PTR(UseCaseBuilder) aUseCaseBuilder = aStudy->GetUseCaseBuilder(); // check if study is locked @@ -391,7 +398,7 @@ void GEOMToolsGUI::OnEditDelete() continue; // invalid object // ... QString entry = anIObject->getEntry(); - _PTR(SObject) obj = aStudy->FindObjectID( entry.toLatin1().data() ); + _PTR(SObject) obj = aStudy->FindObjectID( entry.toUtf8().data() ); // check parent component QString parentComp = getParentComponent( obj ); if ( parentComp != geomComp ) { @@ -444,6 +451,8 @@ void GEOMToolsGUI::OnEditDelete() if ( !dlg.exec() ) return; // operation is cancelled by user + SUIT_OverrideCursor wc; + // get currently opened views QList views; SALOME_View* view; @@ -457,11 +466,12 @@ void GEOMToolsGUI::OnEditDelete() } _PTR(StudyBuilder) aStudyBuilder (aStudy->NewBuilder()); - GEOM_Displayer* disp = new GEOM_Displayer( appStudy ); + GEOM_Displayer disp; + bool toUpdateColorScale = disp.SetUpdateColorScale( false ); // IPAL54049 if ( isComponentSelected ) { // GEOM component is selected: delete all objects recursively - _PTR(SObject) comp = aStudy->FindObjectID( geomComp.toLatin1().data() ); + _PTR(SObject) comp = aStudy->FindObjectID( geomComp.toUtf8().data() ); if ( !comp ) return; _PTR(ChildIterator) it ( aStudy->NewChildIterator( comp ) ); @@ -469,7 +479,7 @@ void GEOMToolsGUI::OnEditDelete() for ( it->InitEx( false ); it->More(); it->Next() ) { _PTR(SObject) child( it->Value() ); // remove object from GEOM engine - removeObjectWithChildren( child, aStudy, views, disp ); + removeObjectWithChildren( child, views, &disp ); // remove object from study aStudyBuilder->RemoveObjectWithChildren( child ); // remove object from use case tree @@ -478,7 +488,7 @@ void GEOMToolsGUI::OnEditDelete() } else { // GEOM component is not selected: check if selected objects are in use - if ( inUse( aStudy, geomComp, allDeleted ) && + if ( inUse( geomComp, allDeleted ) && SUIT_MessageBox::question( app->desktop(), QObject::tr("WRN_WARNING"), QObject::tr("DEP_OBJECT"), @@ -489,9 +499,9 @@ void GEOMToolsGUI::OnEditDelete() // ... and then delete all objects QMap::Iterator it; for ( it = toBeDeleted.begin(); it != toBeDeleted.end(); ++it ) { - _PTR(SObject) obj ( aStudy->FindObjectID( it.key().toLatin1().data() ) ); + _PTR(SObject) obj ( aStudy->FindObjectID( it.key().toUtf8().data() ) ); // remove object from GEOM engine - removeObjectWithChildren( obj, aStudy, views, disp ); + removeObjectWithChildren( obj, views, &disp ); // remove objects from study aStudyBuilder->RemoveObjectWithChildren( obj ); // remove object from use case tree @@ -499,9 +509,9 @@ void GEOMToolsGUI::OnEditDelete() } // ... and then delete all folders for ( it = toBeDelFolders.begin(); it != toBeDelFolders.end(); ++it ) { - _PTR(SObject) obj ( aStudy->FindObjectID( it.key().toLatin1().data() ) ); + _PTR(SObject) obj ( aStudy->FindObjectID( it.key().toUtf8().data() ) ); // remove object from GEOM engine - removeObjectWithChildren( obj, aStudy, views, disp ); + removeObjectWithChildren( obj, views, &disp ); // remove objects from study aStudyBuilder->RemoveObjectWithChildren( obj ); // remove object from use case tree @@ -509,6 +519,7 @@ void GEOMToolsGUI::OnEditDelete() } } + disp.SetUpdateColorScale( toUpdateColorScale ); // IPAL54049 selected.Clear(); aSelMgr->setSelectedObjects( selected ); getGeometryGUI()->updateObjBrowser(); @@ -520,15 +531,15 @@ void GEOMToolsGUI::OnEditDelete() // purpose : used by OnEditDelete() method //===================================================================================== void GEOMToolsGUI::removeObjectWithChildren(_PTR(SObject) obj, - _PTR(Study) aStudy, QList views, GEOM_Displayer* disp) { + _PTR(Study) aStudy = SalomeApp_Application::getStudy(); // iterate through all children of obj for (_PTR(ChildIterator) it (aStudy->NewChildIterator(obj)); it->More(); it->Next()) { // for (_PTR(UseCaseIterator) it (aStudy->GetUseCaseBuilder()->GetUseCaseIterator(obj)); it->More(); it->Next()) { _PTR(SObject) child (it->Value()); - removeObjectWithChildren(child, aStudy, views, disp); + removeObjectWithChildren(child, views, disp); } // erase object and remove it from engine @@ -572,8 +583,7 @@ void GEOMToolsGUI::deactivate() { SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() ); if ( app ) { - SalomeApp_Study* appStudy = dynamic_cast( app->activeStudy() ); - GEOM_Displayer aDisp (appStudy); + GEOM_Displayer aDisp; aDisp.GlobalSelection(); getGeometryGUI()->setLocalSelectionMode(GEOM_ALLOBJECTS); }