Salome HOME
Merge branch 'BR_H2018_3' into BR_2018_V8_5
[modules/hydro.git] / src / HYDROPy / HYDROData_Image.sip
index f1e7cff982c558d22356b165ef5c3c429f9aeeea..64935d935ef9e507ccffb6e3495592004d93ab59 100644 (file)
@@ -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
 #include <HYDROData_Image.h>
 %End
 
-class HYDROData_Image : HYDROData_Object
+class HYDROData_Image : public HYDROData_Entity
 {
 
 %ConvertToSubClassCode
-    if ( !Handle(HYDROData_Image)::DownCast( sipCpp ).IsNull() )
-      sipClass = sipClass_HYDROData_Image;
-    else
-      sipClass = NULL;
+    switch ( sipCpp->GetKind() )
+    {
+      case KIND_IMAGE:
+        sipClass = sipClass_HYDROData_Image;
+        break;
+
+      default:
+        // We don't recognise the type.
+        sipClass = NULL;
+    }
 %End
 
 %TypeHeaderCode
@@ -40,7 +42,13 @@ class HYDROData_Image : HYDROData_Object
 
 public:
 
-  const ObjectKind           GetKind() const;
+  enum TransformationMode
+  {
+    ManualGeodesic = 0,
+    ManualCartesian,
+    CartesianFromFile,
+    ReferenceImage
+  };
 
 public:      
 
@@ -48,174 +56,344 @@ public:
    * Stores the image
    * \param theImage new image
    */
-  void                       SetImage( const QImage& theImage );
+  void SetImage( const QImage& theImage );
 
   /**
    * Load the image from file
    * \param theFilePath path to image
    */
-  bool                       LoadImage( const QString& theFilePath );
+  bool LoadImage( const QString& theFilePath );
 
   /**
    * Returns the kept image
    */
-  QImage                     Image();
+  QImage Image();
+
 
+  /**
+   * Stores the image file path
+   * \param theFilePath image file path
+   */
+  void SetFilePath( const QString& theFilePath );
+
+  /**
+   * Returns uploaded image file path
+   */
+  QString GetFilePath() const;
+
+  
   /**
    * Stores the image transformation
    * \param theTrsf new transformation
    */
-  void                       SetTrsf( const QTransform& theTrsf );
+  void SetTrsf( const QTransform& theTrsf );
 
   /**
    * Returns the kept transformation, or "identity" if not yet stored
    */
-  QTransform                 Trsf();
+  QTransform Trsf() const;
+
+  /**
+   * Updates the matrix of transformation in accordance with reference points.
+   * \param theTrsf new transformation
+   */
+  void UpdateTrsf();
+
+
+  /**
+   * Returns true if transformation is done by two points only
+   */
+  bool IsByTwoPoints() const;
+
+
+  /**
+   * Removes all references from this image.
+   */
+  bool HasReferences() const;
+
+  /**
+   * Removes all references from this image.
+   */
+  void RemoveAllReferences();
+
+
+  /**
+   * Stores the transformation points in local cs of image
+   * \param thePointA point A
+   * \param thePointB point B
+   * \param thePointC point C
+   */
+  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
+   */
+  bool GetLocalPoints( QPoint& thePointA /Out/,
+                       QPoint& thePointB /Out/,
+                       QPoint& thePointC /Out/ ) const;
+
+  /**
+   * Returns true if local points has been set before
+   */
+  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
+   */
+  void SetGlobalPoints( const TransformationMode& theMode,
+                        const QPointF&            thePointA,
+                        const QPointF&            thePointB,
+                        const QPointF&            thePointC = QPoint( INT_MIN, INT_MIN ),
+                        const bool                theIsUpdate = true  );
 
   /**
-   * 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
+   * 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
    */
-  void                       SetTrsfPoints( const QPoint&  thePointAIn,
-                                            const QPoint&  thePointBIn,
-                                            const QPoint&  thePointCIn,
-                                            const QPointF& thePointAOut,
-                                            const QPointF& thePointBOut,
-                                            const QPointF& thePointCOut );
+  bool GetGlobalPoints( TransformationMode& theMode,
+                        QPointF&            thePointA /Out/,
+                        QPointF&            thePointB /Out/,
+                        QPointF&            thePointC /Out/ ) const;
 
   /**
-   * 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
+   * 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
    */
-  void                       TrsfPoints( QPoint&  thePointAIn,
-                                         QPoint&  thePointBIn,
-                                         QPoint&  thePointCIn,
-                                         QPointF& thePointAOut,
-                                         QPointF& thePointBOut,
-                                         QPointF& thePointCOut );
+  bool SetGlobalPointsFromFile( const QString& theFileName );
+
+  /**
+   * Returns true if global points has been set before
+   */
+  bool HasGlobalPoints() const;
+
 
   /**
-   * Appends reference to other image.
-   * \param theReferenced the image referenced by this
+   * 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
    */
-  void AppendReference( HYDROData_Image theReferenced ) [void (Handle_HYDROData_Image)];
+  void SetReferencePoints( HYDROData_Image theRefImage,
+                           const QPointF&  thePointA,
+                           const QPointF&  thePointB,
+                           const QPointF&  thePointC = QPoint( INT_MIN, INT_MIN ),
+                           const bool      theIsUpdate = true )
+  [void ( const opencascade::handle<HYDROData_Image>&, const QPointF&, const QPointF&, const QPointF&, const bool )];
   %MethodCode
+    Handle(HYDROData_Image) aRefImage =
+      Handle(HYDROData_Image)::DownCast( createHandle( a0 ) );
+    if ( !aRefImage.IsNull() )
+    {
+      Py_BEGIN_ALLOW_THREADS
+      sipSelfWasArg ? sipCpp->HYDROData_Image::SetReferencePoints( aRefImage, *a1, *a2, *a3, a4 ) :
+                      sipCpp->SetReferencePoints( aRefImage, *a1, *a2, *a3, a4 );
+      Py_END_ALLOW_THREADS
+    }
+  %End
 
-    Handle(HYDROData_Image) anImage = 
+  /**
+   * 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
+   */
+  bool GetReferencePoints( HYDROData_Image theRefImage,
+                           QPointF&        thePointA /Out/,
+                           QPointF&        thePointB /Out/,
+                           QPointF&        thePointC /Out/ ) const
+  [bool ( const opencascade::handle<HYDROData_Image>&, QPointF&, QPointF&, QPointF& )];
+  %MethodCode
+    Handle(HYDROData_Image) aRefImage =
+      Handle(HYDROData_Image)::DownCast( createHandle( a0 ) );
+    if ( !aRefImage.IsNull() )
+    {
+      Py_BEGIN_ALLOW_THREADS
+      sipRes = sipSelfWasArg ? sipCpp->HYDROData_Image::GetReferencePoints( aRefImage, *a1, *a2, *a3 ) :
+                               sipCpp->GetReferencePoints( aRefImage, *a1, *a2, *a3 );
+      Py_END_ALLOW_THREADS
+    }
+  %End
+
+  /**
+   * Returns true if reference points has been set before
+   */
+  bool HasReferencePoints() const;
+
+  /**
+   * Stores the reference image for transformation
+   * \param theRefImage reference image
+   */
+  void SetTrsfReferenceImage( HYDROData_Image theRefImage ) [void ( const opencascade::handle<HYDROData_Image>& )];
+  %MethodCode
+    Handle(HYDROData_Image) aRefImage =
       Handle(HYDROData_Image)::DownCast( createHandle( a0 ) );
-    if ( !anImage.IsNull() )
+    if ( !aRefImage.IsNull() )
     {
       Py_BEGIN_ALLOW_THREADS
-      sipSelfWasArg ? sipCpp->HYDROData_Image::AppendReference( anImage ) : 
-                      sipCpp->AppendReference( anImage );
+      sipSelfWasArg ? sipCpp->HYDROData_Image::SetTrsfReferenceImage( aRefImage ) :
+                      sipCpp->SetTrsfReferenceImage( aRefImage );
       Py_END_ALLOW_THREADS
     }
+  %End
 
+  /**
+   * Returns the reference image for transformation
+   */
+  HYDROData_Image GetTrsfReferenceImage() const [opencascade::handle<HYDROData_Image> ()];
+  %MethodCode
+    Handle(HYDROData_Image) aRefImage;
+    
+    Py_BEGIN_ALLOW_THREADS
+    aRefImage = sipSelfWasArg ? sipCpp->HYDROData_Image::GetTrsfReferenceImage() : 
+                                sipCpp->GetTrsfReferenceImage();
+    Py_END_ALLOW_THREADS
+    
+    sipRes = (HYDROData_Image*)createPointer( aRefImage );
   %End
 
   /**
-   * Returns the number of referenced images
+   * Removes the reference image for transformation
+   */
+  void                       RemoveTrsfReferenceImage();
+
+
+  /**
+   * Stores the transformation mode
+   */
+  void                       SetTrsfMode( const TransformationMode& theMode );
+
+  /**
+   * Returns the transformation mode
+   */
+  TransformationMode         GetTrsfMode() const;
+
+
+  /**
+   * Returns the number of referenced objects
    * \return zero if there is no references
    */
-  int                        NbReferences();
+  int                        NbReferences() const;
+
+  /**
+   * Appends reference to other object (image or polyline).
+   * \param theReferenced the object referenced by this
+   */
+  void AppendReference( HYDROData_Entity theReferenced ) [void ( const opencascade::handle<HYDROData_Entity>& )];
+  %MethodCode
+    Handle(HYDROData_Entity) aRef = createHandle( a0 );
+    if ( !aRef.IsNull() )
+    {
+      Py_BEGIN_ALLOW_THREADS
+      sipSelfWasArg ? sipCpp->HYDROData_Image::AppendReference( aRef ) :
+                      sipCpp->AppendReference( aRef );
+      Py_END_ALLOW_THREADS
+    }
+  %End
 
   /**
    * Returns reference by index.
    * \param theIndex number of reference [0; NbReference)
-   * \returns the referenced image, or Null if index is invalid
+   * \returns the referenced object, or Null if index is invalid
    */
-  HYDROData_Image Reference( const int theIndex ) const [Handle_HYDROData_Image (const int)];
+  HYDROData_Entity Reference( const int theIndex ) const [opencascade::handle<HYDROData_Entity> ()];
   %MethodCode
-
-    Handle(HYDROData_Image) anImage;
+    Handle(HYDROData_Entity) aRef;
     
     Py_BEGIN_ALLOW_THREADS
-    sipSelfWasArg ? sipCpp->HYDROData_Image::Reference( a0 ) : 
-                    sipCpp->Reference( a0 );
+    aRef = sipSelfWasArg ? sipCpp->HYDROData_Image::Reference( a0 ) : 
+                           sipCpp->Reference( a0 );
     Py_END_ALLOW_THREADS
     
-    sipRes = dynamic_cast<HYDROData_Image*>( createPointer( anImage ) );
-  
+    sipRes = createPointer( aRef );
   %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
+   * \param theReferenced the object referenced by this
    */
-  void ChangeReference( const int theIndex, HYDROData_Image theReferenced ) [void (const int, Handle_HYDROData_Image)];
+  void ChangeReference( const int theIndex, HYDROData_Entity theReferenced )
+  [void ( const int, const opencascade::handle<HYDROData_Entity>& )];
   %MethodCode
-
-    Handle(HYDROData_Image) anImage = 
-      Handle(HYDROData_Image)::DownCast( createHandle( a1 ) );
-    if ( !anImage.IsNull() )
+    Handle(HYDROData_Entity) aRef = createHandle( a1 );
+    if ( !aRef.IsNull() )
     {
       Py_BEGIN_ALLOW_THREADS
-      sipSelfWasArg ? sipCpp->HYDROData_Image::ChangeReference( a0, anImage ) : 
-                      sipCpp->ChangeReference( a0, anImage );
+      sipSelfWasArg ? sipCpp->HYDROData_Image::ChangeReference( a0, aRef ) :
+                      sipCpp->ChangeReference( a0, aRef );
       Py_END_ALLOW_THREADS
     }
-  
   %End
 
   /**
    * Removes reference by index
    * \param theIndex number of reference [0; NbReference)
    */
-  void                       RemoveReference( const int theIndex );
+  void RemoveReference( const int theIndex );
 
   /**
    * Removes all references.
    */
-  void                       ClearReferences();
+  void ClearReferences();
+
 
   /**
    * Stores the operator name
    * \param theOpName name of the operator that must be executed for image update
    */
-  void                       SetOperatorName( const QString theOpName );
+  void SetOperatorName(const QString theOpName);
 
   /**
    * Returns the operator name
    * \returns the name of the operator that must be executed for image update
    */
-  QString                    OperatorName();
+  QString OperatorName() const;
 
   /**
    * Stores the operator arguments
    * \param theArgs array that stores the operator arguments, needed for execution
    */
-  void                       SetArgs( const QByteArray& theArgs );
+  void SetArgs(const QByteArray& theArgs);
 
   /**
    * Returns the operator arguments
    * \returns array that stores the operator arguments, needed for execution
    */
-  QByteArray                 Args();
+  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
+   * Marks the image as self-split.
+   * \param theFlag is true for self-split image
    */
-  void                       MustBeUpdated( bool theFlag );
+  void SetIsSelfSplit(bool theFlag);
 
   /**
-   * Returns the "MustBeUpdated" flag: is image must be recomputed or not
-   * \returns false if image is up to date
+   * Checks that the image is self-split.
+   * \returns true if image is self-split
    */
-  bool                       MustBeUpdated();
-
+  bool IsSelfSplit() const;
 
 protected: