Salome HOME
Delition of objects (Feature #90).
[modules/hydro.git] / src / HYDROData / HYDROData_Object.cxx
index 87ffb2dfbdd881d30748c7f100de859e02104ad9..e8477db6e038bdba58fe79b27ce1f76fb496d972 100644 (file)
@@ -8,6 +8,8 @@
 
 #include <TopoDS_Shape.hxx>
 
+#include <QColor>
+
 IMPLEMENT_STANDARD_HANDLE(HYDROData_Object,HYDROData_Entity)
 IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Object,HYDROData_Entity)
 
@@ -20,6 +22,17 @@ HYDROData_Object::~HYDROData_Object()
 {
 }
 
+HYDROData_SequenceOfObjects HYDROData_Object::GetAllReferenceObjects() const
+{
+  HYDROData_SequenceOfObjects aResSeq = HYDROData_Entity::GetAllReferenceObjects();
+
+  Handle(HYDROData_Bathymetry) aRefBathymetry = GetBathymetry();
+  if ( !aRefBathymetry.IsNull() )
+    aResSeq.Append( aRefBathymetry );
+
+  return aResSeq;
+}
+
 void HYDROData_Object::SetTopShape( const TopoDS_Shape& theShape )
 {
   TNaming_Builder aBuilder( myLab.FindChild( DataTag_TopShape ) );
@@ -32,6 +45,13 @@ void HYDROData_Object::SetShape3D( const TopoDS_Shape& theShape )
   aBuilder.Generated( theShape );
 }
 
+void HYDROData_Object::Update()
+{
+  removeTopShape();
+  removeShape3D();
+  SetToUpdate( false );
+}
+
 void HYDROData_Object::SetBathymetry( const Handle(HYDROData_Bathymetry)& theBathymetry )
 {
   SetReferenceObject( theBathymetry, DataTag_Bathymetry );
@@ -50,17 +70,70 @@ void HYDROData_Object::RemoveBathymetry()
 
 TopoDS_Shape HYDROData_Object::getTopShape() const
 {
-  Handle(TNaming_NamedShape) aNamedShape;
-  if( myLab.FindChild( DataTag_TopShape ).FindAttribute( TNaming_NamedShape::GetID(), aNamedShape ) )
-    return aNamedShape->Get();
+  TDF_Label aLabel = myLab.FindChild( DataTag_TopShape, false );
+  if ( !aLabel.IsNull() )
+  {
+    Handle(TNaming_NamedShape) aNamedShape;
+    if( aLabel.FindAttribute( TNaming_NamedShape::GetID(), aNamedShape ) )
+      return aNamedShape->Get();
+  }
+
   return TopoDS_Shape();
 }
 
+void HYDROData_Object::removeTopShape()
+{
+  TDF_Label aLabel = myLab.FindChild( DataTag_TopShape, false );
+  if ( !aLabel.IsNull() )
+    aLabel.ForgetAllAttributes();
+}
+
 TopoDS_Shape HYDROData_Object::getShape3D() const
 {
-  Handle(TNaming_NamedShape) aNamedShape;
-  if( myLab.FindChild( DataTag_Shape3D ).FindAttribute( TNaming_NamedShape::GetID(), aNamedShape ) )
-    return aNamedShape->Get();
+  TDF_Label aLabel = myLab.FindChild( DataTag_Shape3D, false );
+  if ( !aLabel.IsNull() )
+  {
+    Handle(TNaming_NamedShape) aNamedShape;
+    if( aLabel.FindAttribute( TNaming_NamedShape::GetID(), aNamedShape ) )
+      return aNamedShape->Get();
+  }
+
   return TopoDS_Shape();
 }
 
+void HYDROData_Object::removeShape3D()
+{
+  TDF_Label aLabel = myLab.FindChild( DataTag_Shape3D, false );
+  if ( !aLabel.IsNull() )
+    aLabel.ForgetAllAttributes();
+}
+
+void HYDROData_Object::SetFillingColor( const QColor& theColor )
+{
+  return SetColor( theColor, DataTag_FillingColor );
+}
+
+QColor HYDROData_Object::GetFillingColor() const
+{
+  return GetColor( DefaultFillingColor(), DataTag_FillingColor );
+}
+
+void HYDROData_Object::SetBorderColor( const QColor& theColor )
+{
+  return SetColor( theColor, DataTag_BorderColor );
+}
+
+QColor HYDROData_Object::GetBorderColor() const
+{
+  return GetColor( DefaultBorderColor(), DataTag_BorderColor );
+}
+
+QColor HYDROData_Object::DefaultFillingColor()
+{
+  return QColor( Qt::yellow );
+}
+
+QColor HYDROData_Object::DefaultBorderColor()
+{
+  return QColor( Qt::transparent );
+}
\ No newline at end of file