2 #include "HYDROData_ImmersibleZone.h"
4 #include "HYDROData_Bathymetry.h"
5 #include "HYDROData_Document.h"
6 #include "HYDROData_Polyline.h"
8 #include <BRepBuilderAPI_MakeFace.hxx>
11 #include <TopoDS_Face.hxx>
12 #include <TopoDS_Wire.hxx>
15 #include <QStringList>
17 #define PYTHON_IMMERSIBLE_ZONE_ID "KIND_IMMERSIBLE_ZONE"
19 IMPLEMENT_STANDARD_HANDLE(HYDROData_ImmersibleZone,HYDROData_NaturalObject)
20 IMPLEMENT_STANDARD_RTTIEXT(HYDROData_ImmersibleZone,HYDROData_NaturalObject)
23 HYDROData_ImmersibleZone::HYDROData_ImmersibleZone()
24 : HYDROData_NaturalObject()
28 HYDROData_ImmersibleZone::~HYDROData_ImmersibleZone()
32 QStringList HYDROData_ImmersibleZone::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const
36 Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( this );
37 if ( aDocument.IsNull() )
40 QString aDocName = aDocument->GetDocPyName();
41 QString aZoneName = GetName();
43 aResList << QString( "%1 = %2.CreateObject( %3 );" )
44 .arg( aZoneName ).arg( aDocName ).arg( PYTHON_IMMERSIBLE_ZONE_ID );
45 aResList << QString( "%1.SetName( \"%2\" );" )
46 .arg( aZoneName ).arg( aZoneName );
47 aResList << QString( "" );
49 QColor aFillingColor = GetFillingColor();
50 aResList << QString( "filling_color = QColor( %1, %2, %3, %4 );" )
51 .arg( aFillingColor.red() ).arg( aFillingColor.green() )
52 .arg( aFillingColor.blue() ).arg( aFillingColor.alpha() );
53 aResList << QString( "%1.SetFillingColor( filling_color );" ).arg( aZoneName );
54 aResList << QString( "" );
56 QColor aBorderColor = GetBorderColor();
57 aResList << QString( "border_color = QColor( %1, %2, %3, %4 );" )
58 .arg( aBorderColor.red() ).arg( aBorderColor.green() )
59 .arg( aBorderColor.blue() ).arg( aBorderColor.alpha() );
60 aResList << QString( "%1.SetBorderColor( border_color );" ).arg( aZoneName );
61 aResList << QString( "" );
63 Handle(HYDROData_Bathymetry) aRefBathymetry = GetBathymetry();
64 setPythonReferenceObject( theTreatedObjects, aResList, aRefBathymetry, "SetBathymetry" );
66 Handle(HYDROData_Polyline) aRefPolyline = GetPolyline();
67 setPythonReferenceObject( theTreatedObjects, aResList, aRefPolyline, "SetPolyline" );
72 TopoDS_Shape HYDROData_ImmersibleZone::GetTopShape() const
74 Handle(HYDROData_Polyline) aPolyline = GetPolyline();
75 if( !aPolyline.IsNull() )
77 TopoDS_Wire aPolylineWire = TopoDS::Wire( aPolyline->GetTopShape() );
78 if( !aPolylineWire.IsNull() )
80 BRepBuilderAPI_MakeFace aMakeFace( aPolylineWire, Standard_True );
82 if( aMakeFace.IsDone() )
83 return aMakeFace.Face();
89 TopoDS_Shape HYDROData_ImmersibleZone::GetShape3D() const
95 QColor HYDROData_ImmersibleZone::DefaultFillingColor()
97 return QColor( Qt::green );
100 void HYDROData_ImmersibleZone::SetFillingColor( const QColor& theColor )
102 return SetColor( theColor, DataTag_FillingColor );
105 QColor HYDROData_ImmersibleZone::GetFillingColor() const
107 return GetColor( DefaultFillingColor(), DataTag_FillingColor );
110 QColor HYDROData_ImmersibleZone::DefaultBorderColor()
112 return QColor( Qt::transparent );
115 void HYDROData_ImmersibleZone::SetBorderColor( const QColor& theColor )
117 return SetColor( theColor, DataTag_BorderColor );
120 QColor HYDROData_ImmersibleZone::GetBorderColor() const
122 return GetColor( DefaultBorderColor(), DataTag_BorderColor );
125 void HYDROData_ImmersibleZone::SetPolyline( const Handle(HYDROData_Polyline)& thePolyline )
127 SetReferenceObject( thePolyline, DataTag_Polyline );
130 Handle(HYDROData_Polyline) HYDROData_ImmersibleZone::GetPolyline() const
132 return Handle(HYDROData_Polyline)::DownCast(
133 GetReferenceObject( DataTag_Polyline ) );
136 void HYDROData_ImmersibleZone::RemovePolyline()
138 ClearReferenceObjects( DataTag_Polyline );