Salome HOME
TShell cannot be disconnected; use TCompound of shells/faces instead
[modules/hydro.git] / src / HYDROData / HYDROData_CalculationCase.cxx
index 6c4239054597b9bc78597bc808343bfec3061902..34b413fa97e92e229ec27e6076e0ec6646ad57a5 100644 (file)
 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 
-#ifdef WIN32
-  #pragma warning ( disable: 4251 )
-#endif
-
 #include "HYDROData_CalculationCase.h"
 #include "HYDROData_ArtificialObject.h"
 #include "HYDROData_IAltitudeObject.h"
 #include "HYDROData_NaturalObject.h"
 #include "HYDROData_PolylineXY.h"
 #include "HYDROData_StricklerTable.h"
+#include "HYDROData_LandCoverMap.h"
 #include "HYDROData_SplittedShapesGroup.h"
 #include "HYDROData_Region.h"
 #include "HYDROData_Tool.h"
 #include "HYDROData_GeomTool.h"
 
+#ifdef WIN32
+  #pragma warning ( disable: 4251 )
+#endif
+
 #ifndef LIGHT_MODE
 #include <GEOMBase.h>
 #endif
 
+#ifdef WIN32
+  #pragma warning ( default: 4251 )
+#endif
+
 #include <QSet>
 
 #include <TopoDS.hxx>
 #include <BRepBuilderAPI_MakeVertex.hxx>
 #endif
 
-#ifdef WIN32
-  #pragma warning ( default: 4251 )
-#endif
-
 #define EXPORT_NAME "HYDRO_" + GetName()
 
 IMPLEMENT_STANDARD_HANDLE(HYDROData_CalculationCase, HYDROData_Entity)
 IMPLEMENT_STANDARD_RTTIEXT(HYDROData_CalculationCase, HYDROData_Entity)
 
 HYDROData_CalculationCase::HYDROData_CalculationCase()
-: HYDROData_Entity()
+: HYDROData_Entity( Geom_2d_and_groups )
 {
 }
 
@@ -244,6 +245,9 @@ HYDROData_SequenceOfObjects HYDROData_CalculationCase::GetAllReferenceObjects()
   if ( !aBoundaryPolyline.IsNull() )
     aResSeq.Append( aBoundaryPolyline );
 
+  HYDROData_SequenceOfObjects aSeqOfGeomObjs = GetGeometryObjects();
+  aResSeq.Append( aSeqOfGeomObjs );
+
   // Regions
   HYDROData_SequenceOfObjects aSeqOfRegions = GetRegions();
   aResSeq.Append( aSeqOfRegions );
