Salome HOME
Selector implementation for OCC viewer.
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_DataModel.cxx
index c7b0cedf601912503409c9fac4586f03d84a0a79..ba15923855300b568f22dfb160d1ca30602d7581 100644 (file)
@@ -33,6 +33,7 @@
 #include <HYDROData_Iterator.h>
 #include <HYDROData_Polyline.h>
 #include <HYDROData_VisualState.h>
+#include <HYDROData_Region.h>
 #include <HYDROData_Zone.h>
 
 #include <CAM_Application.h>
@@ -522,17 +523,23 @@ Handle(HYDROData_Document) HYDROGUI_DataModel::getDocument() const
 
 LightApp_DataObject* HYDROGUI_DataModel::createObject( SUIT_DataObject*         theParent,
                                                        Handle(HYDROData_Object) theModelObject,
-                                                       const QString&           theParentEntry )
+                                                       const QString&           theParentEntry,
+                                                       const bool               theIsBuildTree )
 {
   HYDROGUI_DataObject* aResObj = 
     new HYDROGUI_DataObject( theParent, theModelObject, theParentEntry );
-  buildObjectTree( theParent, aResObj, theParentEntry );
+  
+  if ( theIsBuildTree )
+  {
+    buildObjectTree( theParent, aResObj, theParentEntry );
+  }
+
   return aResObj;
 }
 
 LightApp_DataObject* HYDROGUI_DataModel::createObject( SUIT_DataObject* theParent,
                                                        const QString&   theName,
-                                                       const QString&   theParentEntry  )
+                                                       const QString&   theParentEntry )
 {
   return new HYDROGUI_NamedObject( theParent, theName, theParentEntry );
 }
@@ -559,7 +566,7 @@ void HYDROGUI_DataModel::buildObjectTree( SUIT_DataObject* theParent,
     {
       Handle(HYDROData_Object) aRefObj = anImageObj->Reference( anIndex );
       if ( !aRefObj.IsNull() && !aRefObj->IsRemoved() )
-        createObject( aGuiObj, aRefObj, aGuiObj->entry() );
+        createObject( aGuiObj, aRefObj, aGuiObj->entry(), false );
     }
   }
   else if ( anObjectKind == KIND_ZONE )
@@ -567,13 +574,15 @@ void HYDROGUI_DataModel::buildObjectTree( SUIT_DataObject* theParent,
     Handle(HYDROData_Zone) aZoneObj =
       Handle(HYDROData_Zone)::DownCast( aDataObj );
 
-    LightApp_DataObject* aPolylineSect = createObject( aGuiObj, tr( "ZONE_POLYLINE" ), aGuiObj->entry() );
+    LightApp_DataObject* aPolylineSect = 
+      createObject( aGuiObj, tr( "ZONE_POLYLINE" ), aGuiObj->entry() );
 
     Handle(HYDROData_Polyline) aPolyline = aZoneObj->GetPolyline();
     if ( !aPolyline.IsNull() && !aPolyline->IsRemoved() )
-      createObject( aPolylineSect, aPolyline, aGuiObj->entry() );
+      createObject( aPolylineSect, aPolyline, aGuiObj->entry(), false );
 
-    LightApp_DataObject* aBathsSect = createObject( aGuiObj, tr( "ZONE_BATHYMETRIES" ), aGuiObj->entry() );
+    LightApp_DataObject* aBathsSect = 
+      createObject( aGuiObj, tr( "ZONE_BATHYMETRIES" ), aGuiObj->entry() );
 
     HYDROData_SequenceOfObjects aZoneBaths = aZoneObj->GetBathymetries();
     HYDROData_SequenceOfObjects::Iterator aBathsIter( aZoneBaths );
@@ -582,7 +591,45 @@ void HYDROGUI_DataModel::buildObjectTree( SUIT_DataObject* theParent,
       Handle(HYDROData_Bathymetry) aRefBath =
         Handle(HYDROData_Bathymetry)::DownCast( aBathsIter.Value() );
       if( !aRefBath.IsNull() && !aRefBath->IsRemoved() )
-        createObject( aBathsSect, aRefBath, aGuiObj->entry() );
+        createObject( aBathsSect, aRefBath, aGuiObj->entry(), false );
+    }
+  }
+  else if ( anObjectKind == KIND_CALCULATION )
+  {
+    Handle(HYDROData_Calculation) aCaseObj =
+      Handle(HYDROData_Calculation)::DownCast( aDataObj );
+
+    LightApp_DataObject* aPolylineSect = 
+      createObject( aGuiObj, tr( "CASE_BND_POLYLINE" ), aGuiObj->entry() );
+
+    Handle(HYDROData_Polyline) aPolyline = aCaseObj->GetBoundaryPolyline();
+    if ( !aPolyline.IsNull() && !aPolyline->IsRemoved() )
+      createObject( aPolylineSect, aPolyline, aGuiObj->entry(), false );
+
+    LightApp_DataObject* aRefZonesSect = 
+      createObject( aGuiObj, tr( "CASE_REFERENCE_ZONES" ), aGuiObj->entry() );
+
+    HYDROData_SequenceOfObjects aRefZones = aCaseObj->GetZones();
+    HYDROData_SequenceOfObjects::Iterator anIter( aRefZones );
+    for ( ; anIter.More(); anIter.Next() )
+    {
+      Handle(HYDROData_Zone) aRefZone =
+        Handle(HYDROData_Zone)::DownCast( anIter.Value() );
+      if( !aRefZone.IsNull() && !aRefZone->IsRemoved() )
+        createObject( aRefZonesSect, aRefZone, aGuiObj->entry(), false );
+    }
+
+    LightApp_DataObject* aCaseRegionsSect = 
+      createObject( aGuiObj, tr( "CASE_REGIONS" ), aGuiObj->entry() );
+
+    HYDROData_SequenceOfObjects aCaseRegions = aCaseObj->GetRegions();
+    anIter.Init( aCaseRegions );
+    for ( ; anIter.More(); anIter.Next() )
+    {
+      Handle(HYDROData_Region) aCaseRegion =
+        Handle(HYDROData_Region)::DownCast( anIter.Value() );
+      if( !aCaseRegion.IsNull() && !aCaseRegion->IsRemoved() )
+        createObject( aCaseRegionsSect, aCaseRegion, aGuiObj->entry(), false );
     }
   }
 }