From: adv Date: Wed, 18 Dec 2013 06:57:46 +0000 (+0000) Subject: Naming of groups corrected (Feature #242). X-Git-Tag: BR_hydro_v_0_6~50 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=10c72ce8536f0c65c161c4e208cce3789dbdc272;p=modules%2Fhydro.git Naming of groups corrected (Feature #242). --- diff --git a/src/HYDROData/HYDROData_Object.cxx b/src/HYDROData/HYDROData_Object.cxx index 7dfbe813..64530903 100644 --- a/src/HYDROData/HYDROData_Object.cxx +++ b/src/HYDROData/HYDROData_Object.cxx @@ -25,6 +25,35 @@ HYDROData_Object::~HYDROData_Object() { } +void HYDROData_Object::SetName( const QString& theName ) +{ + QString anOldObjName = GetName(); + if ( anOldObjName != theName ) + { + HYDROData_SequenceOfObjects aGroups = GetGroups(); + HYDROData_SequenceOfObjects::Iterator anIter( aGroups ); + for ( ; anIter.More(); anIter.Next() ) + { + Handle(HYDROData_ShapesGroup) aGroup = + Handle(HYDROData_ShapesGroup)::DownCast( anIter.Value() ); + if ( aGroup.IsNull() ) + continue; + + QString aGroupName = aGroup->GetName(); + if ( anOldObjName.isEmpty() ) + aGroupName.prepend( theName + "_" ); + else if ( aGroupName.startsWith( anOldObjName ) ) + aGroupName.replace( anOldObjName, theName ); + else + continue; + + aGroup->SetName( aGroupName ); + } + } + + HYDROData_Entity::SetName( theName ); +} + void HYDROData_Object::Update() { HYDROData_Entity::Update(); diff --git a/src/HYDROData/HYDROData_Object.h b/src/HYDROData/HYDROData_Object.h index e20e4789..a7eb9aec 100644 --- a/src/HYDROData/HYDROData_Object.h +++ b/src/HYDROData/HYDROData_Object.h @@ -37,6 +37,12 @@ protected: public: DEFINE_STANDARD_RTTI(HYDROData_Object); + /** + * Updates the name of this object. + * Reimplemented to update the names child groups. + */ + HYDRODATA_EXPORT virtual void SetName( const QString& theName ); + /** * Update the geometry object. * Call this method whenever you made changes for object data.