2 #include "HYDROData_Zone.h"
4 #include "HYDROData_Document.h"
5 #include "HYDROData_Object.h"
7 #include <TNaming_Builder.hxx>
8 #include <TNaming_NamedShape.hxx>
10 #include <TopoDS_Shape.hxx>
12 #include <QStringList>
14 #define PYTHON_ZONE_ID "KIND_ZONE"
16 IMPLEMENT_STANDARD_HANDLE(HYDROData_Zone, HYDROData_Entity)
17 IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Zone, HYDROData_Entity)
20 HYDROData_Zone::HYDROData_Zone()
25 HYDROData_Zone::~HYDROData_Zone()
29 QStringList HYDROData_Zone::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const
33 Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( this );
34 if ( aDocument.IsNull() )
37 QString aDocName = aDocument->GetDocPyName();
38 QString aZoneName = GetName();
40 aResList << QString( "%1 = %2.CreateObject( %3 );" )
41 .arg( aZoneName ).arg( aDocName ).arg( PYTHON_ZONE_ID );
42 aResList << QString( "%1.SetName( \"%2\" );" )
43 .arg( aZoneName ).arg( aZoneName );
44 aResList << QString( "" );
46 HYDROData_SequenceOfObjects aGeomObjects = GetGeometryObjects();
47 HYDROData_SequenceOfObjects::Iterator aGeomObjsIter( aGeomObjects );
48 for ( ; aGeomObjsIter.More(); aGeomObjsIter.Next() )
50 Handle(HYDROData_Object) aRefGeomObj =
51 Handle(HYDROData_Object)::DownCast( aGeomObjsIter.Value() );
52 if ( !aRefGeomObj.IsNull() )
53 setPythonReferenceObject( theTreatedObjects, aResList, aRefGeomObj, "AddGeometryObject" );
56 // How can we get the shape? Mb Update() method to intersect the shapes of reference objects?
57 // TODO: TopoDS_Shape aRefShape = GetShape();
62 void HYDROData_Zone::SetShape( const TopoDS_Shape& theShape )
64 TNaming_Builder aBuilder( myLab.FindChild( DataTag_Shape ) );
65 aBuilder.Generated( theShape );
68 TopoDS_Shape HYDROData_Zone::GetShape() const
70 Handle(TNaming_NamedShape) aNamedShape;
71 if( myLab.FindChild( DataTag_Shape ).FindAttribute( TNaming_NamedShape::GetID(), aNamedShape ) )
72 return aNamedShape->Get();
73 return TopoDS_Shape();
76 int HYDROData_Zone::NbGeometryObjects() const
78 return NbReferenceObjects( DataTag_GeometryObject );
81 void HYDROData_Zone::AddGeometryObject( const Handle(HYDROData_Object)& theObject )
83 AddReferenceObject( theObject, DataTag_GeometryObject );
86 void HYDROData_Zone::SetGeometryObject( const int theIndex,
87 const Handle(HYDROData_Object)& theObject )
89 SetReferenceObject( theObject, DataTag_GeometryObject, theIndex );
92 void HYDROData_Zone::SetGeometryObjects( const HYDROData_SequenceOfObjects& theObjects )
94 SetReferenceObjects( theObjects, DataTag_GeometryObject );
97 Handle(HYDROData_Object) HYDROData_Zone::GetGeometryObject( const int theIndex ) const
99 return Handle(HYDROData_Object)::DownCast(
100 GetReferenceObject( DataTag_GeometryObject, theIndex ) );
103 HYDROData_SequenceOfObjects HYDROData_Zone::GetGeometryObjects() const
105 return GetReferenceObjects( DataTag_GeometryObject );
108 void HYDROData_Zone::RemoveGeometryObjects()
110 ClearReferenceObjects( DataTag_GeometryObject );