2 #include "HYDROData_Channel.h"
4 #include "HYDROData_Document.h"
5 #include "HYDROData_Polyline3D.h"
6 #include "HYDROData_Profile.h"
9 #include <TopoDS_Wire.hxx>
11 #include <QStringList>
13 #define PYTHON_CHANNEL_ID "KIND_CHANNEL"
15 IMPLEMENT_STANDARD_HANDLE(HYDROData_Channel,HYDROData_ArtificialObject)
16 IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Channel,HYDROData_ArtificialObject)
19 HYDROData_Channel::HYDROData_Channel()
20 : HYDROData_ArtificialObject()
24 HYDROData_Channel::~HYDROData_Channel()
28 QStringList HYDROData_Channel::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const
32 Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab );
33 if ( aDocument.IsNull() )
36 QString aDocName = aDocument->GetDocPyName();
37 QString aChannelName = GetName();
39 aResList << QString( "%1 = %2.CreateObject( %3 );" )
40 .arg( aChannelName ).arg( aDocName ).arg( PYTHON_CHANNEL_ID );
41 aResList << QString( "%1.SetName( \"%2\" );" )
42 .arg( aChannelName ).arg( aChannelName );
43 aResList << QString( "" );
50 TopoDS_Shape HYDROData_Channel::GetTopShape() const
55 TopoDS_Shape HYDROData_Channel::GetShape3D() const
60 void HYDROData_Channel::Update()
62 HYDROData_ArtificialObject::Update();
64 Handle(HYDROData_Polyline3D) aGuideLine = GetGuideLine();
65 Handle(HYDROData_Profile) aProfile = GetProfile();
66 if ( aGuideLine.IsNull() || aProfile.IsNull() )
72 bool HYDROData_Channel::SetGuideLine( const Handle(HYDROData_Polyline3D)& theGuideLine )
74 Handle(HYDROData_Polyline3D) aPrevGuideLine = GetGuideLine();
76 if ( theGuideLine.IsNull() )
79 return !aPrevGuideLine.IsNull();
82 if ( IsEqual( aPrevGuideLine, theGuideLine ) )
85 TopoDS_Wire aHydraulicWire = TopoDS::Wire( theGuideLine->GetTopShape() );
86 if ( aHydraulicWire.IsNull() )
87 return false; // The polyline must be a single wire
89 SetReferenceObject( theGuideLine, DataTag_GuideLine );
91 // Indicate model of the need to update the chanel presentation
97 Handle(HYDROData_Polyline3D) HYDROData_Channel::GetGuideLine() const
99 return Handle(HYDROData_Polyline3D)::DownCast(
100 GetReferenceObject( DataTag_GuideLine ) );
103 void HYDROData_Channel::RemoveGuideLine()
105 Handle(HYDROData_Polyline3D) aPrevGuideLine = GetGuideLine();
106 if ( aPrevGuideLine.IsNull() )
109 ClearReferenceObjects( DataTag_GuideLine );
111 // Indicate model of the need to update the chanel presentation
115 bool HYDROData_Channel::SetProfile( const Handle(HYDROData_Profile)& theProfile )
117 Handle(HYDROData_Profile) aPrevProfile = GetProfile();
119 if ( theProfile.IsNull() )
122 return !aPrevProfile.IsNull();
125 if ( IsEqual( aPrevProfile, theProfile ) )
128 SetReferenceObject( theProfile, DataTag_Profile );
130 // Indicate model of the need to update the chanel presentation
136 Handle(HYDROData_Profile) HYDROData_Channel::GetProfile() const
138 return Handle(HYDROData_Profile)::DownCast(
139 GetReferenceObject( DataTag_Profile ) );
142 void HYDROData_Channel::RemoveProfile()
144 Handle(HYDROData_Profile) aPrevProfile = GetProfile();
145 if ( aPrevProfile.IsNull() )
148 ClearReferenceObjects( DataTag_Profile );
150 // Indicate model of the need to update the chanel presentation