X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDROPy%2FHYDROData_Bathymetry.sip;h=0c78ace313722d45a7bddb5d99a97bb9aa98a54d;hb=58bb6b7459bebeeb089c9ed486c4683a8bae7288;hp=6943e63d281348795e2deb8f92360a3d14080d3d;hpb=8543e637cbb4ae48998c596241fce567a729eb67;p=modules%2Fhydro.git diff --git a/src/HYDROPy/HYDROData_Bathymetry.sip b/src/HYDROPy/HYDROData_Bathymetry.sip index 6943e63d..0c78ace3 100644 --- a/src/HYDROPy/HYDROData_Bathymetry.sip +++ b/src/HYDROPy/HYDROData_Bathymetry.sip @@ -1,12 +1,8 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// +// Copyright (C) 2014-2015 EDF-R&D // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either -// version 2.1 of the License. +// version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -22,20 +18,10 @@ %ExportedHeaderCode #include -#include -#include -%End - -%ModuleCode - -PyObject* convertToPythonAltitudeList( const HYDROData_Bathymetry::AltitudePoints& thePoints ); -HYDROData_Bathymetry::AltitudePoints convertFromPythonAltitudeList( PyObject* thePythonList ); - %End -class HYDROData_Bathymetry : HYDROData_IAltitudeObject +class HYDROData_Bathymetry : public HYDROData_IAltitudeObject { - %ConvertToSubClassCode switch ( sipCpp->GetKind() ) { @@ -49,161 +35,35 @@ class HYDROData_Bathymetry : HYDROData_IAltitudeObject } %End -%TypeHeaderCode -#include -%End - -%TypeCode - -PyObject* convertToPythonAltitudeList( const HYDROData_Bathymetry::AltitudePoints& thePoints ) -{ - int aListSize = thePoints.size(); - - PyObject* aPythonList = NULL; - if ( ( aPythonList = PyList_New( aListSize ) ) == NULL ) - return NULL; - - for ( int i = 0; i < aListSize; ++i ) - { - const HYDROData_Bathymetry::AltitudePoint& aPoint = thePoints.at( i ); - - PyObject* aTypleObj = Py_BuildValue( "(ddd)", aPoint.X(), aPoint.Y(), aPoint.Z() ); - - PyList_SET_ITEM( aPythonList, i, aTypleObj ); - } - - return aPythonList; -} - -HYDROData_Bathymetry::AltitudePoints convertFromPythonAltitudeList( PyObject* thePythonList ) -{ - HYDROData_Bathymetry::AltitudePoints aPoints; - if ( thePythonList == NULL ) - return aPoints; - - for ( int i = 0, n = PyList_GET_SIZE( thePythonList ); i < n; ++i ) +public: + struct AltitudePoint { - PyObject* aTypleObj = PyList_GET_ITEM( thePythonList, i ); + double X; + double Y; + double Z; + }; + typedef std::vector AltitudePoints; - double anArr[ 3 ]; - if ( !PyArg_ParseTuple( aTypleObj, "ddd", &anArr[ 0 ], &anArr[ 1 ], &anArr[ 2 ] ) ) - continue; - - HYDROData_Bathymetry::AltitudePoint aPoint; - aPoint.SetX( anArr[ 0 ] ); - aPoint.SetY( anArr[ 1 ] ); - aPoint.SetZ( anArr[ 2 ] ); - - aPoints.append( aPoint ); - } - - return aPoints; -} +%TypeHeaderCode +#include %End public: - // Public methods to work with Bathymetry altitudes. - - /** - * Returns altitude for given point. - * \param thePoint the point to examine - * \return altitude value - */ - double GetAltitudeForPoint( const QPointF& thePoint ) const [double (const gp_XY&)]; - %MethodCode - - // The C++ API gets the gp_XY object, we convert it from QPointF. - gp_XY aPoint( a0->x(), a0->y() ); - - Py_BEGIN_ALLOW_THREADS - sipRes = sipSelfWasArg ? sipCpp->HYDROData_Bathymetry::GetAltitudeForPoint( aPoint ) : - sipCpp->GetAltitudeForPoint( aPoint ); - Py_END_ALLOW_THREADS - %End - - - - /** - * Replace current altitude points by new one. - * \param thePoints the altitude points list - */ - virtual void SetAltitudePoints( SIP_PYLIST ) [void (const HYDROData_Bathymetry::AltitudePoints&)] ; - %MethodCode - - // The C++ API takes a list of gp_XYZ objects, - // but we pass a list of python tuples. - - HYDROData_Bathymetry::AltitudePoints aPoints = - convertFromPythonAltitudeList( a0 ); - - Py_BEGIN_ALLOW_THREADS - sipSelfWasArg ? sipCpp->HYDROData_Bathymetry::SetAltitudePoints( aPoints ) : - sipCpp->SetAltitudePoints( aPoints ); - Py_END_ALLOW_THREADS - - %End - %VirtualCatcherCode - - PyObject* aPythonList = convertToPythonAltitudeList( a0 ); - if ( aPythonList != NULL ) - { - sipCallMethod( &sipIsErr, sipMethod, "O", aPythonList ); - Py_DECREF( aPythonList ); - } - - %End - - /** - * Returns altitude points list. - * \return points list - */ - SIP_PYLIST GetAltitudePoints() const [HYDROData_Bathymetry::AltitudePoints ()] ; - %MethodCode - - // The C++ API returns a list of gp_XYZ objects, - // we convert it to list of python tuples. - - HYDROData_Bathymetry::AltitudePoints aPoints; - - Py_BEGIN_ALLOW_THREADS - aPoints = sipSelfWasArg ? sipCpp->HYDROData_Bathymetry::GetAltitudePoints() : - sipCpp->GetAltitudePoints(); - Py_END_ALLOW_THREADS - - sipRes = convertToPythonAltitudeList( aPoints ); - - %End - - /** - * Remove all altitude points. - */ - void RemoveAltitudePoints(); + virtual void SetAltitudePoints( const HYDROData_Bathymetry::AltitudePoints& ); + HYDROData_Bathymetry::AltitudePoints GetAltitudePoints() const; + void RemoveAltitudePoints(); public: - // Public methods to work with files. - - /** - * Imports Bathymetry data from file. The supported file types: - * - xyz - * \param theFileName the path to file - * \return \c true if file has been successfully read - */ - bool ImportFromFile( const QString& theFileName ); + void SetAltitudesInverted( const bool theIsInverted, const bool theIsUpdate = true ); + bool IsAltitudesInverted() const; + bool ImportFromFiles( const QStringList& theFileNames ); + bool ImportFromFile( const QString& theFileName ); protected: - - /** - * Creates new object in the internal data structure. Use higher level objects - * to create objects with real content. - */ HYDROData_Bathymetry(); - - /** - * Destructs properties of the object and object itself, removes it from the document. - */ ~HYDROData_Bathymetry(); };