From: asl Date: Tue, 12 Aug 2014 04:33:52 +0000 (+0000) Subject: refs #369: points transformation on bathymetry import X-Git-Tag: master_20140820~6 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=119790bc3cdd003821c1ef1a0164f1c2bcfa5b12;p=modules%2Fhydro.git refs #369: points transformation on bathymetry import --- diff --git a/src/HYDROData/HYDROData_Bathymetry.cxx b/src/HYDROData/HYDROData_Bathymetry.cxx index dab80218..e6968d61 100644 --- a/src/HYDROData/HYDROData_Bathymetry.cxx +++ b/src/HYDROData/HYDROData_Bathymetry.cxx @@ -388,9 +388,19 @@ bool HYDROData_Bathymetry::ImportFromFile( const TCollection_AsciiString& theFil // Try to import the file if ( aFileSuf == "xyz" ) aRes = importFromXYZFile( aFile, aPoints ); - + // Close the file aFile.close(); + + + // Convert from global to local CS + Handle_HYDROData_Document aDoc = HYDROData_Document::Document( myLab ); + AltitudePoints::Iterator anIter( aPoints ); + for ( ; anIter.More(); anIter.Next() ) + { + AltitudePoint& aPoint = anIter.ChangeValue(); + aDoc->Transform( aPoint, true ); + } if ( aRes ) { diff --git a/src/HYDROData/HYDROData_Document.cxx b/src/HYDROData/HYDROData_Document.cxx index 3a460435..57cb0599 100644 --- a/src/HYDROData/HYDROData_Document.cxx +++ b/src/HYDROData/HYDROData_Document.cxx @@ -705,7 +705,7 @@ void HYDROData_Document::SetLocalCS( const gp_Pnt2d& theLocalCS ) myLY = theLocalCS.Y(); } -void HYDROData_Document::Transform( gp_Pnt& thePnt, bool IsToLocalCS ) const +void HYDROData_Document::Transform( double& X, double& Y, bool IsToLocalCS ) const { if( myLX < 0 || myLY < 0 ) { @@ -714,9 +714,32 @@ void HYDROData_Document::Transform( gp_Pnt& thePnt, bool IsToLocalCS ) const aThat->myLX = aLCS.X(); aThat->myLY = aLCS.Y(); } - double X = IsToLocalCS ? thePnt.X() - myLX : thePnt.X() + myLX; - double Y = IsToLocalCS ? thePnt.Y() - myLY : thePnt.Y() + myLY; + if( IsToLocalCS ) + { + X -= myLX; + Y -= myLY; + } + else + { + X += myLX; + Y += myLY; + } +} + +void HYDROData_Document::Transform( gp_Pnt& thePnt, bool IsToLocalCS ) const +{ + double X = thePnt.X(); + double Y = thePnt.Y(); double Z = thePnt.Z(); + Transform( X, Y, IsToLocalCS ); thePnt = gp_Pnt( X, Y, Z ); } +void HYDROData_Document::Transform( gp_XYZ& thePnt, bool IsToLocalCS ) const +{ + double X = thePnt.X(); + double Y = thePnt.Y(); + double Z = thePnt.Z(); + Transform( X, Y, IsToLocalCS ); + thePnt = gp_XYZ( X, Y, Z ); +} diff --git a/src/HYDROData/HYDROData_Document.h b/src/HYDROData/HYDROData_Document.h index 7eeca638..1274fb9d 100644 --- a/src/HYDROData/HYDROData_Document.h +++ b/src/HYDROData/HYDROData_Document.h @@ -9,6 +9,7 @@ class QFile; class gp_Pnt2d; class gp_Pnt; +class gp_XYZ; /** * Errors that could appear on document open/save actions. @@ -127,7 +128,9 @@ public: HYDRODATA_EXPORT gp_Pnt2d GetLocalCS() const; HYDRODATA_EXPORT void SetLocalCS( const gp_Pnt2d& ); + HYDRODATA_EXPORT void Transform( double& X, double& Y, bool IsToLocalCS ) const; HYDRODATA_EXPORT void Transform( gp_Pnt& thePnt, bool IsToLocalCS ) const; + HYDRODATA_EXPORT void Transform( gp_XYZ& thePnt, bool IsToLocalCS ) const; public: diff --git a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts index 2b0a8a31..574b4dda 100644 --- a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts +++ b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts @@ -195,10 +195,7 @@ All supported formats (*.brep *.iges *.igs *.step *.stp) COORDINATES_INFO - -X: %1, Y: %2 -WX: %3, WY: %4 - + Local CS: (%1, %2); Global CS: (%3, %4) POLYLINE3D_POLYLINE