Salome HOME
Lot 2: change bathy associated to natural object propagated to all cases without...
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_ImmersibleZoneOp.cxx
index bf8ff273f62b8e797c373185f0a46397c01ffb8e..d34c908ea9deeae49e771728bad05e60a8c872cd 100644 (file)
@@ -45,6 +45,8 @@
 #include <TopoDS_Wire.hxx>
 
 #include <QApplication>
+#define _DEVDEBUG_
+#include "HYDRO_trace.hxx"
 
 HYDROGUI_ImmersibleZoneOp::HYDROGUI_ImmersibleZoneOp( HYDROGUI_Module* theModule,
                                                       const bool theIsEdit )
@@ -188,8 +190,25 @@ bool HYDROGUI_ImmersibleZoneOp::processApply( int& theUpdateFlags,
     aZoneObj->SetBorderColor( aZoneObj->DefaultBorderColor() );
   }
 
-  aZoneObj->SetPolyline( aZonePolyline );
-  aZoneObj->SetAltitudeObject( aZoneBathymetry );
+  bool isPolylineChanged = true;
+  if (aZonePolyline && aZoneObj->GetPolyline() && (aZoneObj->GetPolyline()->GetName() == aZonePolyline->GetName()))
+  {
+      isPolylineChanged =false;
+      DEBTRACE("polyline unchanged");
+  }
+  else
+  {
+      if (aZonePolyline) DEBTRACE(aZonePolyline->GetName().toStdString());
+      if (aZoneObj->GetPolyline()) DEBTRACE(aZoneObj->GetPolyline()->GetName().toStdString());
+      aZoneObj->SetPolyline( aZonePolyline );
+  }
+  bool isBathymetryChanged = true;
+  if (aZoneBathymetry && aZoneObj->GetAltitudeObject() && IsEqual(aZoneObj->GetAltitudeObject(), aZoneBathymetry))
+  {
+      isBathymetryChanged = false;
+      DEBTRACE("bathymetry unchanged");
+  }
+  else aZoneObj->SetAltitudeObject( aZoneBathymetry );
   aZoneObj->Update();
 
   closePreview();
@@ -205,6 +224,39 @@ bool HYDROGUI_ImmersibleZoneOp::processApply( int& theUpdateFlags,
 
   theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced | UF_VTKViewer;
 
+  if (isBathymetryChanged)
+  {
+    DEBTRACE("bathymetry changed on " << anObjectName.toStdString());
+    // Find immersibles objects referenced by all calculation case zones and check if they correspond to the one modified 
+    HYDROData_SequenceOfObjects zoneList = doc()->CollectAllObjects();
+    for (int i=1; i<=zoneList.Size(); i++ )
+    {
+        //DEBTRACE("    --- entity: " << zoneList(i)->GetName().toStdString() << " " << zoneList(i)->GetKind());
+        Handle(HYDROData_Zone) aZone = Handle(HYDROData_Zone)::DownCast( zoneList(i) );
+        if (aZone.IsNull())
+            continue;
+        DEBTRACE("  zone tested: " << aZone->GetName().toStdString());
+        HYDROData_SequenceOfObjects aSeq = aZone->GetObjects();
+        HYDROData_SequenceOfObjects::Iterator anIter( aSeq );
+        for ( ; anIter.More(); anIter.Next() )
+        {
+            Handle(HYDROData_Entity) aMergeObject;
+            Handle(HYDROData_Object) aRefGeomObj = Handle(HYDROData_Object)::DownCast( anIter.Value() );
+            if ( !aRefGeomObj.IsNull() )
+            {
+                DEBTRACE("    aRefGeomObj " << aRefGeomObj->GetName().toStdString());
+                if (aRefGeomObj->GetName() == anObjectName)
+                {
+                     DEBTRACE("      BINGO! modify altitude object in zone");
+                     aMergeObject = aRefGeomObj->GetAltitudeObject();
+                     aZone->SetMergeObject( aMergeObject );
+                     break;
+                }
+            }            
+        }
+      
+    }
+  }
   return true;
 }