1 // Copyright (C) 2014-2015 EDF-R&D
2 // This library is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU Lesser General Public
4 // License as published by the Free Software Foundation; either
5 // version 2.1 of the License, or (at your option) any later version.
7 // This library is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10 // Lesser General Public License for more details.
12 // You should have received a copy of the GNU Lesser General Public
13 // License along with this library; if not, write to the Free Software
14 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #include "HYDROData_BCPolygon.h"
21 //#include "HYDROData_IAltitudeObject.h"
22 #include "HYDROData_Document.h"
23 //#include "HYDROData_ShapesGroup.h"
24 #include "HYDROData_PolylineXY.h"
25 #include "HYDROData_ShapesTool.h"
28 #include <TopTools_ListIteratorOfListOfShape.hxx>
29 #include <TopTools_HSequenceOfShape.hxx>
30 #include <TDataStd_Integer.hxx>
32 #include <HYDROData_Tool.h>
35 #include <QStringList>
37 IMPLEMENT_STANDARD_RTTIEXT(HYDROData_BCPolygon,HYDROData_Object)
40 HYDROData_BCPolygon::HYDROData_BCPolygon()
41 : HYDROData_Object( Geom_2d )
45 HYDROData_BCPolygon::~HYDROData_BCPolygon()
49 QStringList HYDROData_BCPolygon::DumpToPython( const QString& thePyScriptPath,
50 MapOfTreatedObjects& theTreatedObjects ) const
52 QStringList aResList = dumpObjectCreation( theTreatedObjects );
54 QString aBCName = GetObjPyName();
56 Handle(HYDROData_PolylineXY) aRefPolyline = GetPolyline();
57 setPythonReferenceObject( thePyScriptPath, theTreatedObjects, aResList, aRefPolyline, "SetPolyline" );
59 int nType = GetBoundaryType();
60 aResList << QString( "%1.SetBoundaryType(%2)" ).arg(aBCName).arg(nType);
62 aResList << QString( "" );
64 aResList << QString( "%1.Update()" ).arg( aBCName );
65 aResList << QString( "" );
70 HYDROData_SequenceOfObjects HYDROData_BCPolygon::GetAllReferenceObjects() const
72 HYDROData_SequenceOfObjects aResSeq = HYDROData_Object::GetAllReferenceObjects();
74 Handle(HYDROData_PolylineXY) aRefPolyline = GetPolyline();
75 if ( !aRefPolyline.IsNull() )
76 aResSeq.Append( aRefPolyline );
81 int HYDROData_BCPolygon::GetBoundaryType() const
83 Handle(TDataStd_Integer) aBoundaryTypeAttr;
85 int aBoundaryTypeVal = 0; //default
86 if( myLab.FindAttribute(TDataStd_Integer::GetID(), aBoundaryTypeAttr ) )
87 aBoundaryTypeVal = aBoundaryTypeAttr->Get();
88 return aBoundaryTypeVal;
91 void HYDROData_BCPolygon::SetBoundaryType( int theBoundaryType ) const
93 TDataStd_Integer::Set( myLab, theBoundaryType );
96 void HYDROData_BCPolygon::Update()
98 HYDROData_Object::Update();
99 SetTopShape( generateTopShape() );
102 void HYDROData_BCPolygon::Update(const TopoDS_Shape& theTopShape)
104 HYDROData_Object::Update();
105 SetTopShape( theTopShape);
108 bool HYDROData_BCPolygon::IsHas2dPrs() const
113 TopoDS_Shape HYDROData_BCPolygon::generateTopShape() const
115 return generateTopShape( GetPolyline() );
118 TopoDS_Shape HYDROData_BCPolygon::generateTopShape( const Handle(HYDROData_PolylineXY)& aPolyline )
120 return HYDROData_Tool::PolyXY2Face(aPolyline);
123 TopoDS_Shape HYDROData_BCPolygon::GetShape3D() const
125 return GetTopShape();
128 QColor HYDROData_BCPolygon::DefaultFillingColor() const
130 int aBT = GetBoundaryType();
133 aFC = QColor( Qt::blue );
135 aFC = QColor( Qt::darkGreen );
137 aFC = QColor( Qt::darkYellow );
139 aFC = QColor( Qt::red );
144 QColor HYDROData_BCPolygon::DefaultBorderColor() const
146 return QColor( Qt::black );
149 void HYDROData_BCPolygon::SetPolyline( const Handle(HYDROData_PolylineXY)& thePolyline )
151 if( IsEqual( GetPolyline(), thePolyline ) )
154 SetReferenceObject( thePolyline, DataTag_Polyline );
158 Handle(HYDROData_PolylineXY) HYDROData_BCPolygon::GetPolyline() const
160 return Handle(HYDROData_PolylineXY)::DownCast(
161 GetReferenceObject( DataTag_Polyline ) );
164 void HYDROData_BCPolygon::RemovePolyline()
166 ClearReferenceObjects( DataTag_Polyline );