From 10c72ce8536f0c65c161c4e208cce3789dbdc272 Mon Sep 17 00:00:00 2001 From: adv Date: Wed, 18 Dec 2013 06:57:46 +0000 Subject: [PATCH] Naming of groups corrected (Feature #242). --- src/HYDROData/HYDROData_Object.cxx | 29 +++++++++++++++++++++++++++++ src/HYDROData/HYDROData_Object.h | 6 ++++++ 2 files changed, 35 insertions(+) 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. -- 2.39.2