mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2025-04-01 16:24:29 +05:00
fix bug 10638. Assure correct removal of all sub-objects of a selected one
This commit is contained in:
parent
ad80310695
commit
2e96c9ec03
@ -730,91 +730,81 @@ namespace{
|
|||||||
SALOME_ListIteratorOfListIO It(selected);
|
SALOME_ListIteratorOfListIO It(selected);
|
||||||
|
|
||||||
aStudyBuilder->NewCommand(); // There is a transaction
|
aStudyBuilder->NewCommand(); // There is a transaction
|
||||||
for(; It.More(); It.Next()){
|
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) SO = aStudy->FindObjectID(IObject->getEntry());
|
_PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
|
||||||
|
|
||||||
// disable removal of "SMESH" component object
|
// disable removal of "SMESH" component object
|
||||||
if(SO->FindAttribute(anAttr, "AttributeIOR")){
|
if(aSO->FindAttribute(anAttr, "AttributeIOR")){
|
||||||
anIOR = anAttr;
|
anIOR = anAttr;
|
||||||
if ( !strcmp( (char*)anIOR->Value().c_str(), engineIOR().latin1() ) )
|
if ( !strcmp( (char*)anIOR->Value().c_str(), engineIOR().latin1() ) )
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Erase child graphical objects */
|
// put the whole hierarchy of sub-objects of the selected SO into a list and
|
||||||
_PTR(ChildIterator) it = aStudy->NewChildIterator(SO);
|
// then treat them all starting from the deepest objects (at list back)
|
||||||
for(it->InitEx(true); it->More(); it->Next()){
|
|
||||||
_PTR(SObject) CSO = it->Value();
|
|
||||||
if(CSO->FindAttribute(anAttr, "AttributeIOR")){
|
|
||||||
anIOR = anAttr;
|
|
||||||
|
|
||||||
|
list< _PTR(SObject) > listSO;
|
||||||
|
listSO.push_back( aSO );
|
||||||
|
list< _PTR(SObject) >::iterator itSO = listSO.begin();
|
||||||
|
for ( ; itSO != listSO.end(); ++itSO ) {
|
||||||
|
_PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
|
||||||
|
for (it->InitEx(false); it->More(); it->Next())
|
||||||
|
listSO.push_back( it->Value() );
|
||||||
|
}
|
||||||
|
|
||||||
|
// treat SO's in the list starting from the back
|
||||||
|
|
||||||
|
list< _PTR(SObject) >::reverse_iterator ritSO = listSO.rbegin();
|
||||||
|
for ( ; ritSO != listSO.rend(); ++ritSO ) {
|
||||||
|
_PTR(SObject) SO = *ritSO;
|
||||||
|
if ( !SO ) continue;
|
||||||
|
string anEntry = SO->GetID();
|
||||||
|
|
||||||
|
/** Erase graphical object **/
|
||||||
|
if(SO->FindAttribute(anAttr, "AttributeIOR")){
|
||||||
QPtrVector<SUIT_ViewWindow> aViews = vm->getViews();
|
QPtrVector<SUIT_ViewWindow> aViews = vm->getViews();
|
||||||
for(int i = 0; i < nbSf; i++){
|
for(int i = 0; i < nbSf; i++){
|
||||||
SUIT_ViewWindow *sf = aViews[i];
|
SUIT_ViewWindow *sf = aViews[i];
|
||||||
CORBA::String_var anEntry = CSO->GetID().c_str();
|
if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.c_str())){
|
||||||
if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.in())){
|
|
||||||
SMESH::RemoveActor(sf,anActor);
|
SMESH::RemoveActor(sf,anActor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* Erase main graphical object */
|
/** Remove an object from data structures **/
|
||||||
QPtrVector<SUIT_ViewWindow> aViews = vm->getViews();
|
SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
|
||||||
for(int i = 0; i < nbSf; i++){
|
SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
|
||||||
SUIT_ViewWindow *sf = aViews[i];
|
if ( !aGroup->_is_nil() ) { // DELETE GROUP
|
||||||
if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,IObject->getEntry())){
|
SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
|
||||||
SMESH::RemoveActor(sf,anActor);
|
aMesh->RemoveGroup( aGroup );
|
||||||
}
|
}
|
||||||
}
|
else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
|
||||||
|
SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
|
||||||
|
aMesh->RemoveSubMesh( aSubMesh );
|
||||||
|
|
||||||
// Remove object(s) from data structures
|
_PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
|
||||||
_PTR(SObject) obj = aStudy->FindObjectID(IObject->getEntry());
|
if (aMeshSO)
|
||||||
if(obj){
|
|
||||||
SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( obj ) );
|
|
||||||
SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( obj ) );
|
|
||||||
QString objType = CheckTypeObject(IObject);
|
|
||||||
if ( !aGroup->_is_nil() ) { // DELETE GROUP
|
|
||||||
SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
|
|
||||||
aMesh->RemoveGroup( aGroup );
|
|
||||||
}
|
|
||||||
else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
|
|
||||||
SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
|
|
||||||
aMesh->RemoveSubMesh( aSubMesh );
|
|
||||||
|
|
||||||
_PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
|
|
||||||
if (aMeshSO)
|
|
||||||
SMESH::ModifiedMesh(aMeshSO, false);
|
SMESH::ModifiedMesh(aMeshSO, false);
|
||||||
}
|
}
|
||||||
else if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
|
else {
|
||||||
SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
|
IObject = new SALOME_InteractiveObject
|
||||||
aStudyBuilder->RemoveObjectWithChildren( obj );
|
( anEntry.c_str(), engineIOR().latin1(), SO->GetName().c_str() );
|
||||||
}
|
QString objType = CheckTypeObject(IObject);
|
||||||
else {// default action: remove SObject from the study
|
if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
|
||||||
// san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
|
SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
|
||||||
//SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
|
aStudyBuilder->RemoveObjectWithChildren( SO );
|
||||||
//op->start();
|
}
|
||||||
SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_nil();
|
else {// default action: remove SObject from the study
|
||||||
|
// san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
|
||||||
_PTR(ChildIterator) it = aStudy->NewChildIterator(obj);
|
//SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
|
||||||
for ( ; it->More(); it->Next() ){
|
//op->start();
|
||||||
_PTR(SObject) CSO = it->Value();
|
aStudyBuilder->RemoveObjectWithChildren( SO );
|
||||||
aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( CSO ) );
|
//op->finish();
|
||||||
if ( !aSubMesh->_is_nil() )
|
}
|
||||||
{
|
}
|
||||||
SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
|
} /* listSO back loop */
|
||||||
_PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
|
|
||||||
if (aMeshSO)
|
|
||||||
SMESH::ModifiedMesh(aMeshSO, false);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
aStudyBuilder->RemoveObjectWithChildren( obj );
|
|
||||||
//op->finish();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} /* IObject->hasEntry() */
|
} /* IObject->hasEntry() */
|
||||||
} /* more/next */
|
} /* more/next */
|
||||||
aStudyBuilder->CommitCommand();
|
aStudyBuilder->CommitCommand();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user