mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2025-02-02 04:40:33 +05:00
0021551: EDF 1452 SMESH: referenced object can be deleted
procect from deletion a mesh object referenced from outside
This commit is contained in:
parent
43db13f33a
commit
8662de8ce8
@ -1579,10 +1579,12 @@
|
|||||||
|
|
||||||
SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
|
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);
|
SALOME_ListIteratorOfListIO It(selected);
|
||||||
|
for( ; It.More(); It.Next()) // loop on selected IO's
|
||||||
aStudyBuilder->NewCommand(); // There is a transaction
|
{
|
||||||
for( ; It.More(); It.Next()){ // loop on selected IO's
|
|
||||||
Handle(SALOME_InteractiveObject) IObject = It.Value();
|
Handle(SALOME_InteractiveObject) IObject = It.Value();
|
||||||
if(IObject->hasEntry()) {
|
if(IObject->hasEntry()) {
|
||||||
_PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
|
_PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
|
||||||
@ -1598,10 +1600,6 @@
|
|||||||
if ( aSO && aSO->ReferencedObject( aRefSObject ) )
|
if ( aSO && aSO->ReferencedObject( aRefSObject ) )
|
||||||
aSO = aRefSObject; // Delete main Object instead of reference
|
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 );
|
listSO.push_back( aSO );
|
||||||
std::list< _PTR(SObject) >::iterator itSO = listSO.begin();
|
std::list< _PTR(SObject) >::iterator itSO = listSO.begin();
|
||||||
for ( ; itSO != listSO.end(); ++itSO ) {
|
for ( ; itSO != listSO.end(); ++itSO ) {
|
||||||
@ -1609,11 +1607,32 @@
|
|||||||
for (it->InitEx(false); it->More(); it->Next())
|
for (it->InitEx(false); it->More(); it->Next())
|
||||||
listSO.push_back( it->Value() );
|
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
|
// Treat SO's in the list starting from the back
|
||||||
|
aStudyBuilder->NewCommand(); // There is a transaction
|
||||||
std::list< _PTR(SObject) >::reverse_iterator ritSO = listSO.rbegin();
|
for ( ritSO = listSO.rbegin(); ritSO != listSO.rend(); ++ritSO )
|
||||||
for ( ; ritSO != listSO.rend(); ++ritSO ) {
|
{
|
||||||
_PTR(SObject) SO = *ritSO;
|
_PTR(SObject) SO = *ritSO;
|
||||||
if ( !SO ) continue;
|
if ( !SO ) continue;
|
||||||
std::string anEntry = SO->GetID();
|
std::string anEntry = SO->GetID();
|
||||||
@ -1652,7 +1671,7 @@
|
|||||||
SMESH::ModifiedMesh(aMeshSO, false, aMesh->NbNodes()==0);
|
SMESH::ModifiedMesh(aMeshSO, false, aMesh->NbNodes()==0);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
IObject = new SALOME_InteractiveObject
|
Handle(SALOME_InteractiveObject) IObject = new SALOME_InteractiveObject
|
||||||
( anEntry.c_str(), engineIOR().toLatin1().data(), SO->GetName().c_str() );
|
( anEntry.c_str(), engineIOR().toLatin1().data(), SO->GetName().c_str() );
|
||||||
QString objType = CheckTypeObject(IObject);
|
QString objType = CheckTypeObject(IObject);
|
||||||
if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
|
if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
|
||||||
@ -1668,8 +1687,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} /* listSO back loop */
|
} /* listSO back loop */
|
||||||
} /* IObject->hasEntry() */
|
|
||||||
} /* more/next */
|
|
||||||
|
|
||||||
aStudyBuilder->CommitCommand();
|
aStudyBuilder->CommitCommand();
|
||||||
|
|
||||||
@ -1679,7 +1696,7 @@
|
|||||||
|
|
||||||
SMESHGUI::GetSMESHGUI()->updateObjBrowser();
|
SMESHGUI::GetSMESHGUI()->updateObjBrowser();
|
||||||
}
|
}
|
||||||
//}
|
//} namespace
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
SMESHGUI_EXPORT CAM_Module* createModule()
|
SMESHGUI_EXPORT CAM_Module* createModule()
|
||||||
|
@ -3665,6 +3665,11 @@ Input value precision can be adjusted using
|
|||||||
<source>MESH_LOADING_MSG_FINISHED</source>
|
<source>MESH_LOADING_MSG_FINISHED</source>
|
||||||
<translation>Mesh %0 loading done</translation>
|
<translation>Mesh %0 loading done</translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>DEP_OBJECT</source>
|
||||||
|
<translation>Selected object has been used to create another one.
|
||||||
|
It can't be deleted </translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>SMESHGUI_GroupDlg</name>
|
<name>SMESHGUI_GroupDlg</name>
|
||||||
|
Loading…
Reference in New Issue
Block a user