X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDROData%2FHYDROData_Image.h;h=5a25af9ee633a20ce5e2f760476b7bd1aa2aa770;hb=a95289fabbb6fbf6f32c06207422c65aafd5bd65;hp=382cd817c4853c8c78277d8c327dfeaae682f194;hpb=84f8b4a57d3cdad820bc1333a5066699cd1c8ae3;p=modules%2Fhydro.git diff --git a/src/HYDROData/HYDROData_Image.h b/src/HYDROData/HYDROData_Image.h index 382cd817..5a25af9e 100644 --- a/src/HYDROData/HYDROData_Image.h +++ b/src/HYDROData/HYDROData_Image.h @@ -1,12 +1,37 @@ +// 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, 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 +// 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 +// #ifndef HYDROData_Image_HeaderFile #define HYDROData_Image_HeaderFile #include +#ifdef WIN32 + #pragma warning ( disable: 4251 ) +#endif + #include #include +#ifdef WIN32 + #pragma warning ( default: 4251 ) +#endif + DEFINE_STANDARD_HANDLE(HYDROData_Image, HYDROData_Entity) /**\class HYDROData_Image @@ -17,6 +42,17 @@ DEFINE_STANDARD_HANDLE(HYDROData_Image, HYDROData_Entity) */ class HYDROData_Image : public HYDROData_Entity { + +public: + + enum TransformationMode + { + ManualGeodesic = 0, + ManualCartesian, + CartesianFromFile, + ReferenceImage + }; + protected: /** * Enumeration of tags corresponding to the persistent object parameters. @@ -24,10 +60,11 @@ protected: enum DataTag { DataTag_First = HYDROData_Entity::DataTag_First + 100, ///< first tag, to reserve - DataTag_Operator, ///< name of the operator that must be executed for image update - DataTag_TrsfMode, ///< transformation mode (0 - Lambert93, 1 - Cartesian) - DataTag_TrsfPoints, ///< image transformation points (3 input + 3 output lambert + 3 output cartesian) - DataTag_FilePath ///< image imported file path + DataTag_Operator, ///< name of the operator that must be executed for image update + DataTag_TrsfMode, ///< transformation mode (0 - Lambert93, 1 - Cartesian, 2 - on other Image) + DataTag_TrsfPoints, ///< image transformation points + DataTag_TrsfImage, ///< reference transformation image + DataTag_FilePath ///< image imported file path }; public: @@ -41,16 +78,21 @@ public: /** * Dump Image object to Python script representation. */ - HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const; + HYDRODATA_EXPORT virtual QStringList DumpToPython( const QString& thePyScriptPath, + MapOfTreatedObjects& theTreatedObjects ) const; /** * Updates object state. * Reimplemented to update an Image object in the data structure. * Call this method whenever you made changes for operator or reference objects. * If it is changed, sets "MustBeUpdated" flag to other depended images. - * \param theIsForce force reupdating of data object */ - HYDRODATA_EXPORT virtual void Update( const bool theIsForce = true ); + HYDRODATA_EXPORT virtual void Update(); + + /** + * Checks that object has 2D presentation. Reimlemented to retun true. + */ + HYDRODATA_EXPORT virtual bool IsHas2dPrs() const; /** * Returns data of object wrapped to QVariant. @@ -59,6 +101,12 @@ public: */ HYDRODATA_EXPORT virtual QVariant GetDataVariant(); + /** + * Returns the list of all reference objects of this object. + */ + HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetAllReferenceObjects() const; + + /** * Stores the image * \param theImage new image @@ -99,63 +147,155 @@ public: HYDRODATA_EXPORT QTransform Trsf() const; /** - * Stores the image transformation points (3 input + 3 output) - * \param thePointA input point A - * \param thePointB input point B - * \param thePointC input point C - * \param theLambertPointA output point A in Lambert93 coordinates - * \param theLambertPointB output point B in Lambert93 coordinates - * \param theLambertPointC output point C in Lambert93 coordinates - * \param theCartesianPointA output point A in Cartesian coordinates - * \param theCartesianPointB output point B in Cartesian coordinates - * \param theCartesianPointC output point C in Cartesian coordinates + * Updates the matrix of transformation in accordance with reference points. + * \param theTrsf new transformation + */ + HYDRODATA_EXPORT void UpdateTrsf(); + + + /** + * Returns true if transformation is done by two points only + */ + HYDRODATA_EXPORT bool IsByTwoPoints() const; + + + /** + * Removes all references from this image. + */ + HYDRODATA_EXPORT bool HasReferences() const; + + /** + * Removes all references from this image. + */ + HYDRODATA_EXPORT void RemoveAllReferences(); + + + /** + * Stores the transformation points in local cs of image + * \param thePointA point A + * \param thePointB point B + * \param thePointC point C + */ + HYDRODATA_EXPORT void SetLocalPoints( const QPoint& thePointA, + const QPoint& thePointB, + const QPoint& thePointC = QPoint( INT_MIN, INT_MIN ), + const bool theIsUpdate = true ); + + /** + * Returns the transformation points in local cs of image + * \param thePointA point A + * \param thePointB point B + * \param thePointC point C + * \return true if all parameters has been set before + */ + HYDRODATA_EXPORT bool GetLocalPoints( QPoint& thePointA, + QPoint& thePointB, + QPoint& thePointC ) const; + + /** + * Returns true if local points has been set before + */ + HYDRODATA_EXPORT bool HasLocalPoints() const; + + + /** + * Stores the transformation points in global cs + * \param theMode transformation mode + * \param thePointA point A + * \param thePointB point B + * \param thePointC point C */ - HYDRODATA_EXPORT void SetTrsfPoints(const QPoint& thePointA, - const QPoint& thePointB, - const QPoint& thePointC, - const QPointF& theLambertPointA, - const QPointF& theLambertPointB, - const QPointF& theLambertPointC, - const QPointF& theCartesianPointA, - const QPointF& theCartesianPointB, - const QPointF& theCartesianPointC); + HYDRODATA_EXPORT void SetGlobalPoints( const TransformationMode& theMode, + const QPointF& thePointA, + const QPointF& thePointB, + const QPointF& thePointC = QPoint( INT_MIN, INT_MIN ), + const bool theIsUpdate = true ); /** - * Returns the image transformation points (3 input + 3 output) - * \param thePointA input point A - * \param thePointB input point B - * \param thePointC input point C - * \param theLambertPointA output point A in Lambert93 coordinates - * \param theLambertPointB output point B in Lambert93 coordinates - * \param theLambertPointC output point C in Lambert93 coordinates - * \param theCartesianPointA output point A in Cartesian coordinates - * \param theCartesianPointB output point B in Cartesian coordinates - * \param theCartesianPointC output point C in Cartesian coordinates + * Returns the transformation points in global cs + * \param theMode transformation mode + * \param thePointA point A + * \param thePointB point B + * \param thePointC point C + * \return true if all parameters has been set before */ - HYDRODATA_EXPORT void TrsfPoints(QPoint& thePointA, - QPoint& thePointB, - QPoint& thePointC, - QPointF& theLambertPointA, - QPointF& theLambertPointB, - QPointF& theLambertPointC, - QPointF& theCartesianPointA, - QPointF& theCartesianPointB, - QPointF& theCartesianPointC) const; + HYDRODATA_EXPORT bool GetGlobalPoints( TransformationMode& theMode, + QPointF& thePointA, + QPointF& thePointB, + QPointF& thePointC ) const; /** - * Returns true if the image has stored transformation points + * Get transformation points from the file and stores them in global cs + * \param theFileName the image georeferencement file name + * \return true in case of success */ - HYDRODATA_EXPORT bool HasTrsfPoints() const; + HYDRODATA_EXPORT bool SetGlobalPointsFromFile( const QString& theFileName ); + + /** + * Returns true if global points has been set before + */ + HYDRODATA_EXPORT bool HasGlobalPoints() const; + /** - * Stores the transformation mode (0 - Lambert93, 1 - Cartesian) + * Stores the transformation points in reference image local cs + * \param theRefImage reference image + * \param thePointA point A + * \param thePointB point B + * \param thePointC point C */ - HYDRODATA_EXPORT void SetTrsfMode(const int theMode); + HYDRODATA_EXPORT void SetReferencePoints( const Handle(HYDROData_Image)& theRefImage, + const QPointF& thePointA, + const QPointF& thePointB, + const QPointF& thePointC = QPoint( INT_MIN, INT_MIN ), + const bool theIsUpdate = true ); /** - * Returns the transformation mode (0 - Lambert93, 1 - Cartesian) + * Returns the transformation points in reference image local cs + * \param theRefImage reference image + * \param thePointA point A + * \param thePointB point B + * \param thePointC point C + * \return true if all parameters has been set correctly */ - HYDRODATA_EXPORT int TrsfMode() const; + HYDRODATA_EXPORT bool GetReferencePoints( Handle(HYDROData_Image)& theRefImage, + QPointF& thePointA, + QPointF& thePointB, + QPointF& thePointC ) const; + + /** + * Returns true if reference points has been set before + */ + HYDRODATA_EXPORT bool HasReferencePoints() const; + + + /** + * Stores the reference image for transformation + * \param theRefImage reference image + */ + HYDRODATA_EXPORT void SetTrsfReferenceImage( const Handle(HYDROData_Image)& theRefImage ); + + /** + * Returns the reference image for transformation + */ + HYDRODATA_EXPORT Handle(HYDROData_Image) GetTrsfReferenceImage() const; + + /** + * Removes the reference image for transformation + */ + HYDRODATA_EXPORT void RemoveTrsfReferenceImage(); + + + /** + * Stores the transformation mode + */ + HYDRODATA_EXPORT void SetTrsfMode( const TransformationMode& theMode ); + + /** + * Returns the transformation mode + */ + HYDRODATA_EXPORT TransformationMode GetTrsfMode() const; + /** * Returns the number of referenced objects @@ -196,6 +336,7 @@ public: */ HYDRODATA_EXPORT void ClearReferences(); + /** * Stores the operator name * \param theOpName name of the operator that must be executed for image update @@ -220,29 +361,24 @@ public: */ HYDRODATA_EXPORT QByteArray Args() const; - /** - * 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 - */ - HYDRODATA_EXPORT void MustBeUpdated(bool theFlag); /** - * Returns the "MustBeUpdated" flag: is image must be recomputed or not - * \returns false if image is up to date + * Marks the image as self-split. + * \param theFlag is true for self-plit image */ - HYDRODATA_EXPORT bool MustBeUpdated() const; + HYDRODATA_EXPORT void SetIsSelfSplit(bool theFlag); /** - * Marks the image as self-splitted. - * \param theFlag is true for self-splitted image + * Checks that the image is self-split. + * \returns true if image is self-split */ - HYDRODATA_EXPORT void SetIsSelfSplitted(bool theFlag); + HYDRODATA_EXPORT bool IsSelfSplit() const; - /** - * Checks that the image is self-splitted. - * \returns true if image is self-splitted - */ - HYDRODATA_EXPORT bool IsSelfSplitted() const; +private: + + QPointF generateThirdPoint( const QPointF& thePointA, + const QPointF& thePointB, + const bool& theIsLocal ) const; protected: @@ -252,12 +388,12 @@ protected: * Creates new object in the internal data structure. Use higher level objects * to create objects with real content. */ - HYDROData_Image(); + HYDRODATA_EXPORT HYDROData_Image(); /** * Destructs properties of the object and object itself, removes it from the document. */ - ~HYDROData_Image(); + HYDRODATA_EXPORT ~HYDROData_Image(); };