Salome HOME
mask traces
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_ImmersibleZoneOp.cxx
index 678d8059680af73ba72bbc589df2d754c376232b..e3cba24d6657a0993654c64e6a1cc8c3bb515200 100644 (file)
@@ -23,6 +23,7 @@
 #include "HYDROGUI_Module.h"
 #include "HYDROGUI_Shape.h"
 #include "HYDROGUI_Tool.h"
+#include "HYDROGUI_Tool2.h"
 #include "HYDROGUI_UpdateFlags.h"
 #include "HYDROGUI_DataObject.h"
 
@@ -44,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 )
@@ -183,12 +186,29 @@ bool HYDROGUI_ImmersibleZoneOp::processApply( int& theUpdateFlags,
 
   if ( !myIsEdit )
   {
-    aZoneObj->SetFillingColor( HYDROData_ImmersibleZone::DefaultFillingColor() );
-    aZoneObj->SetBorderColor( HYDROData_ImmersibleZone::DefaultBorderColor() );
+    aZoneObj->SetFillingColor( aZoneObj->DefaultFillingColor() );
+    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();
@@ -204,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;
 }
 
@@ -242,19 +295,19 @@ void HYDROGUI_ImmersibleZoneOp::onCreatePreview( const QString& thePolylineName
 
   if ( aViewManager && myPreviewPrs )
   {
-    QColor aFillingColor = HYDROData_ImmersibleZone::DefaultFillingColor();
-    QColor aBorderColor = HYDROData_ImmersibleZone::DefaultBorderColor();
+    QColor aFillingColor = Qt::darkBlue;
+    QColor aBorderColor = Qt::transparent;
     if ( !myEditedObject.IsNull() ) {
       aFillingColor = myEditedObject->GetFillingColor();
       aBorderColor = myEditedObject->GetBorderColor();
     }
 
-    myPreviewPrs->setFillingColor( aFillingColor, false, false );
-    myPreviewPrs->setBorderColor( aBorderColor, false, false );
     TopoDS_Face aFace;
     if( !aZoneShape.IsNull() )
       aFace = TopoDS::Face( aZoneShape );
     myPreviewPrs->setFace( aFace, true, true, "" );
+    myPreviewPrs->setFillingColor( aFillingColor, false, false );
+    myPreviewPrs->setBorderColor( aBorderColor, false, false );
   }
 
   QApplication::restoreOverrideCursor();