]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
Python wrapping for sequence of HYDRO data objects.
authoradv <adv@opencascade.com>
Fri, 27 Dec 2013 09:33:32 +0000 (09:33 +0000)
committeradv <adv@opencascade.com>
Fri, 27 Dec 2013 09:33:32 +0000 (09:33 +0000)
CMake/UsePyQt4EXT.cmake
src/HYDROPy/CMakeLists.txt
src/HYDROPy/HYDROData.sip
src/HYDROPy/HYDROData_Entity.sip
src/HYDROPy/HYDROData_SequenceOfObjects.sip [new file with mode: 0644]

index 27bcce91968f10108cdaed09c6914b0a624a675a..ce01b53a1d16f0eab582b2b7a0889a18e607c9c7 100644 (file)
 ####################################################################
 MACRO(PYQT4_WRAP_SIP_EXT outfiles)
   FOREACH(_input ${ARGN})
-    FILE(STRINGS ${_input} _sip_modules REGEX "%Module")
-    FILE(STRINGS ${_input} _sip_includes REGEX "%Include")
-    FILE(STRINGS ${_input} _sip_classes REGEX "^class ")
+
     SET(_output)
-   
-    FOREACH(_sip_module ${_sip_modules})
-      STRING(REGEX MATCH ".*%Module *\\( *name=.*\\).*" _mod_name "${_sip_module}")
-      IF (_mod_name)
-        STRING(REGEX REPLACE ".*%Module *\\( *name=(.*).*\\).*" "\\1" _mod_name ${_sip_module})
-      ELSE()
-        STRING(REGEX REPLACE ".*%Module *(.*)" "\\1" _mod_name ${_sip_module})
-      ENDIF()
-      SET(_mod_header "sipAPI${_mod_name}.h")
-      SET(_mod_source "sip${_mod_name}cmodule${PYQT_CXX_EXT}")
-      LIST(APPEND _output ${CMAKE_CURRENT_BINARY_DIR}/${_mod_source})
-      SET(${outfiles} ${${outfiles}} ${CMAKE_CURRENT_BINARY_DIR}/${_mod_source})
-    ENDFOREACH()
-
-    FOREACH(_sip_include ${_sip_includes})
-      STRING(REGEX REPLACE ".*%Include +(.*)\\.sip *" "\\1" _include_name ${_sip_include})
-      SET(_include_source "sip${_mod_name}${_include_name}${PYQT_CXX_EXT}")
-      LIST(APPEND _output ${CMAKE_CURRENT_BINARY_DIR}/${_include_source})
-      SET(${outfiles} ${${outfiles}} ${CMAKE_CURRENT_BINARY_DIR}/${_include_source})
-    ENDFOREACH()
-
-    FOREACH(_sip_class ${_sip_classes})
-      STRING(REGEX MATCH ".*class +.* *:" _class_name "${_sip_class}")
-      IF (_class_name)
-        STRING(REGEX REPLACE ".*class +(.*) *:.*" "\\1" _class_name ${_sip_class})
-      ELSE()
-        STRING(REGEX REPLACE ".*class *(.*)" "\\1" _class_name ${_sip_class})
-      ENDIF()
-      STRING(STRIP ${_class_name} _class_name)
-      SET(_class_source "sip${_mod_name}${_class_name}${PYQT_CXX_EXT}")
-      LIST(APPEND _output ${CMAKE_CURRENT_BINARY_DIR}/${_class_source})
-      SET(${outfiles} ${${outfiles}} ${CMAKE_CURRENT_BINARY_DIR}/${_class_source})
-    ENDFOREACH()
-    
+       
+    LIST(APPEND _output ${CMAKE_CURRENT_BINARY_DIR}/sipHYDROPycmodule.cc)
+    SET(${outfiles} ${${outfiles}} ${CMAKE_CURRENT_BINARY_DIR}/sipHYDROPycmodule.cc)
+
+    LIST(APPEND _output ${CMAKE_CURRENT_BINARY_DIR}/sipHYDROPyHYDROData_ArtificialObject.cc)
+    SET(${outfiles} ${${outfiles}} ${CMAKE_CURRENT_BINARY_DIR}/sipHYDROPyHYDROData_ArtificialObject.cc)
+
+    LIST(APPEND _output ${CMAKE_CURRENT_BINARY_DIR}/sipHYDROPyHYDROData_Bathymetry.cc)
+    SET(${outfiles} ${${outfiles}} ${CMAKE_CURRENT_BINARY_DIR}/sipHYDROPyHYDROData_Bathymetry.cc)
+
+    LIST(APPEND _output ${CMAKE_CURRENT_BINARY_DIR}/sipHYDROPyHYDROData_CalculationCase.cc)
+    SET(${outfiles} ${${outfiles}} ${CMAKE_CURRENT_BINARY_DIR}/sipHYDROPyHYDROData_CalculationCase.cc)
+
+    LIST(APPEND _output ${CMAKE_CURRENT_BINARY_DIR}/sipHYDROPyHYDROData_Document.cc)
+    SET(${outfiles} ${${outfiles}} ${CMAKE_CURRENT_BINARY_DIR}/sipHYDROPyHYDROData_Document.cc)
+
+    LIST(APPEND _output ${CMAKE_CURRENT_BINARY_DIR}/sipHYDROPyHYDROData_Entity.cc)
+    SET(${outfiles} ${${outfiles}} ${CMAKE_CURRENT_BINARY_DIR}/sipHYDROPyHYDROData_Entity.cc)
+
+    LIST(APPEND _output ${CMAKE_CURRENT_BINARY_DIR}/sipHYDROPyHYDROData_IAltitudeObject.cc)
+    SET(${outfiles} ${${outfiles}} ${CMAKE_CURRENT_BINARY_DIR}/sipHYDROPyHYDROData_IAltitudeObject.cc)
+
+    LIST(APPEND _output ${CMAKE_CURRENT_BINARY_DIR}/sipHYDROPyHYDROData_Image.cc)
+    SET(${outfiles} ${${outfiles}} ${CMAKE_CURRENT_BINARY_DIR}/sipHYDROPyHYDROData_Image.cc)
+
+    LIST(APPEND _output ${CMAKE_CURRENT_BINARY_DIR}/sipHYDROPyHYDROData_ImmersibleZone.cc)
+    SET(${outfiles} ${${outfiles}} ${CMAKE_CURRENT_BINARY_DIR}/sipHYDROPyHYDROData_ImmersibleZone.cc)
+
+    LIST(APPEND _output ${CMAKE_CURRENT_BINARY_DIR}/sipHYDROPyHYDROData_IPolyline.cc)
+    SET(${outfiles} ${${outfiles}} ${CMAKE_CURRENT_BINARY_DIR}/sipHYDROPyHYDROData_IPolyline.cc)
+
+    LIST(APPEND _output ${CMAKE_CURRENT_BINARY_DIR}/sipHYDROPyHYDROData_NaturalObject.cc)
+    SET(${outfiles} ${${outfiles}} ${CMAKE_CURRENT_BINARY_DIR}/sipHYDROPyHYDROData_NaturalObject.cc)
+
+    LIST(APPEND _output ${CMAKE_CURRENT_BINARY_DIR}/sipHYDROPyHYDROData_Object.cc)
+    SET(${outfiles} ${${outfiles}} ${CMAKE_CURRENT_BINARY_DIR}/sipHYDROPyHYDROData_Object.cc)
+
+    LIST(APPEND _output ${CMAKE_CURRENT_BINARY_DIR}/sipHYDROPyHYDROData_Obstacle.cc)
+    SET(${outfiles} ${${outfiles}} ${CMAKE_CURRENT_BINARY_DIR}/sipHYDROPyHYDROData_Obstacle.cc)
+
+    LIST(APPEND _output ${CMAKE_CURRENT_BINARY_DIR}/sipHYDROPyHYDROData_PolylineXY.cc)
+    SET(${outfiles} ${${outfiles}} ${CMAKE_CURRENT_BINARY_DIR}/sipHYDROPyHYDROData_PolylineXY.cc)
+
+    LIST(APPEND _output ${CMAKE_CURRENT_BINARY_DIR}/sipHYDROPyHYDROData_ProfileUZ.cc)
+    SET(${outfiles} ${${outfiles}} ${CMAKE_CURRENT_BINARY_DIR}/sipHYDROPyHYDROData_ProfileUZ.cc)
+
+    LIST(APPEND _output ${CMAKE_CURRENT_BINARY_DIR}/sipHYDROPyHYDROData_Region.cc)
+    SET(${outfiles} ${${outfiles}} ${CMAKE_CURRENT_BINARY_DIR}/sipHYDROPyHYDROData_Region.cc)
+
+    LIST(APPEND _output ${CMAKE_CURRENT_BINARY_DIR}/sipHYDROPyHYDROData_River.cc)
+    SET(${outfiles} ${${outfiles}} ${CMAKE_CURRENT_BINARY_DIR}/sipHYDROPyHYDROData_River.cc)
+
+    LIST(APPEND _output ${CMAKE_CURRENT_BINARY_DIR}/sipHYDROPyHYDROData_Zone.cc)
+    SET(${outfiles} ${${outfiles}} ${CMAKE_CURRENT_BINARY_DIR}/sipHYDROPyHYDROData_Zone.cc)
+
+    LIST(APPEND _output ${CMAKE_CURRENT_BINARY_DIR}/sipHYDROPyNCollection_Sequence0100Handle_HYDROData_Entity.cc)
+    SET(${outfiles} ${${outfiles}} ${CMAKE_CURRENT_BINARY_DIR}/sipHYDROPyNCollection_Sequence0100Handle_HYDROData_Entity.cc)
+       
     ADD_CUSTOM_COMMAND(
       OUTPUT ${_output}
       COMMAND ${SIP_EXECUTABLE} ${PYQT_SIPFLAGS} ${CMAKE_CURRENT_SOURCE_DIR}/${_input}
index d1f9d1446c3d69543504f912157c56acb920d1c5..b30b6570b7788c1e53c0f16a7bca9048de282f31 100644 (file)
@@ -79,6 +79,7 @@ SET(_sip_files
 #  HYDROData_Document.sip
 
 SET(_sip_files2
+  HYDROData_SequenceOfObjects.sip
   HYDROData_Entity.sip
   HYDROData_IPolyline.sip
   HYDROData_IAltitudeObject.sip
index 13a1c7bef45f988e4a7771328583ea8650fd7a19..530587c811d66d3696a8095adefef510f5161763 100644 (file)
@@ -51,6 +51,7 @@ See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 
 %Import QtGuimod.sip
 
+%Include HYDROData_SequenceOfObjects.sip
 %Include HYDROData_Entity.sip
 %Include HYDROData_IPolyline.sip
 %Include HYDROData_IAltitudeObject.sip
index f0205a2f3adda593086515ba7a8fe920bdf614ac..d53bcbd582523bbfaca783db7d3ff69b45e3c3af 100644 (file)
@@ -144,6 +144,12 @@ public:
   void CopyTo( HYDROData_Entity theDestination ) const;
   */
 
+  /**
+   * Returns the list of all reference objects of this object.
+   * Base implementation always return empty list.
+   */
+  virtual HYDROData_SequenceOfObjects GetAllReferenceObjects() const;
+
 protected:
 
   /**
diff --git a/src/HYDROPy/HYDROData_SequenceOfObjects.sip b/src/HYDROPy/HYDROData_SequenceOfObjects.sip
new file mode 100644 (file)
index 0000000..be9b94c
--- /dev/null
@@ -0,0 +1,119 @@
+// 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 <NCollection_Sequence.hxx>
+%End
+
+%MappedType NCollection_Sequence<Handle_HYDROData_Entity>
+{
+%TypeHeaderCode
+#include <NCollection_Sequence.hxx>
+%End
+
+%ConvertFromTypeCode
+    // Create the list.
+    PyObject *l;
+
+    if ((l = PyList_New(sipCpp->Length())) == NULL)
+        return NULL;
+
+    // Set the list elements.
+    for (int i = 0; i < sipCpp->Length(); ++i)
+    {
+       HYDROData_Entity* aPntr = createPointer(sipCpp->Value(i));
+     
+        PyObject *tobj;
+        
+        if ((tobj = sipConvertFromNewType(aPntr, sipFindType( aPntr->DynamicType()->Name() ), sipTransferObj)) == NULL)
+        {
+            Py_DECREF(l);
+            {
+              Handle_HYDROData_Entity anEnt( aPntr );
+            }
+
+            return NULL;
+        }
+
+        PyList_SET_ITEM(l, i, tobj);
+    }
+
+    return l;
+%End
+
+%ConvertToTypeCode
+    SIP_SSIZE_T len;
+
+    // Check the type if that is all that is required.
+    if (sipIsErr == NULL)
+    {
+        if (!PySequence_Check(sipPy) || (len = PySequence_Size(sipPy)) < 0)
+            return 0;
+
+        for (SIP_SSIZE_T i = 0; i < len; ++i)
+        {
+            PyObject *itm = PySequence_ITEM(sipPy, i);
+            bool ok = (itm && sipCanConvertToType(itm, sipType_HYDROData_Entity, SIP_NOT_NONE));
+
+            Py_XDECREF(itm);
+
+            if (!ok)
+                return 0;
+        }
+
+        return 1;
+    }
+
+    NCollection_Sequence<Handle_HYDROData_Entity> *ql = 
+      new NCollection_Sequence<Handle_HYDROData_Entity>;
+    len = PySequence_Size(sipPy);
+    for (SIP_SSIZE_T i = 0; i < len; ++i)
+    {
+        PyObject *itm = PySequence_ITEM(sipPy, i);
+        int state;
+        HYDROData_Entity *t = 
+          reinterpret_cast<HYDROData_Entity *>(sipConvertToType(itm, sipType_HYDROData_Entity, sipTransferObj, SIP_NOT_NONE, &state, sipIsErr));
+
+        Py_DECREF(itm);
+        if (*sipIsErr)
+        {
+            sipReleaseType(t, sipType_HYDROData_Entity, state);
+
+            delete ql;
+            return 0;
+        }
+
+        Handle_HYDROData_Entity anEnt( t );
+        ql->Append( anEnt );
+
+        //sipReleaseType(t, sipType_HYDROData_Entity, state);
+    }
+    *sipCppPtr = ql;
+    return sipGetState(sipTransferObj);
+%End
+};
+
+typedef NCollection_Sequence<Handle_HYDROData_Entity> HYDROData_SequenceOfObjects;