]> SALOME platform Git repositories - modules/hydro.git/blob - src/HYDROData/HYDROData_Zone.cxx
Salome HOME
Base implementation of Zone data object (Feature #31).
[modules/hydro.git] / src / HYDROData / HYDROData_Zone.cxx
1
2 #include "HYDROData_Zone.h"
3
4 #include "HYDROData_Bathymetry.h"
5 #include "HYDROData_Document.h"
6 #include "HYDROData_Polyline.h"
7 #include "HYDROData_Iterator.h"
8
9 #include <TDataStd_IntegerArray.hxx>
10
11 #include <QColor>
12 #include <QStringList>
13
14 #define PYTHON_POLYLINE_ID "KIND_ZONE"
15
16 IMPLEMENT_STANDARD_HANDLE(HYDROData_Zone, HYDROData_Object)
17 IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Zone, HYDROData_Object)
18
19 HYDROData_Zone::HYDROData_Zone()
20 {
21 }
22
23 HYDROData_Zone::~HYDROData_Zone()
24 {
25 }
26
27 QStringList HYDROData_Zone::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const
28 {
29   QStringList aResList;
30
31   Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( this );
32   if ( aDocument.IsNull() )
33     return aResList;
34
35   return aResList;
36 }
37
38 void HYDROData_Zone::SetColor( const QColor& theColor )
39 {
40   Handle(TDataStd_IntegerArray) aColorArray;
41   if ( !myLab.FindChild( DataTag_Color ).FindAttribute( TDataStd_IntegerArray::GetID(), aColorArray ) )
42     aColorArray = TDataStd_IntegerArray::Set( myLab.FindChild( DataTag_Color ), 1, 4 );
43
44   aColorArray->SetValue( 1, theColor.red()   );
45   aColorArray->SetValue( 2, theColor.green() );
46   aColorArray->SetValue( 3, theColor.blue()  );
47   aColorArray->SetValue( 4, theColor.alpha() );
48 }
49
50 QColor HYDROData_Zone::GetColor() const
51 {
52   QColor aResColor( Qt::green );
53
54   Handle(TDataStd_IntegerArray) aColorArray;
55   if ( myLab.FindChild( DataTag_Color ).FindAttribute( TDataStd_IntegerArray::GetID(), aColorArray ) )
56   {
57     aResColor.setRed(   aColorArray->Value( 1 ) );
58     aResColor.setGreen( aColorArray->Value( 2 ) );
59     aResColor.setBlue(  aColorArray->Value( 3 ) );
60     aResColor.setAlpha( aColorArray->Value( 4 ) );
61   }
62
63   return aResColor;
64 }
65
66 void HYDROData_Zone::SetPolyline( const Handle(HYDROData_Polyline)& thePolyline )
67 {
68   SetReferenceObject( thePolyline, DataTag_Polyline );
69 }
70
71 Handle(HYDROData_Polyline) HYDROData_Zone::GetPolyline() const
72 {
73   return Handle(HYDROData_Polyline)::DownCast( 
74            GetReferenceObject( DataTag_Polyline ) );
75 }
76
77 void HYDROData_Zone::RemovePolyline()
78 {
79   ClearReferenceObjects( DataTag_Polyline );
80 }
81
82 int HYDROData_Zone::NbBathymetries() const
83 {
84   return NbReferenceObjects( DataTag_Bathymetry );
85 }
86
87 void HYDROData_Zone::AddBathymetry( const Handle(HYDROData_Bathymetry)& theBathymetry )
88 {
89   AddReferenceObject( theBathymetry, DataTag_Bathymetry );
90 }
91
92 void HYDROData_Zone::SetBathymetry( const int                           theIndex,
93                                     const Handle(HYDROData_Bathymetry)& theBathymetry )
94 {
95   SetReferenceObject( theBathymetry, DataTag_Bathymetry, theIndex );
96 }
97
98 Handle(HYDROData_Bathymetry) HYDROData_Zone::GetBathymetry( const int theIndex ) const
99 {
100   return Handle(HYDROData_Bathymetry)::DownCast( 
101            GetReferenceObject( DataTag_Bathymetry, theIndex ) );
102 }
103
104 HYDROData_SequenceOfObjects HYDROData_Zone::GetBathymetries() const
105 {
106   return GetReferenceObjects( DataTag_Bathymetry );
107 }
108
109 void HYDROData_Zone::RemoveBathymetries()
110 {
111   ClearReferenceObjects( DataTag_Bathymetry );
112 }
113
114 QPainterPath HYDROData_Zone::GetPainterPath() const
115 {
116   QPainterPath aPath;
117
118   Handle(HYDROData_Polyline) aPolyline = GetPolyline();
119   if ( !aPolyline.IsNull() )
120   {
121     aPath = aPolyline->painterPath();
122   }
123
124   return aPath;
125 }
126