if ( !aFatherCalc.IsNull() && aFatherCalc->Label() != myLab )
{
Handle(HYDROData_Region) aNewRegion = addNewRegion( aDocument, CALCULATION_REGIONS_PREF, theLandCover );
- theRegion->CopyTo( aNewRegion );
+ theRegion->CopyTo( aNewRegion, true );
aFatherCalc->RemoveRegion( theRegion, theLandCover );
{
}
-void HYDROData_Entity::CopyTo( const Handle(HYDROData_Entity)& theDestination ) const
+void HYDROData_Entity::CopyTo( const Handle(HYDROData_Entity)& theDestination,
+ bool isGenerateNewName ) const
{
Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab );
if ( aDocument.IsNull() ) {
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;
- }
+ if( isGenerateNewName )
+ {
+ // 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 );
+ aName = HYDROData_Tool::GenerateObjectName( aDocument, aPrefix );
+ theDestination->SetName( aName );
+ }
}
Handle(HYDROData_Entity) HYDROData_Entity::GetFatherObject() const
* Objects must be the same type.
* \param theDestination initialized object (from any document) - target of copying
*/
- HYDRODATA_EXPORT virtual void CopyTo( const Handle(HYDROData_Entity)& theDestination ) const;
+ HYDRODATA_EXPORT virtual void CopyTo( const Handle(HYDROData_Entity)& theDestination,
+ bool isGenerateNewName ) const;
/**
* Returns the label of this object.
if ( !aFatherRegion.IsNull() && aFatherRegion->Label() != myLab )
{
Handle(HYDROData_Zone) aNewZone = addNewZone( aDocument, "", TopoDS_Face(), QStringList() );
- theZone->CopyTo( aNewZone );
+ theZone->CopyTo( aNewZone, false );
// To prevent changing of stored shape
aNewZone->SetShape( theZone->GetShape() );
return isOK;
}
-void HYDROData_Stream::CopyTo( const Handle(HYDROData_Entity)& theDestination ) const
+void HYDROData_Stream::CopyTo( const Handle(HYDROData_Entity)& theDestination,
+ bool isGenerateNewName ) const
{
// Get the document
Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab );
}
// Call base method
- HYDROData_Entity::CopyTo( theDestination );
+ HYDROData_Entity::CopyTo( theDestination, isGenerateNewName );
Handle(HYDROData_Stream) aStreamCopy =
Handle(HYDROData_Stream)::DownCast( theDestination );
/**
*
*/
- HYDRODATA_EXPORT virtual void CopyTo( const Handle(HYDROData_Entity)& theDestination ) const;
+ HYDRODATA_EXPORT virtual void CopyTo( const Handle(HYDROData_Entity)& theDestination,
+ bool isGenerateNewName ) const;
/**
Handle(HYDROData_Bathymetry) aBathymetry2 =
Handle(HYDROData_Bathymetry)::DownCast( aDoc->CreateObject( KIND_BATHYMETRY ) );
- aBathymetry1->CopyTo( aBathymetry2 );
+ aBathymetry1->CopyTo( aBathymetry2, true );
if ( anIsFileCreated )
{
Handle(HYDROData_Entity) aCopy = aDoc->CreateObject(KIND_IMAGE); // object for copy
CPPUNIT_ASSERT(aCopy->GetName().isEmpty());
- anObj->CopyTo(aCopy);
+ anObj->CopyTo(aCopy, true);
// check the copied object has same name as original
CPPUNIT_ASSERT_EQUAL(aName.toStdString(), aCopy->GetName().toStdString());
// copy image to the new one
Handle(HYDROData_Image) anImage3 =
Handle(HYDROData_Image)::DownCast(aDoc->CreateObject(KIND_IMAGE));
- anImage1->CopyTo(anImage3);
+ anImage1->CopyTo(anImage3, true);
// check all fields are correctly copied
CPPUNIT_ASSERT(anImage1->Image() == anImage3->Image());
Handle(HYDROData_PolylineXY) aPolyline2 =
Handle(HYDROData_PolylineXY)::DownCast(aDoc->CreateObject(KIND_POLYLINEXY));
- aPolyline1->CopyTo(aPolyline2);
+ aPolyline1->CopyTo(aPolyline2, true);
aDoc->Close();
Handle(HYDROData_Entity) aClone = getDocument()->CreateObject( aKind );
if( !aClone.IsNull() )
{
- anObject->CopyTo( aClone );
+ anObject->CopyTo( aClone, true );
anIsChanged = true;
// remove Z layer
*/
virtual void Remove();
-
- /**
- * Copies all properties of this to the destinated object.
- * Objects must be the same type.
- * \param theDestination initialized object (from any document) - target of copying
- */
- void CopyTo( HYDROData_Entity theDestination ) const [void ( const Handle_HYDROData_Entity& )];
- %MethodCode
- Handle(HYDROData_Entity) aCopyTo = createHandle( a0 );
- if ( !aCopyTo.IsNull() )
- {
- Py_BEGIN_ALLOW_THREADS
- sipSelfWasArg ? sipCpp->HYDROData_Entity::CopyTo( aCopyTo ):
- sipCpp->CopyTo( aCopyTo );
- Py_END_ALLOW_THREADS
- }
- %End
-
/**
* Returns father object. For object created under root document label
* this method always return NULL object.