#include "HYDROData_Channel.h"
#include "HYDROData_Document.h"
+#include "HYDROData_Polyline3D.h"
+#include "HYDROData_Profile.h"
-#include <TopoDS_Shape.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Wire.hxx>
#include <QStringList>
TopoDS_Shape HYDROData_Channel::GetTopShape() const
{
- // TODO
return getTopShape();
}
TopoDS_Shape HYDROData_Channel::GetShape3D() const
{
- // TODO
return getShape3D();
}
+void HYDROData_Channel::Update()
+{
+ removeTopShape();
+ removeShape3D();
+ SetToUpdate( false );
+
+ Handle(HYDROData_Polyline3D) aGuideLine = GetGuideLine();
+ Handle(HYDROData_Profile) aProfile = GetProfile();
+ if ( aGuideLine.IsNull() || aProfile.IsNull() )
+ return;
+
+ // TODO
+}
+
+bool HYDROData_Channel::SetGuideLine( const Handle(HYDROData_Polyline3D)& theGuideLine )
+{
+ if ( theGuideLine.IsNull() )
+ return false;
+
+ TopoDS_Wire aHydraulicWire = TopoDS::Wire( theGuideLine->GetTopShape() );
+ if ( aHydraulicWire.IsNull() )
+ return false; // The polyline must be a single wire
+
+ Handle(HYDROData_Polyline3D) aPrevGuideLine = GetGuideLine();
+ if ( IsEqual( aPrevGuideLine, theGuideLine ) )
+ return true;
+
+ SetReferenceObject( theGuideLine, DataTag_GuideLine );
+
+ // Indicate model of the need to update the chanel presentation
+ SetToUpdate( true );
+
+ return true;
+}
+
+Handle(HYDROData_Polyline3D) HYDROData_Channel::GetGuideLine() const
+{
+ return Handle(HYDROData_Polyline3D)::DownCast(
+ GetReferenceObject( DataTag_GuideLine ) );
+}
+
+void HYDROData_Channel::RemoveGuideLine()
+{
+ Handle(HYDROData_Polyline3D) aPrevGuideLine = GetGuideLine();
+ if ( aPrevGuideLine.IsNull() )
+ return;
+ ClearReferenceObjects( DataTag_GuideLine );
+ // Indicate model of the need to update the chanel presentation
+ SetToUpdate( true );
+}
+
+bool HYDROData_Channel::SetProfile( const Handle(HYDROData_Profile)& theProfile )
+{
+ if ( theProfile.IsNull() )
+ return false;
+
+ Handle(HYDROData_Profile) aPrevProfile = GetProfile();
+ if ( IsEqual( aPrevProfile, theProfile ) )
+ return true;
+
+ SetReferenceObject( theProfile, DataTag_Profile );
+
+ // Indicate model of the need to update the chanel presentation
+ SetToUpdate( true );
+
+ return true;
+}
+
+Handle(HYDROData_Profile) HYDROData_Channel::GetProfile() const
+{
+ return Handle(HYDROData_Profile)::DownCast(
+ GetReferenceObject( DataTag_Profile ) );
+}
+
+void HYDROData_Channel::RemoveProfile()
+{
+ Handle(HYDROData_Profile) aPrevProfile = GetProfile();
+ if ( aPrevProfile.IsNull() )
+ return;
+
+ ClearReferenceObjects( DataTag_Profile );
+
+ // Indicate model of the need to update the chanel presentation
+ SetToUpdate( true );
+}