@@ -449,7 +453,7 @@ bool HYDROData_CalculationCase::AddGeometryObject( const Handle(HYDROData_Object
   AddReferenceObject( theObject, DataTag_GeometryObject );
   
   // Indicate model of the need to update splitting
-  SetToUpdate( true );
+  Changed( Geom_2d );
 
   return true;
 }
@@ -467,7 +471,7 @@ void HYDROData_CalculationCase::RemoveGeometryObject( const Handle(HYDROData_Obj
   RemoveReferenceObject( theObject->Label(), DataTag_GeometryObject );
 
   // Indicate model of the need to update splitting
-  SetToUpdate( true );
+  Changed( Geom_2d );
 }
 
 void HYDROData_CalculationCase::RemoveGeometryObjects()
@@ -475,7 +479,7 @@ void HYDROData_CalculationCase::RemoveGeometryObjects()
   ClearReferenceObjects( DataTag_GeometryObject );
 
   // Indicate model of the need to update splitting
-  SetToUpdate( true );
+  Changed( Geom_2d );
 }
 
 bool HYDROData_CalculationCase::AddGeometryGroup( const Handle(HYDROData_ShapesGroup)& theGroup )
@@ -489,7 +493,7 @@ bool HYDROData_CalculationCase::AddGeometryGroup( const Handle(HYDROData_ShapesG
   AddReferenceObject( theGroup, DataTag_GeometryGroup );
   
   // Indicate model of the need to update splitting
-  SetToUpdate( true );
+  Changed( Geom_Groups );
 
   return true;
 }
@@ -507,7 +511,7 @@ void HYDROData_CalculationCase::RemoveGeometryGroup( const Handle(HYDROData_Shap
   RemoveReferenceObject( theGroup->Label(), DataTag_GeometryGroup );
 
   // Indicate model of the need to update splitting
-  SetToUpdate( true );
+  Changed( Geom_Groups );
 }
 
 void HYDROData_CalculationCase::RemoveGeometryGroups()
@@ -515,7 +519,7 @@ void HYDROData_CalculationCase::RemoveGeometryGroups()
   ClearReferenceObjects( DataTag_GeometryGroup );
 
   // Indicate model of the need to update splitting
-  SetToUpdate( true );
+  Changed( Geom_Groups );
 }
 
 void HYDROData_CalculationCase::SetBoundaryPolyline( const Handle(HYDROData_PolylineXY)& thePolyline )
@@ -525,7 +529,8 @@ void HYDROData_CalculationCase::SetBoundaryPolyline( const Handle(HYDROData_Poly
   SetReferenceObject( thePolyline, DataTag_Polyline );
 
   // Indicate model of the need to update zones splitting
-  SetToUpdate( !IsEqual( aPrevPolyline, thePolyline ) || IsMustBeUpdated() );
+  if( !IsEqual( aPrevPolyline, thePolyline ) )
+    Changed( Geom_2d );
 }
 
 Handle(HYDROData_PolylineXY) HYDROData_CalculationCase::GetBoundaryPolyline() const
@@ -541,7 +546,7 @@ void HYDROData_CalculationCase::RemoveBoundaryPolyline()
   ClearReferenceObjects( DataTag_Polyline );
 
   // Indicate model of the need to update zones splitting
-  SetToUpdate( !aPrevPolyline.IsNull() || IsMustBeUpdated() );
+  Changed( Geom_2d );
 }
 
 void HYDROData_CalculationCase::SetStricklerTable( const Handle(HYDROData_StricklerTable)& theStricklerTable )
@@ -551,7 +556,8 @@ void HYDROData_CalculationCase::SetStricklerTable( const Handle(HYDROData_Strick
   SetReferenceObject( theStricklerTable, DataTag_StricklerTable );
 
   // Indicate model of the need to update land covers partition
-  SetToUpdate( !IsEqual( aPrevStricklerTable, theStricklerTable ) || IsMustBeUpdated() );
+  if( !IsEqual( aPrevStricklerTable, theStricklerTable ) )
+    Changed( Geom_No );
 }
 
 Handle(HYDROData_StricklerTable) HYDROData_CalculationCase::GetStricklerTable() const
@@ -567,11 +573,26 @@ void HYDROData_CalculationCase::RemoveStricklerTable()
   ClearReferenceObjects( DataTag_StricklerTable );
 
   // Indicate model of the need to update land covers partition
-  SetToUpdate( !aPrevStricklerTable.IsNull() || IsMustBeUpdated() );
+  Changed( Geom_No );
+}
+
+Handle(HYDROData_LandCoverMap) HYDROData_CalculationCase::GetLandCoverMap() const
+{
+  Handle(HYDROData_LandCoverMap) aMap = Handle(HYDROData_LandCoverMap)::DownCast(
+    GetReferenceObject( DataTag_LandCoverMap ) );
+  return aMap;
+}
+
+void HYDROData_CalculationCase::SetLandCoverMap( const Handle(HYDROData_LandCoverMap)& theMap )
+{
+  SetReferenceObject( theMap, DataTag_LandCoverMap );
 }
 
 Handle(HYDROData_Region) HYDROData_CalculationCase::AddNewRegion( const Handle(HYDROData_Zone)& theZone )
 {
+  Changed( Geom_No );
+  Changed( Geom_No );
+  Changed( Geom_No );
   Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab );
   Handle(HYDROData_Region) aNewRegion = addNewRegion( aDocument, CALCULATION_REGIONS_PREF );
   if ( aNewRegion.IsNull() )
@@ -827,8 +848,15 @@ NCollection_Sequence<double> HYDROData_CalculationCase::GetAltitudesForPoints(
 
 double HYDROData_CalculationCase::GetStricklerCoefficientForPoint( const gp_XY& thePoint ) const
 {
-  //TODO: #652
-  return 0.0;
+  Handle( HYDROData_LandCoverMap ) aMap = GetLandCoverMap();
+  Handle( HYDROData_StricklerTable ) aTable = GetStricklerTable();
+  if( aMap.IsNull() )
+    return 0.0;
+
+  QString aType;
+  aMap->FindByPoint( thePoint, aType );
+  double aCoeff = aTable->Get( aType, 0.0 );
+  return aCoeff;
 }
 
 Handle(HYDROData_Region) HYDROData_CalculationCase::GetRegionFromPoint( const gp_XY& thePoint ) const
@@ -1174,7 +1202,7 @@ void HYDROData_CalculationCase::ClearRules( HYDROData_CalculationCase::DataTag t
 
   // Indicate model of the need to update splitting
   if ( theIsSetToUpdate ) {
-    SetToUpdate( true );
+    Changed( Geom_2d );
   }
 }
 
@@ -1188,7 +1216,7 @@ void HYDROData_CalculationCase::AddRule( const Handle(HYDROData_Entity)&    theO
   HYDROData_PriorityQueue::AddRule( aRulesLab, theObject1, thePriority, theObject2, theMergeType );
 
   // Indicate model of the need to update splitting
-  SetToUpdate( true );
+  Changed( Geom_2d );
 }
 
 QString HYDROData_CalculationCase::DumpRules() const
@@ -1203,7 +1231,7 @@ void HYDROData_CalculationCase::SetAssignmentMode( AssignmentMode theMode )
   TDataStd_Integer::Set( aModeLab, ( int ) theMode );
 
   // Indicate model of the need to update splitting
-  SetToUpdate( true );
+  Changed( Geom_2d );
 }
 
 HYDROData_CalculationCase::AssignmentMode HYDROData_CalculationCase::GetAssignmentMode() const