2 #include "HYDROData_Object.h"
4 #include "HYDROData_Bathymetry.h"
5 #include "HYDROData_DummyObject3D.h"
6 #include "HYDROData_ShapesGroup.h"
7 #include "HYDROData_Iterator.h"
9 #include <TNaming_Builder.hxx>
10 #include <TNaming_NamedShape.hxx>
12 #include <TopoDS_Shape.hxx>
16 IMPLEMENT_STANDARD_HANDLE(HYDROData_Object,HYDROData_Entity)
17 IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Object,HYDROData_Entity)
19 HYDROData_Object::HYDROData_Object()
24 HYDROData_Object::~HYDROData_Object()
28 void HYDROData_Object::Update()
30 HYDROData_Entity::Update();
36 HYDROData_SequenceOfObjects HYDROData_Object::GetAllReferenceObjects() const
38 HYDROData_SequenceOfObjects aResSeq = HYDROData_Entity::GetAllReferenceObjects();
40 Handle(HYDROData_Bathymetry) aRefBathymetry = GetBathymetry();
41 if ( !aRefBathymetry.IsNull() )
42 aResSeq.Append( aRefBathymetry );
47 void HYDROData_Object::SetToUpdate( bool theFlag )
49 HYDROData_Entity::SetToUpdate( theFlag );
51 Handle(HYDROData_DummyObject3D) anObject3D = GetObject3D();
52 if ( !anObject3D.IsNull() )
53 anObject3D->SetToUpdate( theFlag );
56 void HYDROData_Object::SetTopShape( const TopoDS_Shape& theShape )
58 TNaming_Builder aBuilder( myLab.FindChild( DataTag_TopShape ) );
59 aBuilder.Generated( theShape );
62 void HYDROData_Object::SetShape3D( const TopoDS_Shape& theShape )
64 TNaming_Builder aBuilder( myLab.FindChild( DataTag_Shape3D ) );
65 aBuilder.Generated( theShape );
67 // Check the object 3D existance
68 checkAndSetObject3D();
71 Handle(HYDROData_DummyObject3D) HYDROData_Object::GetObject3D() const
73 Handle(HYDROData_DummyObject3D) anObject;
75 TDF_Label aLabel = myLab.FindChild( DataTag_Object3D, false );
76 if ( !aLabel.IsNull() )
78 TDF_Label aChildLabel = aLabel.FindChild( 0, false );
79 if ( !aChildLabel.IsNull() )
81 anObject = Handle(HYDROData_DummyObject3D)::DownCast(
82 HYDROData_Iterator::Object( aChildLabel ) );
89 void HYDROData_Object::checkAndSetObject3D()
91 TDF_Label aLabel = myLab.FindChild( DataTag_Object3D, false );
92 if ( !aLabel.IsNull() )
95 TDF_Label aChildLabel = myLab.FindChild( DataTag_Object3D ).FindChild( 0 );
96 HYDROData_Iterator::CreateObject( aChildLabel, KIND_DUMMY_3D );
99 HYDROData_SequenceOfObjects HYDROData_Object::GetGroups() const
101 return GetReferenceObjects( DataTag_EdgesGroup );
104 bool HYDROData_Object::SetBathymetry( const Handle(HYDROData_Bathymetry)& theBathymetry )
106 if ( theBathymetry.IsNull() )
109 Handle(HYDROData_Bathymetry) aPrevBathymetry = GetBathymetry();
110 if ( IsEqual( aPrevBathymetry, theBathymetry ) )
113 SetReferenceObject( theBathymetry, DataTag_Bathymetry );
115 // Indicate model of the need to update object
122 Handle(HYDROData_Bathymetry) HYDROData_Object::GetBathymetry() const
124 return Handle(HYDROData_Bathymetry)::DownCast(
125 GetReferenceObject( DataTag_Bathymetry ) );
128 void HYDROData_Object::RemoveBathymetry()
130 Handle(HYDROData_Bathymetry) aPrevBathymetry = GetBathymetry();
131 if ( aPrevBathymetry.IsNull() )
134 ClearReferenceObjects( DataTag_Bathymetry );
136 // Indicate model of the need to update object
140 void HYDROData_Object::SetFillingColor( const QColor& theColor )
142 SetColor( theColor, DataTag_FillingColor );
145 QColor HYDROData_Object::GetFillingColor() const
147 return GetColor( getDefaultFillingColor(), DataTag_FillingColor );
150 void HYDROData_Object::SetBorderColor( const QColor& theColor )
152 SetColor( theColor, DataTag_BorderColor );
155 QColor HYDROData_Object::GetBorderColor() const
157 return GetColor( getDefaultBorderColor(), DataTag_BorderColor );
160 QColor HYDROData_Object::DefaultFillingColor()
162 return QColor( Qt::yellow );
165 QColor HYDROData_Object::DefaultBorderColor()
167 return QColor( Qt::transparent );
170 QColor HYDROData_Object::getDefaultFillingColor() const
172 return DefaultFillingColor();
175 QColor HYDROData_Object::getDefaultBorderColor() const
177 return DefaultBorderColor();
180 Handle(HYDROData_ShapesGroup) HYDROData_Object::createGroupObject()
182 TDF_Label aNewLab = myLab.FindChild( DataTag_EdgesGroup ).NewChild();
184 Handle(HYDROData_ShapesGroup) aNewGroup =
185 Handle(HYDROData_ShapesGroup)::DownCast( HYDROData_Iterator::CreateObject( aNewLab, KIND_SHAPES_GROUP ) );
186 AddReferenceObject( aNewGroup, DataTag_EdgesGroup );
191 void HYDROData_Object::createGroupObjects()
195 void HYDROData_Object::removeGroupObjects()
197 TDF_Label aLabel = myLab.FindChild( DataTag_EdgesGroup, false );
198 if ( !aLabel.IsNull() )
199 aLabel.ForgetAllAttributes();
202 TopoDS_Shape HYDROData_Object::getTopShape() const
204 TDF_Label aLabel = myLab.FindChild( DataTag_TopShape, false );
205 if ( !aLabel.IsNull() )
207 Handle(TNaming_NamedShape) aNamedShape;
208 if( aLabel.FindAttribute( TNaming_NamedShape::GetID(), aNamedShape ) )
209 return aNamedShape->Get();
212 return TopoDS_Shape();
215 void HYDROData_Object::removeTopShape()
217 TDF_Label aLabel = myLab.FindChild( DataTag_TopShape, false );
218 if ( !aLabel.IsNull() )
219 aLabel.ForgetAllAttributes();
222 TopoDS_Shape HYDROData_Object::getShape3D() const
224 TDF_Label aLabel = myLab.FindChild( DataTag_Shape3D, false );
225 if ( !aLabel.IsNull() )
227 Handle(TNaming_NamedShape) aNamedShape;
228 if( aLabel.FindAttribute( TNaming_NamedShape::GetID(), aNamedShape ) )
229 return aNamedShape->Get();
232 return TopoDS_Shape();
235 void HYDROData_Object::removeShape3D()
237 TDF_Label aLabel = myLab.FindChild( DataTag_Shape3D, false );
238 if ( !aLabel.IsNull() )
239 aLabel.ForgetAllAttributes();