// 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 // %ExportedHeaderCode #include %End typedef int ObjectKind; const ObjectKind KIND_UNKNOWN; const ObjectKind KIND_IMAGE; const ObjectKind KIND_POLYLINE; const ObjectKind KIND_BATHYMETRY; const ObjectKind KIND_ALTITUDE; const ObjectKind KIND_IMMERSIBLE_ZONE; const ObjectKind KIND_RIVER; const ObjectKind KIND_STREAM; const ObjectKind KIND_CONFLUENCE; const ObjectKind KIND_CHANNEL; const ObjectKind KIND_OBSTACLE; const ObjectKind KIND_DIGUE; const ObjectKind KIND_PROFILE; const ObjectKind KIND_PROFILEUZ; const ObjectKind KIND_POLYLINEXY; const ObjectKind KIND_CALCULATION; const ObjectKind KIND_ZONE; const ObjectKind KIND_REGION; const ObjectKind KIND_SHAPES_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 { %TypeHeaderCode #include %End %ConvertToSubClassCode // HYDROData_Entity sub-classes provide a unique kind ID. switch ( sipCpp->GetKind() ) { case KIND_IMAGE: sipType = sipType_HYDROData_Image; break; case KIND_POLYLINE: sipType = sipType_HYDROData_Polyline3D; break; case KIND_BATHYMETRY: sipType = sipType_HYDROData_Bathymetry; break; case KIND_ALTITUDE: sipType = sipType_HYDROData_AltitudeObject; break; case KIND_IMMERSIBLE_ZONE: sipType = sipType_HYDROData_ImmersibleZone; break; case KIND_RIVER: sipType = sipType_HYDROData_River; break; case KIND_STREAM: sipType = sipType_HYDROData_Stream; break; case KIND_CONFLUENCE: sipType = sipType_HYDROData_Confluence; break; case KIND_CHANNEL: sipType = sipType_HYDROData_Channel; break; case KIND_OBSTACLE: sipType = sipType_HYDROData_Obstacle; break; case KIND_DIGUE: sipType = sipType_HYDROData_Digue; break; case KIND_PROFILE: sipType = sipType_HYDROData_Profile; break; case KIND_PROFILEUZ: sipType = sipType_HYDROData_ProfileUZ; break; case KIND_POLYLINEXY: sipType = sipType_HYDROData_PolylineXY; break; case KIND_CALCULATION: sipType = sipType_HYDROData_CalculationCase; break; case KIND_ZONE: sipType = sipType_HYDROData_Zone; break; case KIND_REGION: sipType = sipType_HYDROData_Region; break; case KIND_SHAPES_GROUP: sipType = sipType_HYDROData_ShapesGroup; break; case KIND_SPLIT_GROUP: sipType = sipType_HYDROData_SplitShapesGroup; break; case KIND_STREAM_ALTITUDE: sipType = sipType_HYDROData_StreamAltitude; break; case KIND_OBSTACLE_ALTITUDE: sipType = sipType_HYDROData_ObstacleAltitude; break; case KIND_STRICKLER_TABLE: sipType = sipType_HYDROData_StricklerTable; break; case KIND_LAND_COVER_MAP: sipType = sipType_HYDROData_LandCoverMap; break; case KIND_BC_POLYGON: sipType = sipType_HYDROData_BCPolygon; break; case KIND_UNKNOWN: sipType = sipType_HYDROData_Entity; break; default: // We don't recognise the type. sipType = NULL; } %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. */ virtual const ObjectKind GetKind() const; /** * Returns the name of this object. */ virtual QString GetName() const; /** * Updates the name of this object. */ virtual void SetName(const QString& theName, bool isDefault = false ); /** * Updates object state. */ virtual void Update(); /** * Checks that object has 2D presentation. Base implementation returns false. */ virtual bool IsHas2dPrs() const; /** * Returns data of object wrapped to QVariant. * Base implementation returns null value. */ virtual QVariant GetDataVariant(); /** * 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 */ bool IsRemoved() const; /** * Removes object from the data structure. */ virtual void Remove(); /** * Returns father object. For object created under root document label * this method always return NULL object. */ HYDROData_Entity GetFatherObject() const [opencascade::handle ()]; %MethodCode Handle(HYDROData_Entity) aFather; Py_BEGIN_ALLOW_THREADS aFather = sipSelfWasArg ? sipCpp->HYDROData_Entity::GetFatherObject() : sipCpp->GetFatherObject(); Py_END_ALLOW_THREADS sipRes = createPointer( aFather ); %End /** * Returns the list of all reference objects of this object. * Base implementation always return empty list. */ virtual HYDROData_SequenceOfObjects GetAllReferenceObjects() const; /** * Returns the z-level for object presentation, -1 if no z-level. */ virtual bool GetZLevel( int& theLevel ) const [bool ( Standard_Integer& )]; /** * Set the z-level for object presentation. */ virtual void SetZLevel( const int& theLevel ) [void ( const Standard_Integer& )]; /** * Remove the z-level of object presentation. */ 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 * to create objects with real content. */ HYDROData_Entity( Geometry ); /** * Destructs properties of the object and object itself, removes it from the document. */ virtual ~HYDROData_Entity(); }; %MappedType std::vector { %TypeHeaderCode #include %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 *aSeq = new std::vector; 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(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 };