]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
Lot 2: change bathy associated to natural object propagated to all cases without...
authorPaul RASCLE <paul.rascle@edf.fr>
Thu, 14 Nov 2019 15:11:16 +0000 (16:11 +0100)
committerPaul RASCLE <paul.rascle@edf.fr>
Thu, 14 Nov 2019 15:11:16 +0000 (16:11 +0100)
src/HYDROData/HYDROData_Object.cxx
src/HYDROData/HYDROData_Region.cxx
src/HYDROData/HYDROData_Zone.cxx
src/HYDROGUI/HYDROGUI_ImmersibleZoneOp.cxx
src/HYDROGUI/HYDROGUI_Zone.cxx

index 9d311e760e09792c23a3a37bb6c0b6c435a45868..0fcae54fdd9f89c088be247acff920d1815ce46d 100644 (file)
@@ -45,6 +45,7 @@ HYDROData_Object::~HYDROData_Object()
 
 void HYDROData_Object::SetName( const QString& theName )
 {
+  //DEBTRACE("SetName");
   QString anOldObjName = GetName();
   if ( anOldObjName != theName )
   {
@@ -74,6 +75,7 @@ void HYDROData_Object::SetName( const QString& theName )
 
 void HYDROData_Object::Update()
 {
+  DEBTRACE("Update");
   if( IsMustBeUpdated( Geom_2d ) )
   {
     RemoveTopShape();
@@ -88,6 +90,7 @@ void HYDROData_Object::Update()
 
 HYDROData_SequenceOfObjects HYDROData_Object::GetAllReferenceObjects() const
 {
+  //DEBTRACE("GetAllReferenceObjects");
   HYDROData_SequenceOfObjects aResSeq = HYDROData_Entity::GetAllReferenceObjects();
 
   Handle(HYDROData_IAltitudeObject) aRefAltitude = GetAltitudeObject();
@@ -99,6 +102,7 @@ HYDROData_SequenceOfObjects HYDROData_Object::GetAllReferenceObjects() const
 
 void HYDROData_Object::Changed( Geometry theChangedGeometry )
 {
+  DEBTRACE("Changed");
   HYDROData_Entity::Changed( theChangedGeometry );
 
   Handle(HYDROData_DummyObject3D) anObject3D = GetObject3D();
@@ -108,16 +112,19 @@ void HYDROData_Object::Changed( Geometry theChangedGeometry )
 
 void HYDROData_Object::SetTopShape( const TopoDS_Shape& theShape )
 {
+  DEBTRACE("SetTopShape");
   HYDROData_Entity::SetShape( DataTag_TopShape, theShape );
 }
 
 TopoDS_Shape HYDROData_Object::GetTopShape() const
 {
+  //DEBTRACE("GetTopShape");
   return HYDROData_Entity::GetShape( DataTag_TopShape );
 }
 
 void HYDROData_Object::SetShape3D( const TopoDS_Shape& theShape )
 {
+  DEBTRACE("SetShape3D");
   HYDROData_Entity::SetShape( DataTag_Shape3D, theShape );
   // Check the object 3D existance
   checkAndSetObject3D();
@@ -125,11 +132,13 @@ void HYDROData_Object::SetShape3D( const TopoDS_Shape& theShape )
 
 TopoDS_Shape HYDROData_Object::GetShape3D() const
 {
+  //DEBTRACE("GetShape3D");
   return HYDROData_Entity::GetShape( DataTag_Shape3D );
 }
 
 Handle(HYDROData_DummyObject3D) HYDROData_Object::GetObject3D() const
 {
+  //DEBTRACE("GetObject3D");
   Handle(HYDROData_DummyObject3D) anObject;
   
   TDF_Label aLabel = myLab.FindChild( DataTag_Object3D, false );
@@ -148,6 +157,7 @@ Handle(HYDROData_DummyObject3D) HYDROData_Object::GetObject3D() const
 
 void HYDROData_Object::checkAndSetObject3D()
 {
+  DEBTRACE("checkAndSetObject3D");
   TDF_Label aLabel = myLab.FindChild( DataTag_Object3D, false );
   if ( !aLabel.IsNull() )
     return;
@@ -158,11 +168,13 @@ void HYDROData_Object::checkAndSetObject3D()
 
 HYDROData_SequenceOfObjects HYDROData_Object::GetGroups() const
 {
+  //DEBTRACE("GetGroups");
   return GetReferenceObjects( DataTag_EdgesGroup );
 }
 
 Handle(HYDROData_ShapesGroup) HYDROData_Object::GetGroup( const int theGroupId ) const
 {
+  //DEBTRACE("GetGroup");
   Handle(HYDROData_ShapesGroup) aResGroup;
 
   HYDROData_SequenceOfObjects aGroups = GetGroups();
@@ -176,6 +188,7 @@ Handle(HYDROData_ShapesGroup) HYDROData_Object::GetGroup( const int theGroupId )
 
 int HYDROData_Object::GetGroupId( const Handle(HYDROData_ShapesGroup)& theGroup ) const
 {
+  //DEBTRACE("GetGroupId");
   int aRes = -1;
 
   HYDROData_SequenceOfObjects aGroups = GetGroups();
@@ -196,10 +209,14 @@ int HYDROData_Object::GetGroupId( const Handle(HYDROData_ShapesGroup)& theGroup
 bool HYDROData_Object::SetAltitudeObject( 
   const Handle(HYDROData_IAltitudeObject)& theAltitude )
 {
+  DEBTRACE("SetAltitudeObject");
   if ( theAltitude.IsNull() )
     return false;
   
   Handle(HYDROData_IAltitudeObject) aPrevAltitude = GetAltitudeObject();
+  if (!aPrevAltitude.IsNull())
+    DEBTRACE("aPrevAltitude: " << aPrevAltitude->GetName())
+  DEBTRACE("theAltitude: " << theAltitude->GetName())
   if ( IsEqual( aPrevAltitude, theAltitude ) )
     return true;
 
@@ -214,16 +231,18 @@ bool HYDROData_Object::SetAltitudeObject(
 
 Handle(HYDROData_IAltitudeObject) HYDROData_Object::GetAltitudeObject() const
 {
+  //DEBTRACE("GetAltitudeObject");
   return Handle(HYDROData_IAltitudeObject)::DownCast( 
            GetReferenceObject( DataTag_AltitudeObject ) );
 }
 
 void HYDROData_Object::RemoveAltitudeObject()
 {
+  DEBTRACE("RemoveAltitudeObject");
   Handle(HYDROData_IAltitudeObject) aPrevAltitude = GetAltitudeObject();
   if ( aPrevAltitude.IsNull() )
     return;
-
+  DEBTRACE("aPrevAltitude: " << aPrevAltitude->GetName())
   ClearReferenceObjects( DataTag_AltitudeObject );
 
   // #636: In the case of the altitude object change the geometry of the main object is not changed,
@@ -233,36 +252,43 @@ void HYDROData_Object::RemoveAltitudeObject()
 
 void HYDROData_Object::SetFillingColor( const QColor& theColor )
 {
+  //DEBTRACE("SetFillingColor");
   SetColor( theColor, DataTag_FillingColor );
 }
 
 QColor HYDROData_Object::GetFillingColor() const
 {
+  //DEBTRACE("GetFillingColor");
   return GetColor( DefaultFillingColor(), DataTag_FillingColor );
 }
 
 void HYDROData_Object::SetBorderColor( const QColor& theColor )
 {
+  //DEBTRACE("SetBorderColor");
   SetColor( theColor, DataTag_BorderColor );
 }
 
 QColor HYDROData_Object::GetBorderColor() const
 {
+  //DEBTRACE("GetBorderColor");
   return GetColor( DefaultBorderColor(), DataTag_BorderColor );
 }
 
 QColor HYDROData_Object::DefaultFillingColor() const
 {
+  //DEBTRACE("DefaultFillingColor");
   return QColor( Qt::yellow );
 }
 
 QColor HYDROData_Object::DefaultBorderColor() const
 {
+  //DEBTRACE("DefaultBorderColor");
   return QColor( Qt::transparent );
 }
 
 QStringList HYDROData_Object::dumpObjectCreation( MapOfTreatedObjects& theTreatedObjects ) const
 {
+  DEBTRACE("dumpObjectCreation");
   QStringList aResList = HYDROData_Entity::dumpObjectCreation( theTreatedObjects );
   if ( aResList.isEmpty() )
     return aResList; //Object was not created
@@ -291,6 +317,7 @@ ObjectKind HYDROData_Object::getAltitudeObjectType() const
 
 Handle(HYDROData_IAltitudeObject) HYDROData_Object::getChildAltitudeObject() const
 {
+  //DEBTRACE("getChildAltitudeObject");
   Handle(HYDROData_IAltitudeObject) anObject;
   
   TDF_Label aLabel = myLab.FindChild( DataTag_ChildAltitudeObject, false );
@@ -309,14 +336,20 @@ Handle(HYDROData_IAltitudeObject) HYDROData_Object::getChildAltitudeObject() con
 
 void HYDROData_Object::checkAndSetAltitudeObject()
 {
+  DEBTRACE("checkAndSetAltitudeObject");
   Handle(HYDROData_Document) aDocument = HYDROData_Document::Document();
 
   ObjectKind anAltitudeObjectType = getAltitudeObjectType();
-  //DEBTRACE("HYDROData_Object::checkAndSetAltitudeObject anAltitudeObjectType="<< anAltitudeObjectType);
+  DEBTRACE("HYDROData_Object::checkAndSetAltitudeObject anAltitudeObjectType="<< anAltitudeObjectType);
   if ( anAltitudeObjectType == KIND_UNKNOWN )
+  {
+    DEBTRACE("anAltitudeObjectType == KIND_UNKNOWN");
     return; // No need to create altitude object
+  }
 
   Handle(HYDROData_IAltitudeObject) altObject = GetAltitudeObject();
+  if( !altObject.IsNull() )
+      DEBTRACE(altObject->GetName());
   if( !altObject.IsNull() && altObject->GetKind()==anAltitudeObjectType )
     return;
 
@@ -327,7 +360,7 @@ void HYDROData_Object::checkAndSetAltitudeObject()
       HYDROData_Iterator::CreateObject( aChildLabel, anAltitudeObjectType ) );
 
   QString anAltitudePref = GetName() + "_Altitude";
-  //DEBTRACE("anAltitudePref " << anAltitudePref.toStdString());
+  DEBTRACE("anAltitudePref " << anAltitudePref.toStdString());
   QString anAltitudeName = HYDROData_Tool::GenerateObjectName( aDocument, anAltitudePref );
   anAltitudeObject->SetName( anAltitudeName );
 
@@ -336,6 +369,7 @@ void HYDROData_Object::checkAndSetAltitudeObject()
 
 Handle(HYDROData_ShapesGroup) HYDROData_Object::createGroupObject()
 {
+  DEBTRACE("createGroupObject");
   TDF_Label aNewLab = myLab.FindChild( DataTag_EdgesGroup ).NewChild();
 
   Handle(HYDROData_ShapesGroup) aNewGroup =
@@ -347,6 +381,7 @@ Handle(HYDROData_ShapesGroup) HYDROData_Object::createGroupObject()
 
 void HYDROData_Object::RemoveGroupObjects()
 {
+  DEBTRACE("RemoveGroupObjects");
   TDF_Label aLabel = myLab.FindChild( DataTag_EdgesGroup, false );
   if ( !aLabel.IsNull() )
     aLabel.ForgetAllAttributes();
@@ -354,16 +389,19 @@ void HYDROData_Object::RemoveGroupObjects()
 
 void HYDROData_Object::RemoveTopShape()
 {
+  DEBTRACE("RemoveTopShape");
   HYDROData_Entity::SetShape( DataTag_TopShape, TopoDS_Shape() );
 }
 
 void HYDROData_Object::RemoveShape3D()
 {
+  DEBTRACE("RemoveShape3D");
   HYDROData_Entity::SetShape( DataTag_Shape3D, TopoDS_Shape() );
 }
 
 bool HYDROData_Object::IsSubmersible() const
 {
+  //DEBTRACE("IsSubmersible");
   Handle(TDataStd_Integer) aSubMersibleAttr;
 
   bool isSubmersible = true; //default
@@ -377,6 +415,7 @@ bool HYDROData_Object::IsSubmersible() const
 
 void HYDROData_Object::SetIsSubmersible( bool isSubmersible ) const
 {
+  DEBTRACE("SetIsSubmersible");
   Handle(TDataStd_Integer) anAttr = TDataStd_Integer::Set( myLab, isSubmersible ? 1 : 0 );
   anAttr->SetID(TDataStd_Integer::GetID());
 }
@@ -384,6 +423,7 @@ void HYDROData_Object::SetIsSubmersible( bool isSubmersible ) const
 void HYDROData_Object::GetBoundaries( QList<TopoDS_Shape>& theBoundShapes,
                                       QStringList& theBoundNames ) const
 {
+  DEBTRACE("GetBoundaries");
   HYDROData_SequenceOfObjects aGroups = GetGroups();
     HYDROData_SequenceOfObjects::Iterator anIter( aGroups );
     for ( ; anIter.More(); anIter.Next() )
index c3876616505a5a5dc3c123e92329eff369057a05..15bb8160a6ea6a840e9c0f7d6aa4fe63774ad6b9 100644 (file)
@@ -51,7 +51,7 @@
 #include "gp_Pln.hxx"
 #include "BRepTools_ReShape.hxx"
 
-//#define _DEVDEBUG_
+#define _DEVDEBUG_
 #include "HYDRO_trace.hxx"
 
 //#define DEB_GET_REGION_SHAPE
@@ -188,7 +188,7 @@ Handle(HYDROData_Zone) HYDROData_Region::addNewZone( const Handle(HYDROData_Docu
     Handle(HYDROData_Entity) aRefObject = theDoc->FindObjectByName( anObjName );
     if ( aRefObject.IsNull() )
       continue;
-
+    DEBTRACE("aRefObject name: " << aRefObject->GetName());
     aNewZone->AddObject( aRefObject );
   }
 
index 3b296621ff1d1c1b194d257e432fef1fa4392fa3..9edf3051ebd660ea5aba656950a81f0268a13bf6 100644 (file)
@@ -141,7 +141,8 @@ HYDROData_Zone::MergeType HYDROData_Zone::GetMergeType() const
 
 void HYDROData_Zone::SetMergeObject( const Handle(HYDROData_Entity)& theObject )
 {
-  //DEBTRACE("HYDROData_Zone::SetMergeObject");
+  
+  DEBTRACE("HYDROData_Zone::SetMergeObject " << theObject->GetName().toStdString());
   SetReferenceObject( theObject, DataTag_MergeObject );
 }
 
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;
 }
 
index 6da859d9a4ede9ff32f9f022bd03304fe2aef58d..9be83f895fabc17fd7508f08d31be6a88e9776c6 100644 (file)
@@ -25,6 +25,9 @@
 #include <SUIT_DataObject.h>
 #include <QSet>
 
+#define _DEVDEBUG_
+#include "HYDRO_trace.hxx"
+
 HYDROGUI_Zone::HYDROGUI_Zone( SUIT_DataObject* theParent, 
                                           Handle(HYDROData_Zone) theData,
                                           const QString& theParentEntry,
@@ -242,6 +245,7 @@ HYDROData_Zone::MergeType HYDROGUI_Zone::getMergeType() const
 
 void HYDROGUI_Zone::setMergeType( int theMergeType, QString theMergeObjectName )
 {
+  DEBTRACE("HYDROGUI_Zone::setMergeType " << theMergeType << " " << theMergeObjectName.toStdString());
   Handle(HYDROData_Zone) aZone = Handle(HYDROData_Zone)::DownCast( modelObject() );
   if ( !aZone.IsNull() )
   {
@@ -262,6 +266,7 @@ void HYDROGUI_Zone::setMergeType( int theMergeType, QString theMergeObjectName )
         if ( !aRefGeomObj.IsNull() )
         {
           // Get altitude object
+          DEBTRACE("aRefGeomObj " << aRefGeomObj->GetName().toStdString());
           aMergeObject = aRefGeomObj->GetAltitudeObject();
         }