]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
Feature #86: The hierarchy in the Object Browser (T 19).
authormzn <mzn@opencascade.com>
Mon, 25 Nov 2013 14:32:52 +0000 (14:32 +0000)
committermzn <mzn@opencascade.com>
Mon, 25 Nov 2013 14:32:52 +0000 (14:32 +0000)
src/HYDROData/HYDROData_Document.cxx
src/HYDROData/HYDROData_Entity.h
src/HYDROGUI/HYDROGUI_DataModel.cxx
src/HYDROGUI/resources/HYDROGUI_msg_en.ts

index 7d1a12552c9a37fe957777ba17e695a4e2625949..1bcca65adcde3b26a321434ce100e2de185ae4d5 100644 (file)
@@ -194,13 +194,15 @@ bool HYDROData_Document::DumpToPython( const QString& theFileName ) const
   bool aRes = true;
 
   // Dump all model objects to Python script
-  aRes = aRes && dumpPartitionToPython( aFile, aTreatedObjects, KIND_IMAGE      );
-  aRes = aRes && dumpPartitionToPython( aFile, aTreatedObjects, KIND_POLYLINE   );
+  aRes = aRes && dumpPartitionToPython( aFile, aTreatedObjects, KIND_IMAGE );
   aRes = aRes && dumpPartitionToPython( aFile, aTreatedObjects, KIND_BATHYMETRY );
-  aRes = aRes && dumpPartitionToPython( aFile, aTreatedObjects, KIND_ALTITUDE );
-  aRes = aRes && dumpPartitionToPython( aFile, aTreatedObjects, KIND_IMMERSIBLE_ZONE );
+  aRes = aRes && dumpPartitionToPython( aFile, aTreatedObjects, KIND_ARTIFICIAL_OBJECT );
+  aRes = aRes && dumpPartitionToPython( aFile, aTreatedObjects, KIND_NATURAL_OBJECT );
+  aRes = aRes && dumpPartitionToPython( aFile, aTreatedObjects, KIND_OBSTACLE );
   aRes = aRes && dumpPartitionToPython( aFile, aTreatedObjects, KIND_CALCULATION );
-
+  aRes = aRes && dumpPartitionToPython( aFile, aTreatedObjects, KIND_POLYLINE );
+  aRes = aRes && dumpPartitionToPython( aFile, aTreatedObjects, KIND_PROFILE );
+  aRes = aRes && dumpPartitionToPython( aFile, aTreatedObjects, KIND_ALTITUDE );
   return aRes;
 }
 
index 0df866a806222c258d2a104a617b9b506916cbea..02c191160873fe31ca2403e308454bd86f5987f6 100644 (file)
@@ -20,26 +20,28 @@ class Handle_HYDROData_Entity;
 ///! Kind of an object in a document
 typedef int ObjectKind;
 
-const ObjectKind KIND_UNKNOWN         = 0; ///! Unrecognized object
-const ObjectKind KIND_IMAGE           = 1;
-const ObjectKind KIND_POLYLINE        = 2;
-const ObjectKind KIND_BATHYMETRY      = 3;
-const ObjectKind KIND_ALTITUDE        = 4;
-const ObjectKind KIND_IMMERSIBLE_ZONE = 5;
-const ObjectKind KIND_RIVER           = 6;
-const ObjectKind KIND_STREAM          = 7;
-const ObjectKind KIND_CONFLUENCE      = 8;
-const ObjectKind KIND_CHANNEL         = 9;
-const ObjectKind KIND_OBSTACLE        = 10;
-const ObjectKind KIND_DIGUE           = 11;
-const ObjectKind KIND_PROFILE         = 12;
-const ObjectKind KIND_PROFILEUZ       = 13;
-const ObjectKind KIND_POLYLINEXY      = 14;
-const ObjectKind KIND_CALCULATION     = 15;
-const ObjectKind KIND_ZONE            = 16;
-const ObjectKind KIND_REGION          = 17;
-const ObjectKind KIND_VISUAL_STATE    = 18;
-const ObjectKind KIND_LAST            = KIND_VISUAL_STATE;
+const ObjectKind KIND_UNKNOWN           = 0; ///! Unrecognized object
+const ObjectKind KIND_IMAGE             = 1;
+const ObjectKind KIND_POLYLINE          = 2;
+const ObjectKind KIND_BATHYMETRY        = 3;
+const ObjectKind KIND_ALTITUDE          = 4;
+const ObjectKind KIND_IMMERSIBLE_ZONE   = 5;
+const ObjectKind KIND_RIVER             = 6;
+const ObjectKind KIND_STREAM            = 7;
+const ObjectKind KIND_CONFLUENCE        = 8;
+const ObjectKind KIND_CHANNEL           = 9;
+const ObjectKind KIND_OBSTACLE          = 10;
+const ObjectKind KIND_DIGUE             = 11;
+const ObjectKind KIND_PROFILE           = 12;
+const ObjectKind KIND_PROFILEUZ         = 13;
+const ObjectKind KIND_POLYLINEXY        = 14;
+const ObjectKind KIND_CALCULATION       = 15;
+const ObjectKind KIND_ZONE              = 16;
+const ObjectKind KIND_REGION            = 17;
+const ObjectKind KIND_VISUAL_STATE      = 18;
+const ObjectKind KIND_ARTIFICIAL_OBJECT = 19;
+const ObjectKind KIND_NATURAL_OBJECT    = 20;
+const ObjectKind KIND_LAST              = KIND_NATURAL_OBJECT;
 
 DEFINE_STANDARD_HANDLE(HYDROData_Entity, MMgt_TShared)
 
