2 #include "HYDROData_Object.h"
4 #include "HYDROData_Bathymetry.h"
5 #include "HYDROData_DummyObject3D.h"
6 #include "HYDROData_Iterator.h"
8 #include <TNaming_Builder.hxx>
9 #include <TNaming_NamedShape.hxx>
11 #include <TopoDS_Shape.hxx>
15 IMPLEMENT_STANDARD_HANDLE(HYDROData_Object,HYDROData_Entity)
16 IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Object,HYDROData_Entity)
18 HYDROData_Object::HYDROData_Object()
23 HYDROData_Object::~HYDROData_Object()
27 HYDROData_SequenceOfObjects HYDROData_Object::GetAllReferenceObjects() const
29 HYDROData_SequenceOfObjects aResSeq = HYDROData_Entity::GetAllReferenceObjects();
31 Handle(HYDROData_Bathymetry) aRefBathymetry = GetBathymetry();
32 if ( !aRefBathymetry.IsNull() )
33 aResSeq.Append( aRefBathymetry );
38 void HYDROData_Object::SetToUpdate( bool theFlag )
40 HYDROData_Entity::SetToUpdate( theFlag );
42 Handle(HYDROData_DummyObject3D) anObject3D = GetObject3D();
43 if ( !anObject3D.IsNull() )
44 anObject3D->SetToUpdate( theFlag );
47 void HYDROData_Object::SetTopShape( const TopoDS_Shape& theShape )
49 TNaming_Builder aBuilder( myLab.FindChild( DataTag_TopShape ) );
50 aBuilder.Generated( theShape );
53 void HYDROData_Object::SetShape3D( const TopoDS_Shape& theShape )
55 TNaming_Builder aBuilder( myLab.FindChild( DataTag_Shape3D ) );
56 aBuilder.Generated( theShape );
58 // Check the object 3D existance
59 checkAndSetObject3D();
62 Handle(HYDROData_DummyObject3D) HYDROData_Object::GetObject3D() const
64 Handle(HYDROData_DummyObject3D) anObject;
66 TDF_Label aLabel = myLab.FindChild( DataTag_Object3D, false );
67 if ( !aLabel.IsNull() )
69 TDF_Label aChildLabel = aLabel.FindChild( 0, false );
70 if ( !aChildLabel.IsNull() )
72 anObject = Handle(HYDROData_DummyObject3D)::DownCast(
73 HYDROData_Iterator::Object( aChildLabel ) );
80 void HYDROData_Object::checkAndSetObject3D()
82 TDF_Label aLabel = myLab.FindChild( DataTag_Object3D, false );
83 if ( !aLabel.IsNull() )
86 TDF_Label aChildLabel = myLab.FindChild( DataTag_Object3D ).FindChild( 0 );
87 HYDROData_Iterator::CreateObject( aChildLabel, KIND_DUMMY_3D );
90 void HYDROData_Object::Update()
92 HYDROData_Entity::Update();
97 bool HYDROData_Object::SetBathymetry( const Handle(HYDROData_Bathymetry)& theBathymetry )
99 if ( theBathymetry.IsNull() )
102 Handle(HYDROData_Bathymetry) aPrevBathymetry = GetBathymetry();
103 if ( IsEqual( aPrevBathymetry, theBathymetry ) )
106 SetReferenceObject( theBathymetry, DataTag_Bathymetry );
108 // Indicate model of the need to update object
115 Handle(HYDROData_Bathymetry) HYDROData_Object::GetBathymetry() const
117 return Handle(HYDROData_Bathymetry)::DownCast(
118 GetReferenceObject( DataTag_Bathymetry ) );
121 void HYDROData_Object::RemoveBathymetry()
123 Handle(HYDROData_Bathymetry) aPrevBathymetry = GetBathymetry();
124 if ( aPrevBathymetry.IsNull() )
127 ClearReferenceObjects( DataTag_Bathymetry );
129 // Indicate model of the need to update object
133 TopoDS_Shape HYDROData_Object::getTopShape() const
135 TDF_Label aLabel = myLab.FindChild( DataTag_TopShape, false );
136 if ( !aLabel.IsNull() )
138 Handle(TNaming_NamedShape) aNamedShape;
139 if( aLabel.FindAttribute( TNaming_NamedShape::GetID(), aNamedShape ) )
140 return aNamedShape->Get();
143 return TopoDS_Shape();
146 void HYDROData_Object::removeTopShape()
148 TDF_Label aLabel = myLab.FindChild( DataTag_TopShape, false );
149 if ( !aLabel.IsNull() )
150 aLabel.ForgetAllAttributes();
153 TopoDS_Shape HYDROData_Object::getShape3D() const
155 TDF_Label aLabel = myLab.FindChild( DataTag_Shape3D, false );
156 if ( !aLabel.IsNull() )
158 Handle(TNaming_NamedShape) aNamedShape;
159 if( aLabel.FindAttribute( TNaming_NamedShape::GetID(), aNamedShape ) )
160 return aNamedShape->Get();
163 return TopoDS_Shape();
166 void HYDROData_Object::removeShape3D()
168 TDF_Label aLabel = myLab.FindChild( DataTag_Shape3D, false );
169 if ( !aLabel.IsNull() )
170 aLabel.ForgetAllAttributes();
173 void HYDROData_Object::SetFillingColor( const QColor& theColor )
175 SetColor( theColor, DataTag_FillingColor );
178 QColor HYDROData_Object::GetFillingColor() const
180 return GetColor( getDefaultFillingColor(), DataTag_FillingColor );
183 void HYDROData_Object::SetBorderColor( const QColor& theColor )
185 SetColor( theColor, DataTag_BorderColor );
188 QColor HYDROData_Object::GetBorderColor() const
190 return GetColor( getDefaultBorderColor(), DataTag_BorderColor );
193 QColor HYDROData_Object::DefaultFillingColor()
195 return QColor( Qt::yellow );
198 QColor HYDROData_Object::DefaultBorderColor()
200 return QColor( Qt::transparent );
203 QColor HYDROData_Object::getDefaultFillingColor() const
205 return DefaultFillingColor();
208 QColor HYDROData_Object::getDefaultBorderColor() const
210 return DefaultBorderColor();