X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDROData%2FHYDROData_Entity.cxx;h=fe5be13a4d3088d33280f2cae71fbe9c12e696ea;hb=866c6471c93c9e9e12d1557d7224ff614dd17bff;hp=01833f9ce9680c7d981c9bbba8a8522e71da2fad;hpb=474c2cd65280d793f1c81ca528bc92e1cff988e6;p=modules%2Fhydro.git diff --git a/src/HYDROData/HYDROData_Entity.cxx b/src/HYDROData/HYDROData_Entity.cxx index 01833f9c..fe5be13a 100644 --- a/src/HYDROData/HYDROData_Entity.cxx +++ b/src/HYDROData/HYDROData_Entity.cxx @@ -1,8 +1,4 @@ -// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// +// Copyright (C) 2014-2015 EDF-R&D // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either @@ -173,8 +169,31 @@ HYDROData_Entity::~HYDROData_Entity() void HYDROData_Entity::CopyTo( const Handle(HYDROData_Entity)& theDestination ) const { + Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab ); + if ( aDocument.IsNull() ) { + return; + } + TDF_CopyLabel aCopy(myLab, theDestination->Label()); aCopy.Perform(); + + // generate a new unique name for the clone object: + // case 1: Image_1 -> Image_2 + // case 2: ImageObj -> ImageObj_1 + QString aName = theDestination->GetName(); + QString aPrefix = aName; + if( aName.contains( '_' ) ) { // case 1 + QString aSuffix = aName.section( '_', -1 ); + bool anIsInteger = false; + aSuffix.toInt( &anIsInteger ); + if( anIsInteger ) + aPrefix = aName.section( '_', 0, -2 ); + } else { // case 2 + aPrefix = aName; + } + + aName = HYDROData_Tool::GenerateObjectName( aDocument, aPrefix ); + theDestination->SetName( aName ); } Handle(HYDROData_Entity) HYDROData_Entity::GetFatherObject() const