0021551: EDF 1452 SMESH: referenced object can be deleted

procect from deletion a mesh object referenced from outside
This commit is contained in:
eap 2012-04-16 11:28:51 +00:00
parent 43db13f33a
commit 8662de8ce8
2 changed files with 112 additions and 90 deletions

View File

@ -1579,10 +1579,12 @@
SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
// Put the whole hierarchy of sub-objects of the selected SO's into a list and
// then treat them all starting from the deepest objects (at list back)
std::list< _PTR(SObject) > listSO;
SALOME_ListIteratorOfListIO It(selected);
aStudyBuilder->NewCommand(); // There is a transaction
for( ; It.More(); It.Next()){ // loop on selected IO's
for( ; It.More(); It.Next()) // loop on selected IO's
{
Handle(SALOME_InteractiveObject) IObject = It.Value();
if(IObject->hasEntry()) {
_PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
@ -1598,10 +1600,6 @@
if ( aSO && aSO->ReferencedObject( aRefSObject ) )
aSO = aRefSObject; // Delete main Object instead of reference
// put the whole hierarchy of sub-objects of the selected SO into a list and
// then treat them all starting from the deepest objects (at list back)
std::list< _PTR(SObject) > listSO;
listSO.push_back( aSO );
std::list< _PTR(SObject) >::iterator itSO = listSO.begin();
for ( ; itSO != listSO.end(); ++itSO ) {
@ -1609,11 +1607,32 @@
for (it->InitEx(false); it->More(); it->Next())
listSO.push_back( it->Value() );
}
}
}
// Check if none of objects to delete is referred from outside
std::list< _PTR(SObject) >::reverse_iterator ritSO;
for ( ritSO = listSO.rbegin(); ritSO != listSO.rend(); ++ritSO )
{
_PTR(SObject) SO = *ritSO;
if ( !SO ) continue;
std::vector<_PTR(SObject)> aReferences = aStudy->FindDependances( *ritSO );
for (size_t i = 0; i < aReferences.size(); i++) {
_PTR(SComponent) aComponent = aReferences[i]->GetFatherComponent();
std::string type = aComponent->ComponentDataType();
if ( type != "SMESH" )
{
SUIT_MessageBox::warning( anApp->desktop(),
QObject::tr("WRN_WARNING"),
QObject::tr("DEP_OBJECT") );
return; // outside SMESH, there is an object depending on a SMESH object
}
}
}
// treat SO's in the list starting from the back
std::list< _PTR(SObject) >::reverse_iterator ritSO = listSO.rbegin();
for ( ; ritSO != listSO.rend(); ++ritSO ) {
// Treat SO's in the list starting from the back
aStudyBuilder->NewCommand(); // There is a transaction
for ( ritSO = listSO.rbegin(); ritSO != listSO.rend(); ++ritSO )
{
_PTR(SObject) SO = *ritSO;
if ( !SO ) continue;
std::string anEntry = SO->GetID();
@ -1652,7 +1671,7 @@
SMESH::ModifiedMesh(aMeshSO, false, aMesh->NbNodes()==0);
}
else {
IObject = new SALOME_InteractiveObject
Handle(SALOME_InteractiveObject) IObject = new SALOME_InteractiveObject
( anEntry.c_str(), engineIOR().toLatin1().data(), SO->GetName().c_str() );
QString objType = CheckTypeObject(IObject);
if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
@ -1668,8 +1687,6 @@
}
}
} /* listSO back loop */
} /* IObject->hasEntry() */
} /* more/next */
aStudyBuilder->CommitCommand();
@ -1679,7 +1696,7 @@
SMESHGUI::GetSMESHGUI()->updateObjBrowser();
}
//}
//} namespace
extern "C" {
SMESHGUI_EXPORT CAM_Module* createModule()

View File

@ -3665,6 +3665,11 @@ Input value precision can be adjusted using
<source>MESH_LOADING_MSG_FINISHED</source>
<translation>Mesh %0 loading done</translation>
</message>
<message>
<source>DEP_OBJECT</source>
<translation>Selected object has been used to create another one.
It can&apos;t be deleted </translation>
</message>
</context>
<context>
<name>SMESHGUI_GroupDlg</name>