index b0ccc7e65f840e1598527e81674d0f82aaa4ea3c..9432c01c02f2cd996db52aad98d688073acce22c 100644 (file)
@@ -40,6 +40,9 @@
 #include <HYDROData_Region.h>
 #include <HYDROData_Zone.h>
 #include <HYDROData_Obstacle.h>
+#include <HYDROData_Channel.h>
+#include <HYDROData_Digue.h>
+#include <HYDROData_River.h>
 
 #include <CAM_Application.h>
 #include <CAM_DataObject.h>
@@ -226,92 +229,151 @@ void HYDROGUI_DataModel::update( const int theStudyId )
   if( aDocument.IsNull() )
     return;
 
-  LightApp_DataObject* anImageRootObj = createObject( aRootObj, tr( partitionName( KIND_IMAGE ).toAscii() ) );
+  // Create root objects:
 
-  HYDROData_Iterator anIterator( aDocument, KIND_IMAGE );
-  for( ; anIterator.More(); anIterator.Next() )
-  {
-    Handle(HYDROData_Image) anImageObj =
-      Handle(HYDROData_Image)::DownCast( anIterator.Current() );
-    if( !anImageObj.IsNull() )
-      createObject( anImageRootObj, anImageObj );
-  }
+  // IMAGES
+  LightApp_DataObject* anImageRootObj = createObject( aRootObj, tr( partitionName( KIND_IMAGE ).toAscii() ) );
 
+  // BATHYMETRY
   LightApp_DataObject* aBathymetryRootObj = createObject( aRootObj, tr( partitionName( KIND_BATHYMETRY ).toAscii() ) );
 
-  anIterator = HYDROData_Iterator( aDocument, KIND_BATHYMETRY );
-  for( ; anIterator.More(); anIterator.Next() )
-  {
-    Handle(HYDROData_Bathymetry) aBathymetryObj =
-      Handle(HYDROData_Bathymetry)::DownCast( anIterator.Current() );
-    if( !aBathymetryObj.IsNull() )
-      createObject( aBathymetryRootObj, aBathymetryObj );
-  }
+  // ARTIFICIAL OBJECTS
+  LightApp_DataObject* anArtificialObjectsRootObj = createObject( aRootObj, tr( partitionName( KIND_ARTIFICIAL_OBJECT ).toAscii() ) );
 
-  LightApp_DataObject* aPolylineRootObj = createObject( aRootObj, tr( partitionName( KIND_POLYLINE ).toAscii() ) );
+  // NATURAL OBJECTS
+  LightApp_DataObject* aNaturalObjectsRootObj = createObject( aRootObj, tr( partitionName( KIND_NATURAL_OBJECT ).toAscii() ) );
 
-  anIterator = HYDROData_Iterator( aDocument, KIND_POLYLINE );
-  for( ; anIterator.More(); anIterator.Next() )
-  {
-    Handle(HYDROData_Polyline) aPolylineObj =
-      Handle(HYDROData_Polyline)::DownCast( anIterator.Current() );
-    if( !aPolylineObj.IsNull() )
-      createObject( aPolylineRootObj, aPolylineObj );
-  }
+  // OBSTACLES
+  LightApp_DataObject* anObstaclesRootObj = createObject( aRootObj, tr( partitionName( KIND_OBSTACLE ).toAscii() ) );
+
+  // CALCULATION CASES
+  LightApp_DataObject* aCalculRootObj = createObject( aRootObj, tr( partitionName( KIND_CALCULATION ).toAscii() ) );
 
+  // POLYLINES
+  LightApp_DataObject* aPolylineRootObj = createObject( aRootObj, tr( partitionName( KIND_POLYLINE ).toAscii() ) );
+
+  // PROFILES
   LightApp_DataObject* aProfileRootObj = createObject( aRootObj, tr( partitionName( KIND_PROFILE ).toAscii() ) );
 
