#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 <TDataStd_IntegerArray.hxx>
+#include <TNaming_Builder.hxx>
+#include <TNaming_NamedShape.hxx>
+
+#include <TopoDS_Shape.hxx>
-#include <QColor>
#include <QStringList>
#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()
{
}
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 );
}
-QPainterPath HYDROData_Zone::GetPainterPath() const
+void HYDROData_Zone::AddGeometryObject( const Handle(HYDROData_Object)& theObject )
{
- QPainterPath aPath;
+ AddReferenceObject( theObject, DataTag_GeometryObject );
+}
- Handle(HYDROData_Polyline) aPolyline = GetPolyline();
- if ( !aPolyline.IsNull() )
- {
- aPath = aPolyline->painterPath();
- }
+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 );
+}
- return aPath;
+Handle(HYDROData_Object) HYDROData_Zone::GetGeometryObject( const int theIndex ) const
+{
+ return Handle(HYDROData_Object)::DownCast(
+ GetReferenceObject( DataTag_GeometryObject, theIndex ) );
}
-QString HYDROData_Zone::getPythonKindId() const
+HYDROData_SequenceOfObjects HYDROData_Zone::GetGeometryObjects() const
{
- return QString( PYTHON_ZONE_ID );
+ return GetReferenceObjects( DataTag_GeometryObject );
}
+void HYDROData_Zone::RemoveGeometryObjects()
+{
+ ClearReferenceObjects( DataTag_GeometryObject );
+}
+
+