Salome HOME
Sorting alphabetically.
[modules/hydro.git] / src / HYDROData / HYDROData_Domain.cxx
1
2 #include "HYDROData_Domain.h"
3
4 #include "HYDROData_Bathymetry.h"
5 #include "HYDROData_Document.h"
6 #include "HYDROData_Iterator.h"
7
8 #include <TDataStd_IntegerArray.hxx>
9
10 #include <QColor>
11 #include <QStringList>
12
13 IMPLEMENT_STANDARD_HANDLE(HYDROData_Domain, HYDROData_Object)
14 IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Domain, HYDROData_Object)
15
16 HYDROData_Domain::HYDROData_Domain()
17 {
18 }
19
20 HYDROData_Domain::~HYDROData_Domain()
21 {
22 }
23
24 QStringList HYDROData_Domain::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const
25 {
26   QStringList aResList;
27
28   Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( this );
29   if ( aDocument.IsNull() )
30     return aResList;
31
32   QString aDocName = aDocument->GetDocPyName();
33   QString aZoneName = GetName();
34
35   aResList << QString( "%1 = %2.CreateObject( %3 );" )
36               .arg( aZoneName ).arg( aDocName ).arg( getPythonKindId() );
37   aResList << QString( "%1.SetName( \"%2\" );" )
38               .arg( aZoneName ).arg( aZoneName );
39   aResList << QString( "" );
40
41   QColor aFillingColor = GetFillingColor();
42   aResList << QString( "filling_color = QColor( %1, %2, %3, %4 );" )
43               .arg( aFillingColor.red()  ).arg( aFillingColor.green() )
44               .arg( aFillingColor.blue() ).arg( aFillingColor.alpha() );
45   aResList << QString( "%1.SetFillingColor( filling_color );" ).arg( aZoneName );
46   aResList << QString( "" );
47
48   QColor aBorderColor = GetBorderColor();
49   aResList << QString( "border_color = QColor( %1, %2, %3, %4 );" )
50               .arg( aBorderColor.red()  ).arg( aBorderColor.green() )
51               .arg( aBorderColor.blue() ).arg( aBorderColor.alpha() );
52   aResList << QString( "%1.SetBorderColor( border_color );" ).arg( aZoneName );
53   aResList << QString( "" );
54
55   HYDROData_SequenceOfObjects aZoneBaths = GetBathymetries();
56   HYDROData_SequenceOfObjects::Iterator aBathsIter( aZoneBaths );
57   for ( ; aBathsIter.More(); aBathsIter.Next() )
58   {
59     Handle(HYDROData_Bathymetry) aRefBath =
60       Handle(HYDROData_Bathymetry)::DownCast( aBathsIter.Value() );
61     if ( !aRefBath.IsNull() )
62       setPythonReferenceObject( theTreatedObjects, aResList, aRefBath, "AddBathymetry" );
63   }
64
65   return aResList;
66 }
67
68 QColor HYDROData_Domain::DefaultFillingColor()
69 {
70   return QColor( Qt::green );
71 }
72
73 void HYDROData_Domain::SetFillingColor( const QColor& theColor )
74 {
75   return SetColor( theColor, DataTag_FillingColor );
76 }
77
78 QColor HYDROData_Domain::GetFillingColor() const
79 {
80   return GetColor( DefaultFillingColor(), DataTag_FillingColor );
81 }
82
83 QColor HYDROData_Domain::DefaultBorderColor()
84 {
85   return QColor( Qt::transparent );
86 }
87
88 void HYDROData_Domain::SetBorderColor( const QColor& theColor )
89 {
90   return SetColor( theColor, DataTag_BorderColor );
91 }
92
93 QColor HYDROData_Domain::GetBorderColor() const
94 {
95   return GetColor( DefaultBorderColor(), DataTag_BorderColor );
96 }
97
98 int HYDROData_Domain::NbBathymetries() const
99 {
100   return NbReferenceObjects( DataTag_Bathymetry );
101 }
102
103 void HYDROData_Domain::AddBathymetry( const Handle(HYDROData_Bathymetry)& theBathymetry )
104 {
105   AddReferenceObject( theBathymetry, DataTag_Bathymetry );
106 }
107
108 void HYDROData_Domain::SetBathymetry( const int                           theIndex,
109                                     const Handle(HYDROData_Bathymetry)& theBathymetry )
110 {
111   SetReferenceObject( theBathymetry, DataTag_Bathymetry, theIndex );
112 }
113
114 Handle(HYDROData_Bathymetry) HYDROData_Domain::GetBathymetry( const int theIndex ) const
115 {
116   return Handle(HYDROData_Bathymetry)::DownCast( 
117            GetReferenceObject( DataTag_Bathymetry, theIndex ) );
118 }
119
120 HYDROData_SequenceOfObjects HYDROData_Domain::GetBathymetries() const
121 {
122   return GetReferenceObjects( DataTag_Bathymetry );
123 }
124
125 void HYDROData_Domain::RemoveBathymetries()
126 {
127   ClearReferenceObjects( DataTag_Bathymetry );
128 }