-  anIterator = HYDROData_Iterator( aDocument, KIND_PROFILE );
-  for( ; anIterator.More(); anIterator.Next() )
-  {
-    Handle(HYDROData_Profile) aProfileObj =
-      Handle(HYDROData_Profile)::DownCast( anIterator.Current() );
-    if( !aProfileObj.IsNull() )
-      createObject( aProfileRootObj, aProfileObj );
-  }
+  // VISUAL STATES
+  LightApp_DataObject* aVisualStateRootObj = createObject( aRootObj, tr( partitionName( KIND_VISUAL_STATE ).toAscii() ) );
 
-  LightApp_DataObject* aZonesRootObj = createObject( aRootObj, tr( partitionName( KIND_IMMERSIBLE_ZONE ).toAscii() ) );
+  HYDROData_Iterator anIterator( aDocument, KIND_UNKNOWN );
+  for( ; anIterator.More(); anIterator.Next() ) {
+    Handle(HYDROData_Entity) anObj = anIterator.Current();
 
-  anIterator = HYDROData_Iterator( aDocument, KIND_IMMERSIBLE_ZONE );
-  for( ; anIterator.More(); anIterator.Next() )
-  {
-    Handle(HYDROData_ImmersibleZone) aZoneObj =
-      Handle(HYDROData_ImmersibleZone)::DownCast( anIterator.Current() );
-    if( !aZoneObj.IsNull() )
-      createObject( aZonesRootObj, aZoneObj );
-  }
+    switch ( anObj->GetKind() ) {
+      case KIND_IMAGE:
+      {
+        Handle(HYDROData_Image) anImageObj =
+          Handle(HYDROData_Image)::DownCast( anObj );
+        if( !anImageObj.IsNull() ) {
+          createObject( anImageRootObj, anImageObj );
+        }
 
-  LightApp_DataObject* anObstaclesRootObj = createObject( aRootObj, tr( partitionName( KIND_OBSTACLE ).toAscii() ) );
+        break;
+      }
+      case KIND_BATHYMETRY:
+      {
+        Handle(HYDROData_Bathymetry) aBathymetryObj =
+          Handle(HYDROData_Bathymetry)::DownCast( anObj );
+        if( !aBathymetryObj.IsNull() ) {
+          createObject( aBathymetryRootObj, aBathymetryObj );
+        }
 
-  anIterator = HYDROData_Iterator( aDocument, KIND_OBSTACLE );
-  for( ; anIterator.More(); anIterator.Next() )
-  {
-    Handle(HYDROData_Obstacle) anObstacleObj =
-      Handle(HYDROData_Obstacle)::DownCast( anIterator.Current() );
-    if( !anObstacleObj.IsNull() )
-      createObject( anObstaclesRootObj, anObstacleObj );
-  }
+        break;
+      }
+      case KIND_CHANNEL:
+      {
+        Handle(HYDROData_Channel) aChannelObj =
+          Handle(HYDROData_Channel)::DownCast( anObj );
+        if( !aChannelObj.IsNull() ) {
+          createObject( anArtificialObjectsRootObj, aChannelObj );
+        }
 
-  LightApp_DataObject* aCalculRootObj = createObject( aRootObj, tr( partitionName( KIND_CALCULATION ).toAscii() ) );
+        break;
+      }
+      case KIND_DIGUE:
+      {
+        Handle(HYDROData_Digue) aDigueObj =
+          Handle(HYDROData_Digue)::DownCast( anObj );
+        if( !aDigueObj.IsNull() ) {
+          createObject( anArtificialObjectsRootObj, aDigueObj );
+        }
 
-  anIterator = HYDROData_Iterator( aDocument, KIND_CALCULATION );
-  for( ; anIterator.More(); anIterator.Next() )
-  {
-    Handle(HYDROData_CalculationCase) aCalculObj =
-      Handle(HYDROData_CalculationCase)::DownCast( anIterator.Current() );
-    if( !aCalculObj.IsNull() )
-      createObject( aCalculRootObj, aCalculObj );
-  }
+        break;
+      }
+      case KIND_IMMERSIBLE_ZONE:
+      {
+        Handle(HYDROData_ImmersibleZone) anImmersibleZoneObj =
+          Handle(HYDROData_ImmersibleZone)::DownCast( anObj );
+        if( !anImmersibleZoneObj.IsNull() ) {
+          createObject( aNaturalObjectsRootObj, anImmersibleZoneObj );
+        }
 
-  LightApp_DataObject* aVisualStateRootObj = createObject( aRootObj, tr( partitionName( KIND_VISUAL_STATE ).toAscii() ) );
+        break;
+      }
+      case KIND_RIVER:
+      {
+        Handle(HYDROData_River) aRiverObj =
+          Handle(HYDROData_River)::DownCast( anObj );
+        if( !aRiverObj.IsNull() ) {
+          createObject( aNaturalObjectsRootObj, aRiverObj );
+        }
 
-  anIterator = HYDROData_Iterator( aDocument, KIND_VISUAL_STATE );
-  for( ; anIterator.More(); anIterator.Next() )
-  {
-    Handle(HYDROData_VisualState) aVisualStateObj =
-      Handle(HYDROData_VisualState)::DownCast( anIterator.Current() );
-    if( !aVisualStateObj.IsNull() )
-      createObject( aVisualStateRootObj, aVisualStateObj );
+        break;
+      }
+      case KIND_OBSTACLE:
+      {
+        Handle(HYDROData_Obstacle) anObstacleObj =
+          Handle(HYDROData_Obstacle)::DownCast( anObj );
+        if( !anObstacleObj.IsNull() ) {
+          createObject( anObstaclesRootObj, anObstacleObj );
+        }
+
+        break;
+      }
+      case KIND_CALCULATION:
+      {
+        Handle(HYDROData_CalculationCase) aCalculObj =
+          Handle(HYDROData_CalculationCase)::DownCast( anObj );
+        if( !aCalculObj.IsNull() ) {
+          createObject( aCalculRootObj, aCalculObj );
+        }
+
+        break;
+      }
+      case KIND_POLYLINE:
+      {
+        Handle(HYDROData_Polyline) aPolylineObj =
+          Handle(HYDROData_Polyline)::DownCast( anObj );
+        if( !aPolylineObj.IsNull() ) {
+          createObject( aPolylineRootObj, aPolylineObj );
+        }
+
+        break;
+      }
+      case KIND_PROFILE:
+      {
+        Handle(HYDROData_Profile) aProfileObj =
+          Handle(HYDROData_Profile)::DownCast( anObj );
+        if( !aProfileObj.IsNull() ) {
+          createObject( aProfileRootObj, aProfileObj );
+        }
+
+        break;
+      }
+      case KIND_VISUAL_STATE:
+      {
+        Handle(HYDROData_VisualState) aVisualStateObj =
+          Handle(HYDROData_VisualState)::DownCast( anObj );
+        if( !aVisualStateObj.IsNull() ) {
+          createObject( aVisualStateRootObj, aVisualStateObj );
+        }
+
+        break;
+      }
+    }
   }
 
   if( SUIT_DataBrowser* anObjectBrowser = anApp->objectBrowser() )
@@ -532,14 +594,15 @@ QString HYDROGUI_DataModel::partitionName( const ObjectKind theObjectKind )
 {
   switch( theObjectKind )
   {
-    case KIND_IMAGE:           return "IMAGES";
-    case KIND_POLYLINE:        return "POLYLINES";
-    case KIND_PROFILE:         return "PROFILES";
-    case KIND_VISUAL_STATE:    return "VISUAL_STATES";
-    case KIND_BATHYMETRY:      return "BATHYMETRIES";
-    case KIND_CALCULATION:     return "CALCULATION_CASES";
-    case KIND_IMMERSIBLE_ZONE: return "IMMERSIBLE_ZONES";
-    case KIND_OBSTACLE:        return "OBSTACLES";
+    case KIND_IMAGE:             return "IMAGES";
+    case KIND_POLYLINE:          return "POLYLINES";
+    case KIND_PROFILE:           return "PROFILES";
+    case KIND_VISUAL_STATE:      return "VISUAL_STATES";
+    case KIND_BATHYMETRY:        return "BATHYMETRIES";
+    case KIND_CALCULATION:       return "CALCULATION_CASES";
+    case KIND_OBSTACLE:          return "OBSTACLES";
+    case KIND_ARTIFICIAL_OBJECT: return "ARTIFICIAL_OBJECTS";
+    case KIND_NATURAL_OBJECT:    return "NATURAL_OBJECTS";
     default: break;
   }
   return QString();
index 762be79997c3ec03a59e83c3829c2beefd3334d2..0fa1b04d374cc8d48e84e9df587464a0bb9997c1 100644 (file)
       <source>CALCULATION_CASES</source>
       <translation>CALCULATION CASES</translation>
     </message>
-    <message>
-      <source>IMMERSIBLE_ZONES</source>
-      <translation>IMMERSIBLE ZONES</translation>
-    </message>
     <message>
       <source>OBSTACLES</source>
       <translation>OBSTACLES</translation>
     </message>
+    <message>
+      <source>ARTIFICIAL_OBJECTS</source>
+      <translation>ARTIFICIAL OBJECTS</translation>
+    </message>
+    <message>
+      <source>NATURAL_OBJECTS</source>
+      <translation>NATURAL OBJECTS</translation>
+    </message>
     <message>
       <source>BATHYMETRY_FILTER</source>
       <translation>Bathymetry files (*.xyz);;All files (*.* *)</translation>