Salome HOME
patch for correct compilation on Linux
[modules/hydro.git] / src / HYDROData / HYDROData_Object.cxx
1
2 #include "HYDROData_Object.h"
3
4 #include "HYDROData_Bathymetry.h"
5
6 #include <TNaming_Builder.hxx>
7 #include <TNaming_NamedShape.hxx>
8
9 #include <TopoDS_Shape.hxx>
10
11 #include <QColor>
12
13 IMPLEMENT_STANDARD_HANDLE(HYDROData_Object,HYDROData_Entity)
14 IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Object,HYDROData_Entity)
15
16 HYDROData_Object::HYDROData_Object()
17 : HYDROData_Entity()
18 {
19 }
20
21 HYDROData_Object::~HYDROData_Object()
22 {
23 }
24
25 HYDROData_SequenceOfObjects HYDROData_Object::GetAllReferenceObjects() const
26 {
27   HYDROData_SequenceOfObjects aResSeq = HYDROData_Entity::GetAllReferenceObjects();
28
29   Handle(HYDROData_Bathymetry) aRefBathymetry = GetBathymetry();
30   if ( !aRefBathymetry.IsNull() )
31     aResSeq.Append( aRefBathymetry );
32
33   return aResSeq;
34 }
35
36 void HYDROData_Object::SetTopShape( const TopoDS_Shape& theShape )
37 {
38   TNaming_Builder aBuilder( myLab.FindChild( DataTag_TopShape ) );
39   aBuilder.Generated( theShape );
40 }
41
42 void HYDROData_Object::SetShape3D( const TopoDS_Shape& theShape )
43 {
44   TNaming_Builder aBuilder( myLab.FindChild( DataTag_Shape3D ) );
45   aBuilder.Generated( theShape );
46 }
47
48 void HYDROData_Object::Update()
49 {
50   removeTopShape();
51   removeShape3D();
52   SetToUpdate( false );
53 }
54
55 void HYDROData_Object::SetBathymetry( const Handle(HYDROData_Bathymetry)& theBathymetry )
56 {
57   SetReferenceObject( theBathymetry, DataTag_Bathymetry );
58 }
59
60 Handle(HYDROData_Bathymetry) HYDROData_Object::GetBathymetry() const
61 {
62   return Handle(HYDROData_Bathymetry)::DownCast( 
63            GetReferenceObject( DataTag_Bathymetry ) );
64 }
65
66 void HYDROData_Object::RemoveBathymetry()
67 {
68   ClearReferenceObjects( DataTag_Bathymetry );
69 }
70
71 TopoDS_Shape HYDROData_Object::getTopShape() const
72 {
73   TDF_Label aLabel = myLab.FindChild( DataTag_TopShape, false );
74   if ( !aLabel.IsNull() )
75   {
76     Handle(TNaming_NamedShape) aNamedShape;
77     if( aLabel.FindAttribute( TNaming_NamedShape::GetID(), aNamedShape ) )
78       return aNamedShape->Get();
79   }
80
81   return TopoDS_Shape();
82 }
83
84 void HYDROData_Object::removeTopShape()
85 {
86   TDF_Label aLabel = myLab.FindChild( DataTag_TopShape, false );
87   if ( !aLabel.IsNull() )
88     aLabel.ForgetAllAttributes();
89 }
90
91 TopoDS_Shape HYDROData_Object::getShape3D() const
92 {
93   TDF_Label aLabel = myLab.FindChild( DataTag_Shape3D, false );
94   if ( !aLabel.IsNull() )
95   {
96     Handle(TNaming_NamedShape) aNamedShape;
97     if( aLabel.FindAttribute( TNaming_NamedShape::GetID(), aNamedShape ) )
98       return aNamedShape->Get();
99   }
100
101   return TopoDS_Shape();
102 }
103
104 void HYDROData_Object::removeShape3D()
105 {
106   TDF_Label aLabel = myLab.FindChild( DataTag_Shape3D, false );
107   if ( !aLabel.IsNull() )
108     aLabel.ForgetAllAttributes();
109 }
110
111 void HYDROData_Object::SetFillingColor( const QColor& theColor )
112 {
113   return SetColor( theColor, DataTag_FillingColor );
114 }
115
116 QColor HYDROData_Object::GetFillingColor() const
117 {
118   return GetColor( DefaultFillingColor(), DataTag_FillingColor );
119 }
120
121 void HYDROData_Object::SetBorderColor( const QColor& theColor )
122 {
123   return SetColor( theColor, DataTag_BorderColor );
124 }
125
126 QColor HYDROData_Object::GetBorderColor() const
127 {
128   return GetColor( DefaultBorderColor(), DataTag_BorderColor );
129 }
130
131 QColor HYDROData_Object::DefaultFillingColor()
132 {
133   return QColor( Qt::yellow );
134 }
135
136 QColor HYDROData_Object::DefaultBorderColor()
137 {
138   return QColor( Qt::transparent );
139 }