From: mzn Date: Mon, 6 Apr 2015 07:09:18 +0000 (+0300) Subject: refs #492: generate bottom polyline for the stream copy X-Git-Tag: BR_hydro_v_1_0_5~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=ba91ed0e11fd28acbdec9fcb075282f8803d40a8;p=modules%2Fhydro.git refs #492: generate bottom polyline for the stream copy --- diff --git a/src/HYDROData/HYDROData_Entity.cxx b/src/HYDROData/HYDROData_Entity.cxx index 01833f9c..6f3eea80 100644 --- a/src/HYDROData/HYDROData_Entity.cxx +++ b/src/HYDROData/HYDROData_Entity.cxx @@ -173,8 +173,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 diff --git a/src/HYDROData/HYDROData_Entity.h b/src/HYDROData/HYDROData_Entity.h index 506044e4..9ed01046 100644 --- a/src/HYDROData/HYDROData_Entity.h +++ b/src/HYDROData/HYDROData_Entity.h @@ -197,7 +197,7 @@ public: * 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. diff --git a/src/HYDROData/HYDROData_Stream.cxx b/src/HYDROData/HYDROData_Stream.cxx index 8e3cb8ee..6ffdd0ee 100644 --- a/src/HYDROData/HYDROData_Stream.cxx +++ b/src/HYDROData/HYDROData_Stream.cxx @@ -1184,3 +1184,32 @@ bool HYDROData_Stream::Interpolate( HYDROData_IProfilesInterpolator* theInterpol 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 diff --git a/src/HYDROData/HYDROData_Stream.h b/src/HYDROData/HYDROData_Stream.h index 2af9abae..673cca65 100644 --- a/src/HYDROData/HYDROData_Stream.h +++ b/src/HYDROData/HYDROData_Stream.h @@ -126,6 +126,12 @@ public: */ HYDRODATA_EXPORT virtual void UpdatePrs(); + /** + * + */ + HYDRODATA_EXPORT virtual void CopyTo( const Handle(HYDROData_Entity)& theDestination ) const; + + /** * Returns default filling color for new stream. */ diff --git a/src/HYDROGUI/HYDROGUI_DataModel.cxx b/src/HYDROGUI/HYDROGUI_DataModel.cxx index 37e4ec0b..159851ab 100644 --- a/src/HYDROGUI/HYDROGUI_DataModel.cxx +++ b/src/HYDROGUI/HYDROGUI_DataModel.cxx @@ -639,24 +639,6 @@ bool HYDROGUI_DataModel::paste() // 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 ); } } }