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
* Objects must be the same type.
* \param theDestination initialized object (from any document) - target of copying
*/
- HYDRODATA_EXPORT void CopyTo( const Handle(HYDROData_Entity)& theDestination ) const;
+ HYDRODATA_EXPORT virtual void CopyTo( const Handle(HYDROData_Entity)& theDestination ) const;
/**
* Returns the label of this object.
return isOK;
}
+
+void HYDROData_Stream::CopyTo( const Handle(HYDROData_Entity)& theDestination ) const
+{
+ // Get the document
+ Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab );
+ if ( aDocument.IsNull() ) {
+ return;
+ }
+
+ // Call base method
+ HYDROData_Entity::CopyTo( theDestination );
+
+ Handle(HYDROData_Stream) aStreamCopy =
+ Handle(HYDROData_Stream)::DownCast( theDestination );
+
+ // Copy bottom polyline if exists
+ if ( !aStreamCopy.IsNull() ) {
+ const Handle(HYDROData_Polyline3D) aBottom = GetBottomPolyline();
+ if ( !aBottom.IsNull() ) {
+ aStreamCopy->ClearReferenceObjects( DataTag_BottomPolyline );
+ aStreamCopy->GenerateBottomPolyline();
+ const Handle(HYDROData_Polyline3D) aBottomCopy = aStreamCopy->GetBottomPolyline();
+ if ( !aBottomCopy.IsNull() && !aBottomCopy->GetPolylineXY().IsNull() ) {
+ aBottomCopy->GetPolylineXY()->Update();
+ aBottomCopy->Update();
+ }
+ }
+ }
+}
\ No newline at end of file
*/
HYDRODATA_EXPORT virtual void UpdatePrs();
+ /**
+ *
+ */
+ HYDRODATA_EXPORT virtual void CopyTo( const Handle(HYDROData_Entity)& theDestination ) const;
+
+
/**
* Returns default filling color for new stream.
*/
// remove Z layer
aClone->RemoveZLevel();
-
- // generate a new unique name for the clone object:
- // case 1: Image_1 -> Image_2
- // case 2: ImageObj -> ImageObj_1
- QString aName = aClone->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 = HYDROGUI_Tool::GenerateObjectName( (HYDROGUI_Module*)module(), aPrefix );
- aClone->SetName( aName );
}
}
}