2 #include "HYDROData_Zone.h"
4 #include "HYDROData_Bathymetry.h"
5 #include "HYDROData_Document.h"
6 #include "HYDROData_Polyline.h"
7 #include "HYDROData_Iterator.h"
9 #include <TDataStd_IntegerArray.hxx>
12 #include <QStringList>
14 #define PYTHON_ZONE_ID "KIND_ZONE"
16 IMPLEMENT_STANDARD_HANDLE(HYDROData_Zone, HYDROData_Object)
17 IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Zone, HYDROData_Object)
19 HYDROData_Zone::HYDROData_Zone()
23 HYDROData_Zone::~HYDROData_Zone()
27 QStringList HYDROData_Zone::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const
31 Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( this );
32 if ( aDocument.IsNull() )
35 QString aDocName = aDocument->GetDocPyName();
36 QString aZoneName = GetName();
38 aResList << QString( "%1 = %2.CreateObject( %3 );" )
39 .arg( aZoneName ).arg( aDocName ).arg( PYTHON_ZONE_ID );
40 aResList << QString( "%1.SetName( \"%2\" );" )
41 .arg( aZoneName ).arg( aZoneName );
42 aResList << QString( "" );
44 QColor aFillingColor = GetFillingColor();
45 aResList << QString( "filling_color = QColor( %1, %2, %3, %4 );" )
46 .arg( aFillingColor.red() ).arg( aFillingColor.green() )
47 .arg( aFillingColor.blue() ).arg( aFillingColor.alpha() );
48 aResList << QString( "%1.SetFillingColor( filling_color );" ).arg( aZoneName );
49 aResList << QString( "" );
51 QColor aBorderColor = GetBorderColor();
52 aResList << QString( "border_color = QColor( %1, %2, %3, %4 );" )
53 .arg( aBorderColor.red() ).arg( aBorderColor.green() )
54 .arg( aBorderColor.blue() ).arg( aBorderColor.alpha() );
55 aResList << QString( "%1.SetBorderColor( border_color );" ).arg( aZoneName );
56 aResList << QString( "" );
58 Handle(HYDROData_Polyline) aRefPolyline = GetPolyline();
59 setPythonReferenceObject( theTreatedObjects, aResList, aRefPolyline, "SetPolyline" );
60 aResList << QString( "" );
62 HYDROData_SequenceOfObjects aZoneBaths = GetBathymetries();
63 HYDROData_SequenceOfObjects::Iterator aBathsIter( aZoneBaths );
64 for ( ; aBathsIter.More(); aBathsIter.Next() )
66 Handle(HYDROData_Bathymetry) aRefBath =
67 Handle(HYDROData_Bathymetry)::DownCast( aBathsIter.Value() );
68 if ( !aRefBath.IsNull() )
69 setPythonReferenceObject( theTreatedObjects, aResList, aRefBath, "AddBathymetry" );
75 QColor HYDROData_Zone::DefaultFillingColor()
77 return QColor( Qt::green );
80 void HYDROData_Zone::SetFillingColor( const QColor& theColor )
82 return SetColor( theColor, DataTag_FillingColor );
85 QColor HYDROData_Zone::GetFillingColor() const
87 return GetColor( DefaultFillingColor(), DataTag_FillingColor );
90 QColor HYDROData_Zone::DefaultBorderColor()
92 return QColor( Qt::transparent );
95 void HYDROData_Zone::SetBorderColor( const QColor& theColor )
97 return SetColor( theColor, DataTag_BorderColor );
100 QColor HYDROData_Zone::GetBorderColor() const
102 return GetColor( DefaultBorderColor(), DataTag_BorderColor );
105 void HYDROData_Zone::SetPolyline( const Handle(HYDROData_Polyline)& thePolyline )
107 SetReferenceObject( thePolyline, DataTag_Polyline );
110 Handle(HYDROData_Polyline) HYDROData_Zone::GetPolyline() const
112 return Handle(HYDROData_Polyline)::DownCast(
113 GetReferenceObject( DataTag_Polyline ) );
116 void HYDROData_Zone::RemovePolyline()
118 ClearReferenceObjects( DataTag_Polyline );
121 int HYDROData_Zone::NbBathymetries() const
123 return NbReferenceObjects( DataTag_Bathymetry );
126 void HYDROData_Zone::AddBathymetry( const Handle(HYDROData_Bathymetry)& theBathymetry )
128 AddReferenceObject( theBathymetry, DataTag_Bathymetry );
131 void HYDROData_Zone::SetBathymetry( const int theIndex,
132 const Handle(HYDROData_Bathymetry)& theBathymetry )
134 SetReferenceObject( theBathymetry, DataTag_Bathymetry, theIndex );
137 Handle(HYDROData_Bathymetry) HYDROData_Zone::GetBathymetry( const int theIndex ) const
139 return Handle(HYDROData_Bathymetry)::DownCast(
140 GetReferenceObject( DataTag_Bathymetry, theIndex ) );
143 HYDROData_SequenceOfObjects HYDROData_Zone::GetBathymetries() const
145 return GetReferenceObjects( DataTag_Bathymetry );
148 void HYDROData_Zone::RemoveBathymetries()
150 ClearReferenceObjects( DataTag_Bathymetry );
153 QPainterPath HYDROData_Zone::GetPainterPath() const
157 Handle(HYDROData_Polyline) aPolyline = GetPolyline();
158 if ( !aPolyline.IsNull() )
160 aPath = aPolyline->painterPath();