From: jfa Date: Mon, 27 Mar 2006 11:39:36 +0000 (+0000) Subject: Fix for bug 10441: 'Delete' functionality for reference of curve works incorrectly. X-Git-Tag: mergeto_OCC_debug_for_3_2_0b1_07Apr06~14 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=bdf956bb312ce0ab4f29d20ce5b187ca324d76c4;p=modules%2Fvisu.git Fix for bug 10441: 'Delete' functionality for reference of curve works incorrectly. --- diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index 0ac4663d..b685e0f8 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -1092,7 +1092,8 @@ void VisuGUI:: OnDeleteObjects() { - _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this)); + SalomeApp_Study* anAppStudy = GetAppStudy(this); + _PTR(Study) aCStudy = GetCStudy(anAppStudy); if (CheckLock(aCStudy,GetDesktop(this))) return; @@ -1119,8 +1120,39 @@ OnDeleteObjects() for (i = 0; i < nbSelected; i++) { _PTR(SObject) aSObject = aCStudy->FindObjectID(entries[i]); if (aSObject) { - DeleteSObject(this, aCStudy, aSObject); - UpdateObjBrowser(this, true, aSObject); + _PTR(SObject) aRefObj; + if (aSObject->ReferencedObject(aRefObj)) { + // It can be a reference on curve, published under a container. + // In this case the curve should be removed from the container. + // See bug 10441. + CORBA::Object_var aCorbaObj = VISU::GetSelectedObj(anAppStudy, aRefObj->GetID()); + if (!CORBA::is_nil(aCorbaObj)) { + VISU::Base_var aVisuObj = VISU::Base::_narrow(aCorbaObj); + if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TCURVE) { + VISU::Curve_ptr aCurve = VISU::Curve::_narrow(aVisuObj); + _PTR(SObject) aParentSO = aSObject->GetFather(); + aCorbaObj = VISU::GetSelectedObj(anAppStudy, aParentSO->GetID()); + if (!CORBA::is_nil(aCorbaObj) && !CORBA::is_nil(aCurve)) { + aVisuObj = VISU::Base::_narrow(aCorbaObj); + if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TCONTAINER) { + // Container object + CORBA::Object_ptr aCnt = VISU::Container::_narrow(aVisuObj); + if (!CORBA::is_nil(aCnt)) { + VISU::Container_i* aContainer = + dynamic_cast(VISU::GetServant(aCnt).in()); + if (aContainer && aContainer->GetNbCurves() > 0) { + aContainer->RemoveCurve(aCurve); + UpdateObjBrowser(this, true, aParentSO); + } + } + } + } + } + } + } else { + DeleteSObject(this, aCStudy, aSObject); + UpdateObjBrowser(this, true, aSObject); + } } }