From: rkv Date: Tue, 12 Nov 2013 12:10:28 +0000 (+0000) Subject: Fix for the bug #59: bathymetry can not bet defined for conflicted zone. X-Git-Tag: BR_hydro_v_0_3~14 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=e98e5c25e842447ac4cdd60bc5c1770255cdb0a3;p=modules%2Fhydro.git Fix for the bug #59: bathymetry can not bet defined for conflicted zone. --- diff --git a/src/HYDROGUI/HYDROGUI_Zone.cxx b/src/HYDROGUI/HYDROGUI_Zone.cxx index 3ec240f0..26aa2f08 100644 --- a/src/HYDROGUI/HYDROGUI_Zone.cxx +++ b/src/HYDROGUI/HYDROGUI_Zone.cxx @@ -27,6 +27,7 @@ #include #include +#include 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 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 ); }