From: adv Date: Thu, 5 Sep 2013 12:16:12 +0000 (+0000) Subject: Python API for HYDROData_Image. X-Git-Tag: BR_hydro_v_0_1~71 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c7c04a2922840103813e485e08bfd4e1d06e3b2d;p=modules%2Fhydro.git Python API for HYDROData_Image. --- diff --git a/HYDRO.sln b/HYDRO.sln index 49e79419..52d0869c 100644 --- a/HYDRO.sln +++ b/HYDRO.sln @@ -13,17 +13,30 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HYDROOperations", "src\HYDR {EB7B7816-4EA0-4E7D-A88A-1417DEB0FC1C} = {EB7B7816-4EA0-4E7D-A88A-1417DEB0FC1C} EndProjectSection EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HYDROPy", "src\HYDROPy\HYDROPy.vcproj", "{72DE2E1A-BDE1-4BBE-8225-3D3DB2CC6C93}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {D11F0AD0-D002-4A22-A8E6-3F906379206F}.Debug|Win32.ActiveCfg = Debug|Win32 {D11F0AD0-D002-4A22-A8E6-3F906379206F}.Debug|Win32.Build.0 = Debug|Win32 + {D11F0AD0-D002-4A22-A8E6-3F906379206F}.Release|Win32.ActiveCfg = Debug|Win32 + {D11F0AD0-D002-4A22-A8E6-3F906379206F}.Release|Win32.Build.0 = Debug|Win32 {EB7B7816-4EA0-4E7D-A88A-1417DEB0FC1C}.Debug|Win32.ActiveCfg = Debug|Win32 {EB7B7816-4EA0-4E7D-A88A-1417DEB0FC1C}.Debug|Win32.Build.0 = Debug|Win32 + {EB7B7816-4EA0-4E7D-A88A-1417DEB0FC1C}.Release|Win32.ActiveCfg = Debug|Win32 + {EB7B7816-4EA0-4E7D-A88A-1417DEB0FC1C}.Release|Win32.Build.0 = Debug|Win32 {6F9309FA-A798-4F2A-A04B-133EA58E50A9}.Debug|Win32.ActiveCfg = Debug|Win32 {6F9309FA-A798-4F2A-A04B-133EA58E50A9}.Debug|Win32.Build.0 = Debug|Win32 + {6F9309FA-A798-4F2A-A04B-133EA58E50A9}.Release|Win32.ActiveCfg = Debug|Win32 + {6F9309FA-A798-4F2A-A04B-133EA58E50A9}.Release|Win32.Build.0 = Debug|Win32 + {72DE2E1A-BDE1-4BBE-8225-3D3DB2CC6C93}.Debug|Win32.ActiveCfg = Debug|Win32 + {72DE2E1A-BDE1-4BBE-8225-3D3DB2CC6C93}.Debug|Win32.Build.0 = Debug|Win32 + {72DE2E1A-BDE1-4BBE-8225-3D3DB2CC6C93}.Release|Win32.ActiveCfg = Release|Win32 + {72DE2E1A-BDE1-4BBE-8225-3D3DB2CC6C93}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/HYDROPy/HYDROData.sip b/src/HYDROPy/HYDROData.sip index ae4ec313..9bb7e82f 100644 --- a/src/HYDROPy/HYDROData.sip +++ b/src/HYDROPy/HYDROData.sip @@ -50,10 +50,11 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com %End -%Import QtCore/QtCoremod.sip +%Import QtGui/QtGuimod.sip %Include HYDROData_Object.sip %Include HYDROData_Bathymetry.sip +%Include HYDROData_Image.sip %Include HYDROData_Document.sip diff --git a/src/HYDROPy/HYDROData_Bathymetry.sip b/src/HYDROPy/HYDROData_Bathymetry.sip index 2d5911e0..8666ba56 100644 --- a/src/HYDROPy/HYDROData_Bathymetry.sip +++ b/src/HYDROPy/HYDROData_Bathymetry.sip @@ -21,11 +21,8 @@ // %ExportedHeaderCode - #include - #include - %End %ModuleCode @@ -101,7 +98,7 @@ HYDROData_Bathymetry::AltitudePoints convertFromPythonAltitudeList( PyObject* th public: - //virtual const ObjectKind GetKind() const { return KIND_BATHYMETRY; } + const ObjectKind GetKind() const; public: @@ -156,7 +153,8 @@ public: HYDROData_Bathymetry::AltitudePoints aPoints; Py_BEGIN_ALLOW_THREADS - aPoints = sipSelfWasArg ? sipCpp->HYDROData_Bathymetry::GetAltitudePoints() : sipCpp->GetAltitudePoints(); + aPoints = sipSelfWasArg ? sipCpp->HYDROData_Bathymetry::GetAltitudePoints() : + sipCpp->GetAltitudePoints(); Py_END_ALLOW_THREADS sipRes = convertToPythonAltitudeList( aPoints ); @@ -189,8 +187,6 @@ public: protected: - //friend class HYDROData_Iterator; - /** * Creates new object in the internal data structure. Use higher level objects * to create objects with real content. diff --git a/src/HYDROPy/HYDROData_Document.sip b/src/HYDROPy/HYDROData_Document.sip index 57f60e9b..9c4779ff 100644 --- a/src/HYDROPy/HYDROData_Document.sip +++ b/src/HYDROPy/HYDROData_Document.sip @@ -24,6 +24,12 @@ #include %End +%ModuleHeaderCode +HYDROData_Object* copyObject( HYDROData_Object* theObject ); +Handle(HYDROData_Object) createHandle( HYDROData_Object* theObject ); +HYDROData_Object* createPointer( const Handle(HYDROData_Object)& theObject ); +%End + enum Data_DocError { DocError_OK = 0, ///< success DocError_ResourcesProblem, ///< resources files are invalid or not found @@ -46,21 +52,64 @@ class HYDROData_Document sipClass = NULL; %End +%TypeCode + + HYDROData_Object* copyObject( HYDROData_Object* theObject ) + { + HYDROData_Object* aRes = NULL; + if ( theObject == NULL ) + return aRes; + + switch( theObject->GetKind() ) + { + case KIND_BATHYMETRY: + { + aRes = new HYDROData_Bathymetry( *dynamic_cast( theObject ) ); + break; + } + case KIND_IMAGE: + { + aRes = new HYDROData_Image( *dynamic_cast( theObject ) ); + break; + } + } + + return aRes; + } + + Handle(HYDROData_Object) createHandle( HYDROData_Object* theObject ) + { + Handle(HYDROData_Object) aRes = copyObject( theObject ); + return aRes; + } + + HYDROData_Object* createPointer( const Handle(HYDROData_Object)& theObject ) + { + HYDROData_Object* aRes = NULL; + + if ( !theObject.IsNull() ) + aRes = copyObject( theObject.operator->() ); + + return aRes; + } + +%End + public: //! Returns the existing document or creates new if it is not exist static HYDROData_Document Document( const int theStudyID ) [Handle_HYDROData_Document (const int)] ; %MethodCode + Handle(HYDROData_Document) aDocument; + Py_BEGIN_ALLOW_THREADS - Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( a0 ); + aDocument = HYDROData_Document::Document( a0 ); + Py_END_ALLOW_THREADS + if ( !aDocument.IsNull() ) - { sipRes = aDocument.operator->(); - } - - Py_END_ALLOW_THREADS - + %End //! Returns true if data model contains document for this study @@ -126,33 +175,18 @@ public: HYDROData_Object CreateObject( const ObjectKind theKind ) [Handle_HYDROData_Object (const ObjectKind)] ; %MethodCode + Handle(HYDROData_Object) anObject; Py_BEGIN_ALLOW_THREADS - - Handle(HYDROData_Object) anObject = - sipSelfWasArg ? sipCpp->HYDROData_Document::CreateObject( a0 ) : sipCpp->CreateObject( a0 ); - if ( !anObject.IsNull() ) - { - switch( anObject->GetKind() ) - { - case KIND_BATHYMETRY: - { - Handle(HYDROData_Bathymetry) aBathymetry = - Handle(HYDROData_Bathymetry)::DownCast( anObject ); - sipRes = new HYDROData_Bathymetry( *aBathymetry.operator->() ); - break; - } - } - } - + anObject = sipSelfWasArg ? sipCpp->HYDROData_Document::CreateObject( a0 ) : + sipCpp->CreateObject( a0 ); Py_END_ALLOW_THREADS + + sipRes = createPointer( anObject ); %End protected: - //friend class HYDROData_Iterator; - //friend class test_HYDROData_Document; - //! Creates new document: private because "Document" method must be used instead of direct creation. HYDROData_Document(); diff --git a/src/HYDROPy/HYDROData_Image.sip b/src/HYDROPy/HYDROData_Image.sip new file mode 100644 index 00000000..08617394 --- /dev/null +++ b/src/HYDROPy/HYDROData_Image.sip @@ -0,0 +1,228 @@ +// 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 +// +// 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. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +%ExportedHeaderCode +#include +%End + +class HYDROData_Image : HYDROData_Object +{ + +%ConvertToSubClassCode + if ( !Handle(HYDROData_Image)::DownCast( sipCpp ).IsNull() ) + sipClass = sipClass_HYDROData_Image; + else + sipClass = NULL; +%End + +%TypeHeaderCode +#include +%End + +public: + + const ObjectKind GetKind() const; + +public: + + /** + * Stores the image + * \param theImage new image + */ + void SetImage( const QImage& theImage ); + + /** + * Returns the kept image + */ + QImage Image(); + + /** + * Stores the image transformation + * \param theTrsf new transformation + */ + void SetTrsf( const QTransform& theTrsf ); + + /** + * Returns the kept transformation, or "identity" if not yet stored + */ + QTransform Trsf(); + + /** + * Stores the image transformation points (3 input + 3 output) + * \param thePointAIn input point A + * \param thePointBIn input point B + * \param thePointCIn input point C + * \param thePointAOut output point A + * \param thePointBOut output point B + * \param thePointCOut output point C + */ + void SetTrsfPoints( const QPoint& thePointAIn, + const QPoint& thePointBIn, + const QPoint& thePointCIn, + const QPointF& thePointAOut, + const QPointF& thePointBOut, + const QPointF& thePointCOut ); + + /** + * Returns the image transformation points (3 input + 3 output) + * \param thePointAIn input point A + * \param thePointBIn input point B + * \param thePointCIn input point C + * \param thePointAOut output point A + * \param thePointBOut output point B + * \param thePointCOut output point C + */ + void TrsfPoints( QPoint& thePointAIn, + QPoint& thePointBIn, + QPoint& thePointCIn, + QPointF& thePointAOut, + QPointF& thePointBOut, + QPointF& thePointCOut ); + + /** + * Appends reference to other image. + * \param theReferenced the image referenced by this + */ + void AppendReference( HYDROData_Image theReferenced ) [void (Handle_HYDROData_Image)]; + %MethodCode + + Handle(HYDROData_Image) anImage = + Handle(HYDROData_Image)::DownCast( createHandle( a0 ) ); + if ( !anImage.IsNull() ) + { + Py_BEGIN_ALLOW_THREADS + sipSelfWasArg ? sipCpp->HYDROData_Image::AppendReference( anImage ) : + sipCpp->AppendReference( anImage ); + Py_END_ALLOW_THREADS + } + + %End + + /** + * Returns the number of referenced images + * \return zero if there is no references + */ + int NbReferences(); + + /** + * Returns reference by index. + * \param theIndex number of reference [0; NbReference) + * \returns the referenced image, or Null if index is invalid + */ + HYDROData_Image Reference( const int theIndex ) const [Handle_HYDROData_Image (const int)]; + %MethodCode + + Handle(HYDROData_Image) anImage; + + Py_BEGIN_ALLOW_THREADS + sipSelfWasArg ? sipCpp->HYDROData_Image::Reference( a0 ) : + sipCpp->Reference( a0 ); + Py_END_ALLOW_THREADS + + sipRes = dynamic_cast( createPointer( anImage ) ); + + %End + + /** + * Updates reference by index. If index is one-bigger than \a NbReferences, + * this method appends it to the end (NbReferences is incremented). + * \param theIndex number of reference [0; NbReference] + * \param theReferenced the image referenced by this + */ + void ChangeReference( const int theIndex, HYDROData_Image theReferenced ) [void (const int, Handle_HYDROData_Image)]; + %MethodCode + + Handle(HYDROData_Image) anImage = + Handle(HYDROData_Image)::DownCast( createHandle( a1 ) ); + if ( !anImage.IsNull() ) + { + Py_BEGIN_ALLOW_THREADS + sipSelfWasArg ? sipCpp->HYDROData_Image::ChangeReference( a0, anImage ) : + sipCpp->ChangeReference( a0, anImage ); + Py_END_ALLOW_THREADS + } + + %End + + /** + * Removes reference by index + * \param theIndex number of reference [0; NbReference) + */ + void RemoveReference( const int theIndex ); + + /** + * Removes all references. + */ + void ClearReferences(); + + /** + * Stores the operator name + * \param theOpName name of the operator that must be executed for image update + */ + void SetOperatorName( const QString theOpName ); + + /** + * Returns the operator name + * \returns the name of the operator that must be executed for image update + */ + QString OperatorName(); + + /** + * Stores the operator arguments + * \param theArgs array that stores the operator arguments, needed for execution + */ + void SetArgs( const QByteArray& theArgs ); + + /** + * Returns the operator arguments + * \returns array that stores the operator arguments, needed for execution + */ + QByteArray Args(); + + /** + * Sets the "MustBeUpdated" flag: if image is depended on updated features. + * \param theFlag is true for images that must be updated, false for up-to-date + */ + void MustBeUpdated( bool theFlag ); + + /** + * Returns the "MustBeUpdated" flag: is image must be recomputed or not + * \returns false if image is up to date + */ + bool MustBeUpdated(); + + +protected: + + /** + * Creates new object in the internal data structure. Use higher level objects + * to create objects with real content. + */ + HYDROData_Image(); + + /** + * Destructs properties of the object and object itself, removes it from the document. + */ + ~HYDROData_Image(); +}; + + diff --git a/src/HYDROPy/HYDROData_Object.sip b/src/HYDROPy/HYDROData_Object.sip index 7d63afcf..59a7a4a1 100644 --- a/src/HYDROPy/HYDROData_Object.sip +++ b/src/HYDROPy/HYDROData_Object.sip @@ -72,7 +72,7 @@ public: /** * Returns the kind of this object. Must be redefined in all objects of known type. */ - //virtual const ObjectKind GetKind() const {return KIND_UNKNOWN;} + const ObjectKind GetKind() const; /** * Returns the name of this object. @@ -126,8 +126,6 @@ public: protected: - //friend class HYDROData_Iterator; - /** * Creates new object in the internal data structure. Use higher level objects * to create objects with real content. diff --git a/src/HYDROPy/HYDROPy.vcproj b/src/HYDROPy/HYDROPy.vcproj new file mode 100644 index 00000000..71b1051d --- /dev/null +++ b/src/HYDROPy/HYDROPy.vcproj @@ -0,0 +1,201 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +