]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Fix for bug 10441: 'Delete' functionality for reference of curve works incorrectly.
authorjfa <jfa@opencascade.com>
Mon, 27 Mar 2006 11:39:36 +0000 (11:39 +0000)
committerjfa <jfa@opencascade.com>
Mon, 27 Mar 2006 11:39:36 +0000 (11:39 +0000)
src/VISUGUI/VisuGUI.cxx

index 0ac4663d6754f5a0691d46db18ed151efac010c2..b685e0f81df85f17633b9852e729fc72d9148345 100644 (file)
@@ -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::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);
+      }
     }
   }