Salome HOME
Fix for the bug #255: VTK viewer is not updated after modification of objects.
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_DataModel.cxx
index 1fb7a1cca721691a06644edaa1d7b587ddd9a854..e1a64a838c2d86a0e36378a236d6eeacb3b6ad47 100644 (file)
@@ -705,6 +705,30 @@ LightApp_DataObject* HYDROGUI_DataModel::createObject( SUIT_DataObject* theParen
   return new HYDROGUI_NamedObject( theParent, theName, theParentEntry );
 }
 
+void HYDROGUI_DataModel::buildObjectPartition( SUIT_DataObject*                   theObject,
+                                               const HYDROData_SequenceOfObjects& theObjects,
+                                               const QString&                     thePartName,
+                                               const bool                         theIsCreateEmpty )
+{
+  if ( theObjects.IsEmpty() && !theIsCreateEmpty )
+    return;
+
+  HYDROGUI_DataObject* aGuiObj = dynamic_cast<HYDROGUI_DataObject*>( theObject );
+  if ( !aGuiObj )
+    return;
+
+  LightApp_DataObject* aPartSect = 
+    createObject( aGuiObj, thePartName, aGuiObj->entry() );
+
+  HYDROData_SequenceOfObjects::Iterator anIter( theObjects );
+  for ( ; anIter.More(); anIter.Next() )
+  {
+    Handle(HYDROData_Entity) anObj = anIter.Value();
+    if( !anObj.IsNull() && !anObj->IsRemoved() )
+      createObject( aPartSect, anObj, aGuiObj->entry(), false );
+  }
+}
+
 void HYDROGUI_DataModel::buildObjectTree( SUIT_DataObject* theParent,
                                           SUIT_DataObject* theObject,
                                           const QString&   theParentEntry,
@@ -728,18 +752,8 @@ void HYDROGUI_DataModel::buildObjectTree( SUIT_DataObject* theParent,
       createObject( aGuiObj, anObject3D, aGuiObj->entry(), false );
 
 #ifdef DEB_GROUPS
-    LightApp_DataObject* aGroupsSect = 
-      createObject( aGuiObj, tr( "OBJECT_GROUPS" ), aGuiObj->entry() );
-
     HYDROData_SequenceOfObjects anObjGroups = aGeomObj->GetGroups();
-    HYDROData_SequenceOfObjects::Iterator anIter( anObjGroups );
-    for ( ; anIter.More(); anIter.Next() )
-    {
-      Handle(HYDROData_ShapesGroup) anObjGroup =
-        Handle(HYDROData_ShapesGroup)::DownCast( anIter.Value() );
-      if( !anObjGroup.IsNull() && !anObjGroup->IsRemoved() )
-        createObject( aGroupsSect, anObjGroup, aGuiObj->entry(), false );
-    }
+    buildObjectPartition( aGuiObj, anObjGroups, tr( "OBJECT_GROUPS" ), false );
 #endif
   }
 
@@ -771,9 +785,9 @@ void HYDROGUI_DataModel::buildObjectTree( SUIT_DataObject* theParent,
     LightApp_DataObject* aBathSect = 
       createObject( aGuiObj, tr( "ZONE_BATHYMETRY" ), aGuiObj->entry() );
 
-    Handle(HYDROData_Bathymetry) aBathymetry = aZoneObj->GetBathymetry();
-    if ( !aBathymetry.IsNull() && !aBathymetry->IsRemoved() )
-      createObject( aBathSect, aBathymetry, aGuiObj->entry(), false );
+    Handle(HYDROData_IAltitudeObject) anAltitudeObj = aZoneObj->GetAltitudeObject();
+    if ( !anAltitudeObj.IsNull() && !anAltitudeObj->IsRemoved() )
+      createObject( aBathSect, anAltitudeObj, aGuiObj->entry(), false );
   }
   else if ( anObjectKind == KIND_POLYLINE )
   {
@@ -805,9 +819,9 @@ void HYDROGUI_DataModel::buildObjectTree( SUIT_DataObject* theParent,
     LightApp_DataObject* aBathSect = 
       createObject( aGuiObj, tr( "POLYLINE3D_BATHYMETRY" ), aGuiObj->entry() );
 
-    Handle(HYDROData_Bathymetry) aBathymetry = aPolyline3D->GetBathymetry();
-    if ( !aBathymetry.IsNull() && !aBathymetry->IsRemoved() )
-      createObject( aBathSect, aBathymetry, aGuiObj->entry(), false );
+    Handle(HYDROData_IAltitudeObject) anAltitudeObj = aPolyline3D->GetAltitudeObject();
+    if ( !anAltitudeObj.IsNull() && !anAltitudeObj->IsRemoved() )
+      createObject( aBathSect, anAltitudeObj, aGuiObj->entry(), false );
   }
   else if ( anObjectKind == KIND_CALCULATION )
   {
@@ -826,6 +840,15 @@ void HYDROGUI_DataModel::buildObjectTree( SUIT_DataObject* theParent,
       if( !aCaseRegion.IsNull() && !aCaseRegion->IsRemoved() )
         createRegion( aCaseRegionsSect, aCaseRegion, "", true, theIsInOperation );
     }
+
+#ifdef DEB_GROUPS
+    HYDROData_SequenceOfObjects aCalcGroups = aCaseObj->GetSplittedGroups();
+    buildObjectPartition( aGuiObj, aCalcGroups, tr( "OBJECT_GROUPS" ), false );
+
+    HYDROData_SequenceOfObjects aCalcSplitGroups = aCaseObj->GetSplittedGroups();
+    buildObjectPartition( aGuiObj, aCalcSplitGroups, tr( "CASE_SPLITTED_GROUPS" ), false );
+#endif
+
   }
   else if ( anObjectKind == KIND_REGION )
   {
@@ -849,6 +872,40 @@ void HYDROGUI_DataModel::buildObjectTree( SUIT_DataObject* theParent,
 
     aGuiObj->setIsValid( aProfileObj->IsValid() );
   }
+  else if ( anObjectKind == KIND_CHANNEL || anObjectKind == KIND_DIGUE )
+  {
+    Handle(HYDROData_Channel) aChannelObj =
+      Handle(HYDROData_Channel)::DownCast( aDataObj );
+
+    LightApp_DataObject* aGuideLineSect = 
+      createObject( aGuiObj, tr( "CHANNEL_GUIDE_LINE" ), aGuiObj->entry() );
+    Handle(HYDROData_Polyline3D) aGuideLine = aChannelObj->GetGuideLine();
+    if ( !aGuideLine.IsNull() && !aGuideLine->IsRemoved() ) {
+      createObject( aGuideLineSect, aGuideLine, aGuiObj->entry(), false );
+    }
+
+    LightApp_DataObject* aProfileSect = 
+      createObject( aGuiObj, tr( "CHANNEL_PROFILE" ), aGuiObj->entry() );
+    Handle(HYDROData_Profile) aProfile = aChannelObj->GetProfile();
+    if ( !aProfile.IsNull() && !aProfile->IsRemoved() ) {
+      createObject( aProfileSect, aProfile, aGuiObj->entry(), false );
+    }
+  }
+  else if ( anObjectKind == KIND_STREAM )
+  {
+    Handle(HYDROData_Stream) aStreamObj =
+      Handle(HYDROData_Stream)::DownCast( aDataObj );
+
+    LightApp_DataObject* aHydraulicAxisSect = 
+      createObject( aGuiObj, tr( "STREAM_HYDRAULIC_AXIS" ), aGuiObj->entry() );
+    Handle(HYDROData_PolylineXY) aHydraulicAxis = aStreamObj->GetHydraulicAxis();
+    if ( !aHydraulicAxis.IsNull() && !aHydraulicAxis->IsRemoved() ) {
+      createObject( aHydraulicAxisSect, aHydraulicAxis, aGuiObj->entry(), false );
+    }
+
+    HYDROData_SequenceOfObjects aProfiles = aStreamObj->GetProfiles();
+    buildObjectPartition( aGuiObj, aProfiles, tr( "STREAM_PROFILES" ), true );
+  }
 }
 
 void HYDROGUI_DataModel::buildCaseTree( SUIT_DataObject* theParent, Handle(HYDROData_CalculationCase) theCase )