mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2025-02-02 02:30:32 +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,98 +1579,115 @@
|
|||||||
|
|
||||||
SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
|
SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
|
||||||
|
|
||||||
SALOME_ListIteratorOfListIO It(selected);
|
// 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)
|
||||||
aStudyBuilder->NewCommand(); // There is a transaction
|
std::list< _PTR(SObject) > listSO;
|
||||||
for( ; It.More(); It.Next()){ // loop on selected IO's
|
SALOME_ListIteratorOfListIO It(selected);
|
||||||
Handle(SALOME_InteractiveObject) IObject = It.Value();
|
for( ; It.More(); It.Next()) // loop on selected IO's
|
||||||
if(IObject->hasEntry()) {
|
{
|
||||||
_PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
|
Handle(SALOME_InteractiveObject) IObject = It.Value();
|
||||||
|
if(IObject->hasEntry()) {
|
||||||
// disable removal of "SMESH" component object
|
_PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
|
||||||
if(aSO->FindAttribute(anAttr, "AttributeIOR")){
|
|
||||||
anIOR = anAttr;
|
// disable removal of "SMESH" component object
|
||||||
if ( engineIOR() == anIOR->Value().c_str() )
|
if(aSO->FindAttribute(anAttr, "AttributeIOR")){
|
||||||
continue;
|
anIOR = anAttr;
|
||||||
}
|
if ( engineIOR() == anIOR->Value().c_str() )
|
||||||
//Check the referenced object
|
continue;
|
||||||
_PTR(SObject) aRefSObject;
|
}
|
||||||
if ( aSO && aSO->ReferencedObject( aRefSObject ) )
|
//Check the referenced object
|
||||||
aSO = aRefSObject; // Delete main Object instead of reference
|
_PTR(SObject) aRefSObject;
|
||||||
|
if ( aSO && aSO->ReferencedObject( aRefSObject ) )
|
||||||
// put the whole hierarchy of sub-objects of the selected SO into a list and
|
aSO = aRefSObject; // Delete main Object instead of reference
|
||||||
// then treat them all starting from the deepest objects (at list back)
|
|
||||||
|
listSO.push_back( aSO );
|
||||||
std::list< _PTR(SObject) > listSO;
|
std::list< _PTR(SObject) >::iterator itSO = listSO.begin();
|
||||||
listSO.push_back( aSO );
|
for ( ; itSO != listSO.end(); ++itSO ) {
|
||||||
std::list< _PTR(SObject) >::iterator itSO = listSO.begin();
|
_PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
|
||||||
for ( ; itSO != listSO.end(); ++itSO ) {
|
for (it->InitEx(false); it->More(); it->Next())
|
||||||
_PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
|
listSO.push_back( it->Value() );
|
||||||
for (it->InitEx(false); it->More(); it->Next())
|
}
|
||||||
listSO.push_back( it->Value() );
|
}
|
||||||
}
|
}
|
||||||
|
// Check if none of objects to delete is referred from outside
|
||||||
// treat SO's in the list starting from the back
|
std::list< _PTR(SObject) >::reverse_iterator ritSO;
|
||||||
|
for ( ritSO = listSO.rbegin(); ritSO != listSO.rend(); ++ritSO )
|
||||||
std::list< _PTR(SObject) >::reverse_iterator ritSO = listSO.rbegin();
|
{
|
||||||
for ( ; ritSO != listSO.rend(); ++ritSO ) {
|
_PTR(SObject) SO = *ritSO;
|
||||||
_PTR(SObject) SO = *ritSO;
|
if ( !SO ) continue;
|
||||||
if ( !SO ) continue;
|
std::vector<_PTR(SObject)> aReferences = aStudy->FindDependances( *ritSO );
|
||||||
std::string anEntry = SO->GetID();
|
for (size_t i = 0; i < aReferences.size(); i++) {
|
||||||
|
_PTR(SComponent) aComponent = aReferences[i]->GetFatherComponent();
|
||||||
/** Erase graphical object **/
|
std::string type = aComponent->ComponentDataType();
|
||||||
if(SO->FindAttribute(anAttr, "AttributeIOR")){
|
if ( type != "SMESH" )
|
||||||
ViewManagerList aViewMenegers = anApp->viewManagers();
|
{
|
||||||
ViewManagerList::const_iterator it = aViewMenegers.begin();
|
SUIT_MessageBox::warning( anApp->desktop(),
|
||||||
for( ; it != aViewMenegers.end(); it++) {
|
QObject::tr("WRN_WARNING"),
|
||||||
SUIT_ViewManager* vm = *it;
|
QObject::tr("DEP_OBJECT") );
|
||||||
int nbSf = vm ? vm->getViewsCount() : 0;
|
return; // outside SMESH, there is an object depending on a SMESH object
|
||||||
if(vm) {
|
}
|
||||||
QVector<SUIT_ViewWindow*> aViews = vm->getViews();
|
}
|
||||||
for(int i = 0; i < nbSf; i++){
|
}
|
||||||
SUIT_ViewWindow *sf = aViews[i];
|
|
||||||
if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.c_str())){
|
// Treat SO's in the list starting from the back
|
||||||
SMESH::RemoveActor(sf,anActor);
|
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();
|
||||||
|
|
||||||
|
/** Erase graphical object **/
|
||||||
|
if(SO->FindAttribute(anAttr, "AttributeIOR")){
|
||||||
|
ViewManagerList aViewMenegers = anApp->viewManagers();
|
||||||
|
ViewManagerList::const_iterator it = aViewMenegers.begin();
|
||||||
|
for( ; it != aViewMenegers.end(); it++) {
|
||||||
|
SUIT_ViewManager* vm = *it;
|
||||||
|
int nbSf = vm ? vm->getViewsCount() : 0;
|
||||||
|
if(vm) {
|
||||||
|
QVector<SUIT_ViewWindow*> aViews = vm->getViews();
|
||||||
|
for(int i = 0; i < nbSf; i++){
|
||||||
|
SUIT_ViewWindow *sf = aViews[i];
|
||||||
|
if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.c_str())){
|
||||||
|
SMESH::RemoveActor(sf,anActor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/** Remove an object from data structures **/
|
}
|
||||||
SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
|
}
|
||||||
SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
|
/** Remove an object from data structures **/
|
||||||
if ( !aGroup->_is_nil() ) { // DELETE GROUP
|
SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
|
||||||
SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
|
SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
|
||||||
aMesh->RemoveGroup( aGroup );
|
if ( !aGroup->_is_nil() ) { // DELETE GROUP
|
||||||
}
|
SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
|
||||||
else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
|
aMesh->RemoveGroup( aGroup );
|
||||||
SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
|
}
|
||||||
aMesh->RemoveSubMesh( aSubMesh );
|
else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
|
||||||
|
SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
|
||||||
_PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
|
aMesh->RemoveSubMesh( aSubMesh );
|
||||||
if (aMeshSO)
|
|
||||||
SMESH::ModifiedMesh(aMeshSO, false, aMesh->NbNodes()==0);
|
_PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
|
||||||
}
|
if (aMeshSO)
|
||||||
else {
|
SMESH::ModifiedMesh(aMeshSO, false, aMesh->NbNodes()==0);
|
||||||
IObject = new SALOME_InteractiveObject
|
}
|
||||||
( anEntry.c_str(), engineIOR().toLatin1().data(), SO->GetName().c_str() );
|
else {
|
||||||
QString objType = CheckTypeObject(IObject);
|
Handle(SALOME_InteractiveObject) IObject = new SALOME_InteractiveObject
|
||||||
if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
|
( anEntry.c_str(), engineIOR().toLatin1().data(), SO->GetName().c_str() );
|
||||||
SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
|
QString objType = CheckTypeObject(IObject);
|
||||||
aStudyBuilder->RemoveObjectWithChildren( SO );
|
if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
|
||||||
}
|
SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
|
||||||
else {// default action: remove SObject from the study
|
aStudyBuilder->RemoveObjectWithChildren( SO );
|
||||||
// san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
|
}
|
||||||
//SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
|
else {// default action: remove SObject from the study
|
||||||
//op->start();
|
// san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
|
||||||
aStudyBuilder->RemoveObjectWithChildren( SO );
|
//SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
|
||||||
//op->finish();
|
//op->start();
|
||||||
}
|
aStudyBuilder->RemoveObjectWithChildren( SO );
|
||||||
}
|
//op->finish();
|
||||||
} /* listSO back loop */
|
}
|
||||||
} /* IObject->hasEntry() */
|
}
|
||||||
} /* more/next */
|
} /* listSO back loop */
|
||||||
|
|
||||||
aStudyBuilder->CommitCommand();
|
aStudyBuilder->CommitCommand();
|
||||||
|
|
||||||
/* Clear any previous selection */
|
/* Clear any previous selection */
|
||||||
@ -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