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 void HYDROData_Object::SetBathymetry( const Handle(HYDROData_Bathymetry)& theBathymetry )
99 SetReferenceObject( theBathymetry, DataTag_Bathymetry );
103 Handle(HYDROData_Bathymetry) HYDROData_Object::GetBathymetry() const
105 return Handle(HYDROData_Bathymetry)::DownCast(
106 GetReferenceObject( DataTag_Bathymetry ) );
109 void HYDROData_Object::RemoveBathymetry()
111 ClearReferenceObjects( DataTag_Bathymetry );
115 TopoDS_Shape HYDROData_Object::getTopShape() const
117 TDF_Label aLabel = myLab.FindChild( DataTag_TopShape, false );
118 if ( !aLabel.IsNull() )
120 Handle(TNaming_NamedShape) aNamedShape;
121 if( aLabel.FindAttribute( TNaming_NamedShape::GetID(), aNamedShape ) )
122 return aNamedShape->Get();
125 return TopoDS_Shape();
128 void HYDROData_Object::removeTopShape()
130 TDF_Label aLabel = myLab.FindChild( DataTag_TopShape, false );
131 if ( !aLabel.IsNull() )
132 aLabel.ForgetAllAttributes();
135 TopoDS_Shape HYDROData_Object::getShape3D() const
137 TDF_Label aLabel = myLab.FindChild( DataTag_Shape3D, false );
138 if ( !aLabel.IsNull() )
140 Handle(TNaming_NamedShape) aNamedShape;
141 if( aLabel.FindAttribute( TNaming_NamedShape::GetID(), aNamedShape ) )
142 return aNamedShape->Get();
145 return TopoDS_Shape();
148 void HYDROData_Object::removeShape3D()
150 TDF_Label aLabel = myLab.FindChild( DataTag_Shape3D, false );
151 if ( !aLabel.IsNull() )
152 aLabel.ForgetAllAttributes();
155 void HYDROData_Object::SetFillingColor( const QColor& theColor )
157 SetColor( theColor, DataTag_FillingColor );
160 QColor HYDROData_Object::GetFillingColor() const
162 return GetColor( getDefaultFillingColor(), DataTag_FillingColor );
165 void HYDROData_Object::SetBorderColor( const QColor& theColor )
167 SetColor( theColor, DataTag_BorderColor );
170 QColor HYDROData_Object::GetBorderColor() const
172 return GetColor( getDefaultBorderColor(), DataTag_BorderColor );
175 QColor HYDROData_Object::DefaultFillingColor()
177 return QColor( Qt::yellow );
180 QColor HYDROData_Object::DefaultBorderColor()
182 return QColor( Qt::transparent );
185 QColor HYDROData_Object::getDefaultFillingColor() const
187 return DefaultFillingColor();
190 QColor HYDROData_Object::getDefaultBorderColor() const
192 return DefaultBorderColor();