Salome HOME
Common part of dump to python is moved to HYDROData_Entity.
[modules/hydro.git] / src / HYDROData / HYDROData_Obstacle.cxx
index 0a48be15c79f29510c0da3a164a361b5c7134160..370b80c7deafbc2b55ff3e69fbf417382663208b 100644 (file)
@@ -2,6 +2,8 @@
 #include "HYDROData_Obstacle.h"
 
 #include "HYDROData_Document.h"
+#include "HYDROData_ShapesGroup.h"
+#include "HYDROData_ShapesTool.h"
 
 #include <Basics_Utils.hxx>
 
 
 #include <Interface_Static.hxx>
 
+#include <TopoDS.hxx>
 #include <TopoDS_Iterator.hxx>
 #include <TopoDS_Shape.hxx>
+#include <TopoDS_Edge.hxx>
 
 #include <TDataStd_AsciiString.hxx>
 
@@ -33,8 +37,6 @@
 
 #include <HYDROData_Projection.h>
 
-#define PYTHON_OBSTACLE_ID "KIND_OBSTACLE"
-
 IMPLEMENT_STANDARD_HANDLE(HYDROData_Obstacle,HYDROData_ArtificialObject)
 IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Obstacle,HYDROData_ArtificialObject)
 
@@ -50,38 +52,39 @@ HYDROData_Obstacle::~HYDROData_Obstacle()
 
 QStringList HYDROData_Obstacle::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const
 {
-  QStringList aResList;
-
-  Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab );
-  if ( aDocument.IsNull() )
-    return aResList;
-
-  QString aDocName = aDocument->GetDocPyName();
-  QString anObstacleName = GetName();
-
-  aResList << QString( "%1 = %2.CreateObject( %3 );" )
-              .arg( anObstacleName ).arg( aDocName ).arg( PYTHON_OBSTACLE_ID );
-  aResList << QString( "%1.SetName( \"%2\" );" )
-              .arg( anObstacleName ).arg( anObstacleName );
-  aResList << QString( "" );
+  QStringList aResList = HYDROData_Entity::DumpToPython( theTreatedObjects );
 
   // TODO
 
   return aResList;
 }
 
+void HYDROData_Obstacle::Update()
+{
+  removeGroupObjects();
+  createGroupObjects();
+  checkAndSetAltitudeObject();
+
+  HYDROData_Entity::Update();
+}
+
 TopoDS_Shape HYDROData_Obstacle::GetTopShape() const
 {
-  // TODO
   return getTopShape();
 }
 
 TopoDS_Shape HYDROData_Obstacle::GetShape3D() const
 {
-  // TODO
   return getShape3D();
 }
 
+void HYDROData_Obstacle::SetShape3D( const TopoDS_Shape& theShape )
+{
+  TopoDS_Face aShape2d = HYDROData_Projection::MakeProjection( theShape );
+  HYDROData_ArtificialObject::SetShape3D( theShape );
+  HYDROData_ArtificialObject::SetTopShape( aShape2d );
+}
+
 QColor HYDROData_Obstacle::DefaultFillingColor()
 {
   return QColor( Qt::yellow );
@@ -92,16 +95,6 @@ QColor HYDROData_Obstacle::DefaultBorderColor()
   return QColor( Qt::transparent );
 }
 
-QColor HYDROData_Obstacle::getDefaultFillingColor() const
-{
-  return DefaultFillingColor();
-}
-
-QColor HYDROData_Obstacle::getDefaultBorderColor() const
-{
-  return DefaultBorderColor();
-}
-
 bool HYDROData_Obstacle::ImportFromFile( const QString& theFilePath )
 {
   // Check the file existence
@@ -332,9 +325,39 @@ TopoDS_Shape HYDROData_Obstacle::ImportSTEP( const QString& theFilePath ) const
   return aResShape;
 }
 
-void HYDROData_Obstacle::SetShape3D( const TopoDS_Shape& theShape )
+QColor HYDROData_Obstacle::getDefaultFillingColor() const
 {
-  TopoDS_Face aShape2d = HYDROData_Projection::MakeProjection( theShape );
-  HYDROData_ArtificialObject::SetShape3D( theShape );
-  HYDROData_ArtificialObject::SetTopShape( aShape2d );
+  return DefaultFillingColor();
+}
+
+QColor HYDROData_Obstacle::getDefaultBorderColor() const
+{
+  return DefaultBorderColor();
+}
+
+void HYDROData_Obstacle::createGroupObjects()
+{
+  TopoDS_Shape anObstacleShape = GetTopShape();
+  if ( !anObstacleShape.IsNull() )
+  {
+    TopTools_SequenceOfShape aWireEdges;
+    HYDROData_ShapesTool::ExploreShapeToShapes( anObstacleShape, TopAbs_EDGE, aWireEdges );
+    if ( !aWireEdges.IsEmpty() )
+    {
+      QString aWireGroupName = GetName() + "_Outer_Wire";
+
+      Handle(HYDROData_ShapesGroup) anExtWireGroup = createGroupObject();
+      anExtWireGroup->SetName( aWireGroupName );
+     
+      anExtWireGroup->SetShapes( aWireEdges );
+    }
+  }
 }
+
+ObjectKind HYDROData_Obstacle::getAltitudeObjectType() const
+{
+  return KIND_OBSTACLE_ALTITUDE;
+}
+
+
+