]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
Naming of groups corrected (Feature #242).
authoradv <adv@opencascade.com>
Wed, 18 Dec 2013 06:57:46 +0000 (06:57 +0000)
committeradv <adv@opencascade.com>
Wed, 18 Dec 2013 06:57:46 +0000 (06:57 +0000)
src/HYDROData/HYDROData_Object.cxx
src/HYDROData/HYDROData_Object.h

index 7dfbe8134ae4531f34a0a390c5ec1bc35c2fa972..64530903e6def5149778aefb12b7b2302190613d 100644 (file)
@@ -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();
index e20e47893a0088434f1fb2ce685d1fde88ed7fa0..a7eb9aec349d8da644d8e4a4d2bbe149f4ab90a8 100644 (file)
@@ -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.