Salome HOME
f8c514b3a86f9a7690bb0896154d0347e0ebe6f9
[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 void HYDROData_Object::SetTopShape( const TopoDS_Shape& theShape )
26 {
27   TNaming_Builder aBuilder( myLab.FindChild( DataTag_TopShape ) );
28   aBuilder.Generated( theShape );
29 }
30
31 void HYDROData_Object::SetShape3D( const TopoDS_Shape& theShape )
32 {
33   TNaming_Builder aBuilder( myLab.FindChild( DataTag_Shape3D ) );
34   aBuilder.Generated( theShape );
35 }
36
37 void HYDROData_Object::Update()
38 {
39   removeTopShape();
40   removeShape3D();
41   SetToUpdate( false );
42 }
43
44 void HYDROData_Object::SetBathymetry( const Handle(HYDROData_Bathymetry)& theBathymetry )
45 {
46   SetReferenceObject( theBathymetry, DataTag_Bathymetry );
47 }
48
49 Handle(HYDROData_Bathymetry) HYDROData_Object::GetBathymetry() const
50 {
51   return Handle(HYDROData_Bathymetry)::DownCast( 
52            GetReferenceObject( DataTag_Bathymetry ) );
53 }
54
55 void HYDROData_Object::RemoveBathymetry()
56 {
57   ClearReferenceObjects( DataTag_Bathymetry );
58 }
59
60 TopoDS_Shape HYDROData_Object::getTopShape() const
61 {
62   TDF_Label aLabel = myLab.FindChild( DataTag_TopShape, false );
63   if ( !aLabel.IsNull() )
64   {
65     Handle(TNaming_NamedShape) aNamedShape;
66     if( aLabel.FindAttribute( TNaming_NamedShape::GetID(), aNamedShape ) )
67       return aNamedShape->Get();
68   }
69
70   return TopoDS_Shape();
71 }
72
73 void HYDROData_Object::removeTopShape()
74 {
75   TDF_Label aLabel = myLab.FindChild( DataTag_TopShape, false );
76   if ( !aLabel.IsNull() )
77     aLabel.ForgetAllAttributes();
78 }
79
80 TopoDS_Shape HYDROData_Object::getShape3D() const
81 {
82   TDF_Label aLabel = myLab.FindChild( DataTag_Shape3D, false );
83   if ( !aLabel.IsNull() )
84   {
85     Handle(TNaming_NamedShape) aNamedShape;
86     if( aLabel.FindAttribute( TNaming_NamedShape::GetID(), aNamedShape ) )
87       return aNamedShape->Get();
88   }
89
90   return TopoDS_Shape();
91 }
92
93 void HYDROData_Object::removeShape3D()
94 {
95   TDF_Label aLabel = myLab.FindChild( DataTag_Shape3D, false );
96   if ( !aLabel.IsNull() )
97     aLabel.ForgetAllAttributes();
98 }
99
100 void HYDROData_Object::SetFillingColor( const QColor& theColor )
101 {
102   return SetColor( theColor, DataTag_FillingColor );
103 }
104
105 QColor HYDROData_Object::GetFillingColor() const
106 {
107   return GetColor( DefaultFillingColor(), DataTag_FillingColor );
108 }
109
110 void HYDROData_Object::SetBorderColor( const QColor& theColor )
111 {
112   return SetColor( theColor, DataTag_BorderColor );
113 }
114
115 QColor HYDROData_Object::GetBorderColor() const
116 {
117   return GetColor( DefaultBorderColor(), DataTag_BorderColor );
118 }
119
120 QColor HYDROData_Object::DefaultFillingColor()
121 {
122   return QColor( Qt::yellow );
123 }
124
125 QColor HYDROData_Object::DefaultBorderColor()
126 {
127   return QColor( Qt::transparent );
128 }