VisuGUI::
OnDeleteObjects()
{
- _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
+ SalomeApp_Study* anAppStudy = GetAppStudy(this);
+ _PTR(Study) aCStudy = GetCStudy(anAppStudy);
if (CheckLock(aCStudy,GetDesktop(this)))
return;
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::Container_i*>(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);
+ }
}
}