X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDROData%2FHYDROData_Bathymetry.cxx;h=58d3a11cfd7c2103011225dbf3914bc45d9e6f9d;hb=2f217128f8d34b2082de78d2af90bf243bf9e8b1;hp=f37c0ae6d3b92ab9079d14a73aaeeae0df08377c;hpb=92bbcbb42ab64143396876b7335c14b3097b0e48;p=modules%2Fhydro.git diff --git a/src/HYDROData/HYDROData_Bathymetry.cxx b/src/HYDROData/HYDROData_Bathymetry.cxx index f37c0ae6..58d3a11c 100644 --- a/src/HYDROData/HYDROData_Bathymetry.cxx +++ b/src/HYDROData/HYDROData_Bathymetry.cxx @@ -26,9 +26,6 @@ #include #endif -#define PYTHON_BATHYMETRY_ID "KIND_BATHYMETRY" - - IMPLEMENT_STANDARD_HANDLE(HYDROData_Bathymetry, HYDROData_IAltitudeObject) IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Bathymetry, HYDROData_IAltitudeObject) @@ -43,33 +40,19 @@ HYDROData_Bathymetry::~HYDROData_Bathymetry() QStringList HYDROData_Bathymetry::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const { - QStringList aResList; - - Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab ); - if ( aDocument.IsNull() ) - return aResList; - - QString aDocName = aDocument->GetDocPyName(); - QString aBathymetryName = GetName(); - - aResList << QString( "%1 = %2.CreateObject( %3 );" ) - .arg( aBathymetryName ).arg( aDocName ).arg( PYTHON_BATHYMETRY_ID ); - aResList << QString( "%1.SetName( \"%2\" );" ) - .arg( aBathymetryName ).arg( aBathymetryName ); + QStringList aResList = dumpObjectCreation( theTreatedObjects ); + QString aBathymetryName = GetObjPyName(); aResList << QString( "%1.SetAltitudesInverted( %2 );" ) .arg( aBathymetryName ).arg( IsAltitudesInverted() ); TCollection_AsciiString aFilePath = GetFilePath(); - if ( !aFilePath.IsEmpty() ) - { - aResList << QString( "%1.ImportFromFile( \"%2\" );" ) - .arg( aBathymetryName ).arg( aFilePath.ToCString() ); - } - else - { - // TODO : bathymetry is composed from other bathymetry(ies) - } + aResList << QString( "%1.ImportFromFile( \"%2\" );" ) + .arg( aBathymetryName ).arg( aFilePath.ToCString() ); + + aResList << QString( "" ); + aResList << QString( "%1.Update();" ).arg( aBathymetryName ); + aResList << QString( "" ); return aResList; } @@ -405,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 ) { @@ -483,14 +476,14 @@ bool HYDROData_Bathymetry::importFromXYZFile( QFile& theFile, } -bool HYDROData_Bathymetry::CreateBoundaryPolyline() const +Handle_HYDROData_PolylineXY HYDROData_Bathymetry::CreateBoundaryPolyline() const { Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab ); Handle_HYDROData_PolylineXY aResult = Handle_HYDROData_PolylineXY::DownCast( aDocument->CreateObject( KIND_POLYLINEXY ) ); if( aResult.IsNull() ) - return false; + return aResult; //search free name QString aPolylinePref = GetName() + "_Boundary"; @@ -525,5 +518,19 @@ bool HYDROData_Bathymetry::CreateBoundaryPolyline() const aResult->AddPoint( 0, HYDROData_IPolyline::Point( Xmax, Ymin ) ); aResult->Update(); - return true; + return aResult; +} + +void HYDROData_Bathymetry::UpdateLocalCS( double theDx, double theDy ) +{ + gp_XYZ aDelta( theDx, theDy, 0 ); + AltitudePoints aPoints = GetAltitudePoints(); + AltitudePoints::Iterator anIter( aPoints ); + for ( int i = 0 ; anIter.More(); ++i, anIter.Next() ) + { + AltitudePoint& aPoint = anIter.ChangeValue(); + aPoint += aDelta; + } + SetAltitudePoints( aPoints ); } +