]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
Fix for the bug #59: bathymetry can not bet defined for conflicted zone.
authorrkv <rkv@opencascade.com>
Tue, 12 Nov 2013 12:10:28 +0000 (12:10 +0000)
committerrkv <rkv@opencascade.com>
Tue, 12 Nov 2013 12:10:28 +0000 (12:10 +0000)
src/HYDROGUI/HYDROGUI_Zone.cxx

index 3ec240f04002479255ce3a13a672ce8ba9d70c55..26aa2f08878e24ebc3d2992d8233402d8533ce05 100644 (file)
@@ -27,6 +27,7 @@
 #include <HYDROData_Bathymetry.h>
 
 #include <SUIT_DataObject.h>
+#include <QSet>
 
 HYDROGUI_Zone::HYDROGUI_Zone( SUIT_DataObject* theParent, 
                                           Handle(HYDROData_Zone) theData,
@@ -90,12 +91,16 @@ QString HYDROGUI_Zone::getBathimetryName() const
   if ( !aZone.IsNull() )
   {
     HYDROData_SequenceOfObjects aSeq = aZone->GetGeometryObjects();
-    if ( ( aZone->IsMergingNeed() && aZone->GetMergeType() == HYDROData_Zone::Merge_UNKNOWN ) 
-      || aSeq.Length() == 1 )
+    bool isMergingNeed = aZone->IsMergingNeed();
+    if ( ( isMergingNeed && aZone->GetMergeType() == HYDROData_Zone::Merge_UNKNOWN ) 
+      || ( aSeq.Length() == 1 ) || ( !isMergingNeed ) )
     {
       // Collect all used bathymetries names when merging is necessary
       // or just get the name of bathymetry of a single geometry object
+      // or just get the name of a single bathymetry
       HYDROData_SequenceOfObjects::Iterator anIter( aSeq );
+      QSet<QString> aNamesSet;
+      QString aName;
       for ( ; anIter.More(); anIter.Next() )
       {
         Handle(HYDROData_Object) aRefGeomObj =
@@ -106,11 +111,24 @@ QString HYDROGUI_Zone::getBathimetryName() const
           Handle(HYDROData_Bathymetry) aBathymetry = aRefGeomObj->GetBathymetry();
           if ( !aBathymetry.IsNull() )
           {
-            aRes += aBathymetry->GetName() + ", ";
+            aName = aBathymetry->GetName();
+            if ( !isMergingNeed )
+            {
+              // Get the first geometry object's bathymetry name and go out
+              aRes = aName;
+              break;
+            }
+
+            if ( !aNamesSet.contains( aName ) )
+            {
+              aRes += aName + ", ";
+              aNamesSet.insert( aName );
+            }
           }
         }
       }
-      if ( aRes.length() > 1 )
+      // Remove the last comma if necessary
+      if ( isMergingNeed && ( aRes.length() > 1 ) )
       {
         aRes.remove( aRes.length() - 2, 2 );
       }