Salome HOME
Correction for hydro_test
[modules/hydro.git] / src / HYDROPy / HYDROData_Entity.sip
index 6492535a1e908a3b7a96622235271afbf6171436..344d691a3f7db18c609d49ef90108a1c9d1b23fd 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
@@ -45,8 +41,11 @@ const ObjectKind KIND_CALCULATION;
 const ObjectKind KIND_ZONE;
 const ObjectKind KIND_REGION;
 const ObjectKind KIND_SHAPES_GROUP;
-const ObjectKind KIND_SPLITTED_GROUP;
+const ObjectKind KIND_SPLIT_GROUP;
 const ObjectKind KIND_OBSTACLE_ALTITUDE;
+const ObjectKind KIND_STRICKLER_TABLE;
+const ObjectKind KIND_LAND_COVER_MAP;
+const ObjectKind KIND_BC_POLYGON;
 
 class HYDROData_Entity
 {
@@ -129,9 +128,9 @@ class HYDROData_Entity
       case KIND_SHAPES_GROUP:
         sipClass = sipClass_HYDROData_ShapesGroup;
         break;
-        
-      case KIND_SPLITTED_GROUP:
-        sipClass = sipClass_HYDROData_SplittedShapesGroup;
+
+      case KIND_SPLIT_GROUP:
+        sipClass = sipClass_HYDROData_SplitShapesGroup;
         break;
 
       case KIND_STREAM_ALTITUDE:
@@ -142,6 +141,18 @@ class HYDROData_Entity
         sipClass = sipClass_HYDROData_ObstacleAltitude;
         break;
 
+      case KIND_STRICKLER_TABLE:
+        sipClass = sipClass_HYDROData_StricklerTable;
+        break;
+
+      case KIND_LAND_COVER_MAP:
+        sipClass = sipClass_HYDROData_LandCoverMap;
+        break;
+
+      case KIND_BC_POLYGON:
+        sipClass = sipClass_HYDROData_BCPolygon;
+        break;
+
       case KIND_UNKNOWN:
         sipClass = sipClass_HYDROData_Entity;
         break;
@@ -153,6 +164,16 @@ class HYDROData_Entity
 %End
 
 public:
+  enum Geometry
+  {
+    Geom_No = 1,
+    Geom_2d = 2,
+    Geom_Z  = 4,
+    Geom_Groups = 8,
+
+    Geom_3d = 6,
+    Geom_2d_and_groups = 10,
+  };
 
   /**
    * Returns the kind of this object. Must be redefined in all objects of known type.
@@ -167,7 +188,7 @@ public:
   /**
    * Updates the name of this object.
    */
-  virtual void SetName(const QString& theName);
+  virtual void SetName(const QString& theName, bool isDefault = false );
 
   /**
    * Updates object state.
@@ -185,25 +206,12 @@ public:
    */
   virtual QVariant GetDataVariant();
 
-
-  /**
-   * Sets the "MustBeUpdated" flag: if object is depended on updated features.
-   * \param theFlag is true for objects that must be updated, false for up-to-date
-   */
-  virtual void SetToUpdate( bool theFlag );
-
-  /**
-   * Returns the "MustBeUpdated" flag: is object data must be updated or not
-   * \returns false if object is up to date
-   */
-  virtual bool IsMustBeUpdated() const;
-
   /**
    * Returns flag indicating that object is updateble or not.
    */
   virtual bool CanBeUpdated() const;
 
-  
+
   /**
    * Checks is object exists in the data structure.
    * \returns true is object is not exists in the data model
@@ -215,37 +223,19 @@ public:
    */
   virtual void Remove();
 
-
-  /**
-   * Copies all properties of this to the destinated object.
-   * Objects must be the same type.
-   * \param theDestination initialized object (from any document) - target of copying
-   */
-  void CopyTo( HYDROData_Entity theDestination ) const [void ( const Handle_HYDROData_Entity& )];
-  %MethodCode
-    Handle(HYDROData_Entity) aCopyTo = createHandle( a0 );
-    if ( !aCopyTo.IsNull() )
-    {
-      Py_BEGIN_ALLOW_THREADS
-      sipSelfWasArg ? sipCpp->HYDROData_Entity::CopyTo( aCopyTo ):
-                      sipCpp->CopyTo( aCopyTo );
-      Py_END_ALLOW_THREADS
-    }
-  %End
-
   /**
    * Returns father object. For object created under root document label
    * this method always return NULL object.
    */
-  HYDROData_Entity GetFatherObject() const [Handle_HYDROData_Entity ()];
+  HYDROData_Entity GetFatherObject() const [opencascade::handle<HYDROData_Entity> ()];
   %MethodCode
     Handle(HYDROData_Entity) aFather;
-    
+
     Py_BEGIN_ALLOW_THREADS
-    aFather = sipSelfWasArg ? sipCpp->HYDROData_Entity::GetFatherObject() : 
+    aFather = sipSelfWasArg ? sipCpp->HYDROData_Entity::GetFatherObject() :
                               sipCpp->GetFatherObject();
     Py_END_ALLOW_THREADS
-    
+
     sipRes = createPointer( aFather );
   %End
 
@@ -259,7 +249,7 @@ public:
   /**
    * Returns the z-level for object presentation, -1 if no z-level.
    */
-  virtual bool GetZLevel( int& theLevel ) const [Standard_Boolean ( Standard_Integer& )];
+  virtual bool GetZLevel( int& theLevel ) const [bool ( Standard_Integer& )];
 
   /**
    * Set the z-level for object presentation.
@@ -271,18 +261,107 @@ public:
    */
   virtual void RemoveZLevel();
 
+   void SetColor( const QColor& theColor, const int theTag = 0 );
 
 protected:
 
   /**
-   * Creates new object in the internal data structure. Use higher level objects 
+   * Creates new object in the internal data structure. Use higher level objects
    * to create objects with real content.
    */
-  HYDROData_Entity();
+  HYDROData_Entity( Geometry );
 
   /**
    * Destructs properties of the object and object itself, removes it from the document.
    */
   virtual ~HYDROData_Entity();
-  
+
+};
+
+
+%MappedType std::vector<HYDROData_Entity*>
+{
+%TypeHeaderCode
+#include <vector>
+%End
+
+%ConvertFromTypeCode
+    // Create the list.
+    PyObject *l;
+
+    if ( ( l = PyList_New( sipCpp->size() ) ) == NULL )
+      return NULL;
+
+    // Set the list elements.
+    for ( int i = 0, n = sipCpp->size(); i < n; ++i )
+    {
+      HYDROData_Entity* t = (*sipCpp)[i];                   //new HYDROData_Entity( ( sipCpp)[i] );
+
+      PyObject* pobj;
+      if ( ( pobj = sipConvertFromNewType( t, sipType_HYDROData_Entity, sipTransferObj ) ) == NULL )
+      {
+        Py_DECREF( l );
+        //delete t;
+
+        return NULL;
+      }
+
+      PyList_SET_ITEM( l, i, pobj );
+    }
+
+    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;
+    }
+
+    std::vector<HYDROData_Entity*> *aSeq = new std::vector<HYDROData_Entity*>;
+    len = PySequence_Size(sipPy);
+       aSeq->reserve( len );
+    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 aSeq;
+            return 0;
+        }
+
+        aSeq->push_back(t);
+
+        sipReleaseType(t, sipType_HYDROData_Entity, state);
+    }
+    *sipCppPtr = aSeq;
+    return sipGetState(sipTransferObj);
+%End
 };