X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDROData%2FHYDROData_Zone.cxx;h=36b13d65629b20eb2edd5293622947deb8edf647;hb=0d9decc8762a829f1bdc69048fab08122e441ec0;hp=3af90622deec733c285953a517d81db4c80b5332;hpb=f664563df96e1f99e099bc90a1088533e6a018b0;p=modules%2Fhydro.git diff --git a/src/HYDROData/HYDROData_Zone.cxx b/src/HYDROData/HYDROData_Zone.cxx index 3af90622..36b13d65 100644 --- a/src/HYDROData/HYDROData_Zone.cxx +++ b/src/HYDROData/HYDROData_Zone.cxx @@ -1,24 +1,24 @@ #include "HYDROData_Zone.h" -#include "HYDROData_Bathymetry.h" #include "HYDROData_Document.h" -#include "HYDROData_Polyline.h" -#include "HYDROData_Iterator.h" +#include "HYDROData_Object.h" -#include -#include -#include +#include +#include + +#include -#include #include #define PYTHON_ZONE_ID "KIND_ZONE" -IMPLEMENT_STANDARD_HANDLE(HYDROData_Zone, HYDROData_Domain) -IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Zone, HYDROData_Domain) +IMPLEMENT_STANDARD_HANDLE(HYDROData_Zone, HYDROData_Entity) +IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Zone, HYDROData_Entity) + HYDROData_Zone::HYDROData_Zone() +: HYDROData_Entity() { } @@ -28,55 +28,88 @@ HYDROData_Zone::~HYDROData_Zone() QStringList HYDROData_Zone::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const { - QStringList aResList = HYDROData_Domain::DumpToPython( theTreatedObjects ); - if ( aResList.isEmpty() ) + QStringList aResList; + + Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( this ); + if ( aDocument.IsNull() ) return aResList; + QString aDocName = aDocument->GetDocPyName(); + QString aZoneName = GetName(); + + aResList << QString( "%1 = %2.CreateObject( %3 );" ) + .arg( aZoneName ).arg( aDocName ).arg( PYTHON_ZONE_ID ); + aResList << QString( "%1.SetName( \"%2\" );" ) + .arg( aZoneName ).arg( aZoneName ); aResList << QString( "" ); - Handle(HYDROData_Polyline) aRefPolyline = GetPolyline(); - setPythonReferenceObject( theTreatedObjects, aResList, aRefPolyline, "SetPolyline" ); + HYDROData_SequenceOfObjects aGeomObjects = GetGeometryObjects(); + HYDROData_SequenceOfObjects::Iterator aGeomObjsIter( aGeomObjects ); + for ( ; aGeomObjsIter.More(); aGeomObjsIter.Next() ) + { + Handle(HYDROData_Object) aRefGeomObj = + Handle(HYDROData_Object)::DownCast( aGeomObjsIter.Value() ); + if ( !aRefGeomObj.IsNull() ) + setPythonReferenceObject( theTreatedObjects, aResList, aRefGeomObj, "AddGeometryObject" ); + } + + // How can we get the shape? Mb Update() method to intersect the shapes of reference objects? + // TODO: TopoDS_Shape aRefShape = GetShape(); return aResList; } -void HYDROData_Zone::SetPolyline( const Handle(HYDROData_Polyline)& thePolyline ) +void HYDROData_Zone::SetShape( const TopoDS_Shape& theShape ) { - SetReferenceObject( thePolyline, DataTag_Polyline ); + TNaming_Builder aBuilder( myLab.FindChild( DataTag_Shape ) ); + aBuilder.Generated( theShape ); } -Handle(HYDROData_Polyline) HYDROData_Zone::GetPolyline() const +TopoDS_Shape HYDROData_Zone::GetShape() const { - return Handle(HYDROData_Polyline)::DownCast( - GetReferenceObject( DataTag_Polyline ) ); + Handle(TNaming_NamedShape) aNamedShape; + if( myLab.FindChild( DataTag_Shape ).FindAttribute( TNaming_NamedShape::GetID(), aNamedShape ) ) + return aNamedShape->Get(); + return TopoDS_Shape(); } -void HYDROData_Zone::RemovePolyline() +int HYDROData_Zone::NbGeometryObjects() const { - ClearReferenceObjects( DataTag_Polyline ); + return NbReferenceObjects( DataTag_GeometryObject ); } -TopoDS_Face HYDROData_Zone::Face() const +void HYDROData_Zone::AddGeometryObject( const Handle(HYDROData_Object)& theObject ) { - Handle(HYDROData_Polyline) aPolyline = GetPolyline(); - if( !aPolyline.IsNull() ) - { - TopoDS_Wire aWire = aPolyline->Wire(); - if( !aWire.IsNull() ) - { - BRepBuilderAPI_MakeFace aMakeFace( aWire, Standard_True ); - aMakeFace.Build(); - if( aMakeFace.IsDone() ) - return aMakeFace.Face(); - } - } - return TopoDS_Face(); + AddReferenceObject( theObject, DataTag_GeometryObject ); +} + +void HYDROData_Zone::SetGeometryObject( const int theIndex, + const Handle(HYDROData_Object)& theObject ) +{ + SetReferenceObject( theObject, DataTag_GeometryObject, theIndex ); +} + +void HYDROData_Zone::SetGeometryObjects( const HYDROData_SequenceOfObjects& theObjects ) +{ + SetReferenceObjects( theObjects, DataTag_GeometryObject ); } -QString HYDROData_Zone::getPythonKindId() const +Handle(HYDROData_Object) HYDROData_Zone::GetGeometryObject( const int theIndex ) const { - return QString( PYTHON_ZONE_ID ); + return Handle(HYDROData_Object)::DownCast( + GetReferenceObject( DataTag_GeometryObject, theIndex ) ); } +HYDROData_SequenceOfObjects HYDROData_Zone::GetGeometryObjects() const +{ + return GetReferenceObjects( DataTag_GeometryObject ); +} + +void HYDROData_Zone::RemoveGeometryObjects() +{ + ClearReferenceObjects( DataTag_GeometryObject ); +} + +