From: adv Date: Tue, 17 Dec 2013 07:01:20 +0000 (+0000) Subject: Groups for obstacles implemented (Feature #242). X-Git-Tag: BR_hydro_v_0_6~77 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=a3faf294fa6a8f5483a06c7975eefb1b8c7053d9;p=modules%2Fhydro.git Groups for obstacles implemented (Feature #242). --- diff --git a/src/HYDROData/HYDROData_Obstacle.cxx b/src/HYDROData/HYDROData_Obstacle.cxx index 0a48be15..76480bd1 100644 --- a/src/HYDROData/HYDROData_Obstacle.cxx +++ b/src/HYDROData/HYDROData_Obstacle.cxx @@ -2,6 +2,7 @@ #include "HYDROData_Obstacle.h" #include "HYDROData_Document.h" +#include "HYDROData_EdgesGroup.h" #include @@ -15,8 +16,10 @@ #include +#include #include #include +#include #include @@ -70,18 +73,31 @@ QStringList HYDROData_Obstacle::DumpToPython( MapOfTreatedObjects& theTreatedObj return aResList; } +void HYDROData_Obstacle::Update() +{ + HYDROData_Entity::Update(); + + removeGroupObjects(); + createGroupObjects(); +} + 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 +108,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 +338,45 @@ 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() ) + { + HYDROData_SequenceOfEdges aWireEdges; + + TopExp_Explorer anExp( anObstacleShape, TopAbs_EDGE ); + for ( ; anExp.More(); anExp.Next() ) + { + TopoDS_Edge anEdge = TopoDS::Edge( anExp.Current() ); + if ( anEdge.IsNull() ) + continue; + + aWireEdges.Append( anEdge ); + } + + if ( !aWireEdges.IsEmpty() ) + { + QString aWireGroupName = GetName() + "_External_Wire"; + + Handle(HYDROData_EdgesGroup) anExtWireGroup = createGroupObject(); + anExtWireGroup->SetName( aWireGroupName ); + + anExtWireGroup->SetEdges( aWireEdges ); + } + } +} + + + + diff --git a/src/HYDROData/HYDROData_Obstacle.h b/src/HYDROData/HYDROData_Obstacle.h index 952a8905..39b7d584 100644 --- a/src/HYDROData/HYDROData_Obstacle.h +++ b/src/HYDROData/HYDROData_Obstacle.h @@ -36,6 +36,12 @@ public: */ HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const; + /** + * Update the immersible zone object. + * Call this method whenever you made changes for object data. + */ + HYDRODATA_EXPORT virtual void Update(); + /** * Returns the top shape of the object. */ @@ -111,6 +117,11 @@ protected: */ HYDRODATA_EXPORT virtual QColor getDefaultBorderColor() const; + /** + * Create all necessary child group objects. + */ + HYDRODATA_EXPORT virtual void createGroupObjects(); + protected: friend class HYDROData_Iterator;