]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
Python API for HYDROData_Image.
authoradv <adv@opencascade.com>
Thu, 5 Sep 2013 12:16:12 +0000 (12:16 +0000)
committeradv <adv@opencascade.com>
Thu, 5 Sep 2013 12:16:12 +0000 (12:16 +0000)
HYDRO.sln
src/HYDROPy/HYDROData.sip
src/HYDROPy/HYDROData_Bathymetry.sip
src/HYDROPy/HYDROData_Document.sip
src/HYDROPy/HYDROData_Image.sip [new file with mode: 0644]
src/HYDROPy/HYDROData_Object.sip
src/HYDROPy/HYDROPy.vcproj [new file with mode: 0644]

index 49e794196e087ec8a6ae4e71d2dec83da7c5a5ab..52d0869cc2ffa642fc89df840835398340fe469e 100644 (file)
--- 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
index ae4ec313697320cb02e48ce3e0a621450eefe6dc..9bb7e82fddb2bdc01b46dbd9dad63a0a25380873 100644 (file)
@@ -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
index 2d5911e0616177bcb90444e1f8a99997b78de379..8666ba56f60e203520e7a1469649e20a79aab00c 100644 (file)
 //
 
 %ExportedHeaderCode
-
 #include <HYDROData_Bathymetry.h>
-
 #include <gp_XYZ.hxx>
-
 %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.
index 57f60e9bb7dc2cb06f3034b83af3b0b6f597074c..9c4779fff7f9a0a7a0b30540b8b180ac75ed450a 100644 (file)
 #include <HYDROData_Document.h>
 %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<HYDROData_Bathymetry*>( theObject ) );
+        break;
+      }
+      case KIND_IMAGE:
+      {
+        aRes = new HYDROData_Image( *dynamic_cast<HYDROData_Image*>( 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 (file)
index 0000000..0861739
--- /dev/null
@@ -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 <HYDROData_Image.h>
+%End
+
+class HYDROData_Image : HYDROData_Object
+{
+
+%ConvertToSubClassCode
+    if ( !Handle(HYDROData_Image)::DownCast( sipCpp ).IsNull() )
+      sipClass = sipClass_HYDROData_Image;
+    else
+      sipClass = NULL;
+%End
+
+%TypeHeaderCode
+#include <HYDROData_Image.h>
+%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<HYDROData_Image*>( 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();
+};
+
+
index 7d63afcfd6f932e8e44aeb3fbac07085f09aaade..59a7a4a168f083589d3aed8cf1f6479cf0d1dc50 100644 (file)
@@ -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 (file)
index 0000000..71b1051
--- /dev/null
@@ -0,0 +1,201 @@
+<?xml version="1.0" encoding="windows-1251"?>
+<VisualStudioProject
+       ProjectType="Visual C++"
+       Version="9.00"
+       Name="HYDROPy"
+       ProjectGUID="{72DE2E1A-BDE1-4BBE-8225-3D3DB2CC6C93}"
+       RootNamespace="HYDROPy"
+       Keyword="ManagedCProj"
+       TargetFrameworkVersion="196613"
+       >
+       <Platforms>
+               <Platform
+                       Name="Win32"
+               />
+       </Platforms>
+       <ToolFiles>
+       </ToolFiles>
+       <Configurations>
+               <Configuration
+                       Name="Debug|Win32"
+                       OutputDirectory=".\..\..\Debug"
+                       IntermediateDirectory=".\..\..\Debug\HYDROPy"
+                       ConfigurationType="4"
+                       InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+                       CharacterSet="1"
+                       ManagedExtensions="1"
+                       >
+                       <Tool
+                               Name="VCPreBuildEventTool"
+                       />
+                       <Tool
+                               Name="VCCustomBuildTool"
+                       />
+                       <Tool
+                               Name="VCXMLDataGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCWebServiceProxyGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCMIDLTool"
+                       />
+                       <Tool
+                               Name="VCCLCompilerTool"
+                               Optimization="0"
+                               PreprocessorDefinitions="WIN32;_DEBUG"
+                               RuntimeLibrary="3"
+                               WarningLevel="3"
+                               DebugInformationFormat="3"
+                       />
+                       <Tool
+                               Name="VCManagedResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCPreLinkEventTool"
+                       />
+                       <Tool
+                               Name="VCLibrarianTool"
+                       />
+                       <Tool
+                               Name="VCALinkTool"
+                       />
+                       <Tool
+                               Name="VCXDCMakeTool"
+                       />
+                       <Tool
+                               Name="VCBscMakeTool"
+                       />
+                       <Tool
+                               Name="VCFxCopTool"
+                       />
+                       <Tool
+                               Name="VCPostBuildEventTool"
+                       />
+               </Configuration>
+               <Configuration
+                       Name="Release|Win32"
+                       OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+                       IntermediateDirectory="$(ConfigurationName)"
+                       ConfigurationType="1"
+                       CharacterSet="1"
+                       ManagedExtensions="1"
+                       WholeProgramOptimization="1"
+                       >
+                       <Tool
+                               Name="VCPreBuildEventTool"
+                       />
+                       <Tool
+                               Name="VCCustomBuildTool"
+                       />
+                       <Tool
+                               Name="VCXMLDataGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCWebServiceProxyGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCMIDLTool"
+                       />
+                       <Tool
+                               Name="VCCLCompilerTool"
+                               PreprocessorDefinitions="WIN32;NDEBUG"
+                               RuntimeLibrary="2"
+                               WarningLevel="3"
+                               DebugInformationFormat="3"
+                       />
+                       <Tool
+                               Name="VCManagedResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCPreLinkEventTool"
+                       />
+                       <Tool
+                               Name="VCLinkerTool"
+                               AdditionalDependencies="$(NoInherit)"
+                               LinkIncremental="1"
+                               GenerateDebugInformation="true"
+                               TargetMachine="1"
+                       />
+                       <Tool
+                               Name="VCALinkTool"
+                       />
+                       <Tool
+                               Name="VCManifestTool"
+                       />
+                       <Tool
+                               Name="VCXDCMakeTool"
+                       />
+                       <Tool
+                               Name="VCBscMakeTool"
+                       />
+                       <Tool
+                               Name="VCFxCopTool"
+                       />
+                       <Tool
+                               Name="VCAppVerifierTool"
+                       />
+                       <Tool
+                               Name="VCPostBuildEventTool"
+                       />
+               </Configuration>
+       </Configurations>
+       <References>
+       </References>
+       <Files>
+               <Filter
+                       Name="Source Files"
+                       Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+                       UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+                       >
+                       <File
+                               RelativePath=".\configure.py"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\HYDROData.py.in"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\HYDROData.sip"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\HYDROData_Bathymetry.sip"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\HYDROData_Document.sip"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\HYDROData_Image.sip"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\HYDROData_Object.sip"
+                               >
+                       </File>
+               </Filter>
+               <Filter
+                       Name="Header Files"
+                       Filter="h;hpp;hxx;hm;inl;inc;xsd"
+                       UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+                       >
+               </Filter>
+               <Filter
+                       Name="Resource Files"
+                       Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
+                       UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+                       >
+               </Filter>
+       </Files>
+       <Globals>
+       </Globals>
+</VisualStudioProject>