#include <OSD_Timer.hxx>
#endif
-#define PYTHON_BATHYMETRY_ID "KIND_BATHYMETRY"
-
-
IMPLEMENT_STANDARD_HANDLE(HYDROData_Bathymetry, HYDROData_IAltitudeObject)
IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Bathymetry, HYDROData_IAltitudeObject)
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() );
- QString aFilePath = GetFilePath();
- if ( !aFilePath.isEmpty() )
- {
- aResList << QString( "%1.ImportFromFile( \"%2\" );" )
- .arg( aBathymetryName ).arg( aFilePath );
- }
- else
- {
- // TODO : bathymetry is composed from other bathymetry(ies)
- }
+ TCollection_AsciiString aFilePath = GetFilePath();
+ aResList << QString( "%1.ImportFromFile( \"%2\" );" )
+ .arg( aBathymetryName ).arg( aFilePath.ToCString() );
+
+ aResList << QString( "" );
+ aResList << QString( "%1.Update();" ).arg( aBathymetryName );
+ aResList << QString( "" );
return aResList;
}
return aResAltitude;
}
-void HYDROData_Bathymetry::SetFilePath(const QString& theFilePath)
+void HYDROData_Bathymetry::SetFilePath( const TCollection_AsciiString& theFilePath )
{
- TCollection_AsciiString anAsciiStr( theFilePath.toStdString().c_str() );
- TDataStd_AsciiString::Set( myLab.FindChild( DataTag_FilePath ), anAsciiStr );
+ TDataStd_AsciiString::Set( myLab.FindChild( DataTag_FilePath ), theFilePath );
}
-QString HYDROData_Bathymetry::GetFilePath() const
+TCollection_AsciiString HYDROData_Bathymetry::GetFilePath() const
{
- QString aRes;
+ TCollection_AsciiString aRes;
TDF_Label aLabel = myLab.FindChild( DataTag_FilePath, false );
if ( !aLabel.IsNull() )
{
Handle(TDataStd_AsciiString) anAsciiStr;
if ( aLabel.FindAttribute( TDataStd_AsciiString::GetID(), anAsciiStr ) )
- aRes = QString( anAsciiStr->Get().ToCString() );
+ aRes = anAsciiStr->Get();
}
return aRes;
return aRes;
}
-bool HYDROData_Bathymetry::ImportFromFile( const QString& theFileName )
+bool HYDROData_Bathymetry::ImportFromFile( const TCollection_AsciiString& theFileName )
{
// Try to open the file
- QFile aFile( theFileName );
+ QFile aFile( theFileName.ToCString() );
if ( !aFile.exists() || !aFile.open( QIODevice::ReadOnly ) )
return false;
// 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 )
{
}
-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";
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 );
}
+