Salome HOME
refs #636: flags for geometry 2d/3d change
[modules/hydro.git] / src / HYDROData / HYDROData_Object.cxx
index 81cbe38ac4198022ae9a658d7cd9e76c4ca44184..fff074adebd0d85ed9f4dbb78b5ae42b49b1de85 100644 (file)
@@ -1,8 +1,4 @@
-// Copyright (C) 2007-2015  CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
+// Copyright (C) 2014-2015  EDF-R&D
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 // License as published by the Free Software Foundation; either
 #include <TNaming_NamedShape.hxx>
 
 #include <TopoDS_Shape.hxx>
+#include <TDataStd_Integer.hxx>
 
 #include <QColor>
 
 IMPLEMENT_STANDARD_HANDLE(HYDROData_Object,HYDROData_Entity)
 IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Object,HYDROData_Entity)
 
-HYDROData_Object::HYDROData_Object()
-: HYDROData_Entity()
+HYDROData_Object::HYDROData_Object( Geometry theGeometry )
+  : HYDROData_Entity( theGeometry )
 {
 }
 
@@ -78,9 +75,14 @@ void HYDROData_Object::SetName( const QString& theName )
 
 void HYDROData_Object::Update()
 {
-  removeTopShape();
-  removeShape3D();
-  removeGroupObjects();
+  if( IsMustBeUpdated2d() )
+  {
+    removeTopShape();
+    removeGroupObjects();
+  }
+  if( IsMustBeUpdated3d() )
+    removeShape3D();
+
   checkAndSetAltitudeObject();
   HYDROData_Entity::Update();
 }
@@ -96,13 +98,13 @@ HYDROData_SequenceOfObjects HYDROData_Object::GetAllReferenceObjects() const
   return aResSeq;
 }
 
-void HYDROData_Object::SetToUpdate( bool theFlag )
+void HYDROData_Object::Changed( Geometry theChangedGeometry )
 {
-  HYDROData_Entity::SetToUpdate( theFlag );
+  HYDROData_Entity::Changed( theChangedGeometry );
 
   Handle(HYDROData_DummyObject3D) anObject3D = GetObject3D();
   if ( !anObject3D.IsNull() )
-    anObject3D->SetToUpdate( theFlag );
+    anObject3D->Changed( theChangedGeometry );
 }
 
 void HYDROData_Object::SetTopShape( const TopoDS_Shape& theShape )
@@ -197,8 +199,9 @@ bool HYDROData_Object::SetAltitudeObject(
 
   SetReferenceObject( theAltitude, DataTag_AltitudeObject );
 
-  // Indicate model of the need to update object
-  SetToUpdate( true );
+  // #636: In the case of the altitude object change the geometry of the main object is not changed,
+  // to the object should not be marked as updated
+  //SetToUpdate( true );
 
   return true;
 }
@@ -217,8 +220,9 @@ void HYDROData_Object::RemoveAltitudeObject()
 
   ClearReferenceObjects( DataTag_AltitudeObject );
 
-  // Indicate model of the need to update object
-  SetToUpdate( true );
+  // #636: In the case of the altitude object change the geometry of the main object is not changed,
+  // to the object should not be marked as updated
+  //SetToUpdate( true );
 }
 
 void HYDROData_Object::SetFillingColor( const QColor& theColor )
@@ -380,3 +384,20 @@ void HYDROData_Object::removeShape3D()
     aLabel.ForgetAllAttributes();
 }
 
+bool HYDROData_Object::IsSubmersible() const
+{
+  Handle(TDataStd_Integer) aSubMersibleAttr;
+
+  bool isSubmersible = true; //default
+  if( myLab.FindAttribute(TDataStd_Integer::GetID(), aSubMersibleAttr ) )
+  {
+    int aValue = aSubMersibleAttr->Get();
+    isSubmersible = ( aValue != 0 );
+  }
+  return isSubmersible;
+}
+
+void HYDROData_Object::SetIsSubmersible( bool isSubmersible ) const
+{
+  TDataStd_Integer::Set( myLab, isSubmersible ? 1 : 0 );
+}