From 43202d78bedfc132df783346843174f5363937d2 Mon Sep 17 00:00:00 2001 From: adv Date: Fri, 29 Nov 2013 07:27:00 +0000 Subject: [PATCH] Reference objetcs are added for chanel. --- src/HYDROData/HYDROData_Channel.cxx | 92 ++++++++++++++++++++++++++++- src/HYDROData/HYDROData_Channel.h | 47 +++++++++++++++ 2 files changed, 136 insertions(+), 3 deletions(-) diff --git a/src/HYDROData/HYDROData_Channel.cxx b/src/HYDROData/HYDROData_Channel.cxx index b365008a..9ad19c97 100644 --- a/src/HYDROData/HYDROData_Channel.cxx +++ b/src/HYDROData/HYDROData_Channel.cxx @@ -2,8 +2,11 @@ #include "HYDROData_Channel.h" #include "HYDROData_Document.h" +#include "HYDROData_Polyline3D.h" +#include "HYDROData_Profile.h" -#include +#include +#include #include @@ -46,15 +49,98 @@ QStringList HYDROData_Channel::DumpToPython( MapOfTreatedObjects& theTreatedObje 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 ); +} diff --git a/src/HYDROData/HYDROData_Channel.h b/src/HYDROData/HYDROData_Channel.h index fbb35f4a..c1aea49c 100644 --- a/src/HYDROData/HYDROData_Channel.h +++ b/src/HYDROData/HYDROData_Channel.h @@ -4,6 +4,9 @@ #include "HYDROData_ArtificialObject.h" +class Handle(HYDROData_Polyline3D); +class Handle(HYDROData_Profile); + DEFINE_STANDARD_HANDLE(HYDROData_Channel, HYDROData_ArtificialObject) /**\class HYDROData_Channel @@ -19,6 +22,8 @@ protected: enum DataTag { DataTag_First = HYDROData_ArtificialObject::DataTag_First + 100, ///< first tag, to reserve + DataTag_GuideLine, + DataTag_Profile, }; public: @@ -44,6 +49,48 @@ public: */ HYDRODATA_EXPORT virtual TopoDS_Shape GetShape3D() const; + /** + * Update the shape presentations of stream. + * Call this method whenever you made changes for channel data. + */ + HYDRODATA_EXPORT virtual void Update(); + + +public: + // Public methods to work with Channel + + /** + * Sets reference guide line object for channel. + */ + HYDRODATA_EXPORT virtual bool SetGuideLine( const Handle(HYDROData_Polyline3D)& theGuideLine ); + + /** + * Returns reference guide line object of channel. + */ + HYDRODATA_EXPORT virtual Handle(HYDROData_Polyline3D) GetGuideLine() const; + + /** + * Remove reference guide line object from channel. + */ + HYDRODATA_EXPORT virtual void RemoveGuideLine(); + + + /** + * Sets reference profile object for channel. + */ + HYDRODATA_EXPORT virtual bool SetProfile( const Handle(HYDROData_Profile)& theProfile ); + + /** + * Returns reference profile object of channel. + */ + HYDRODATA_EXPORT virtual Handle(HYDROData_Profile) GetProfile() const; + + /** + * Remove reference profile object from channel. + */ + HYDRODATA_EXPORT virtual void RemoveProfile(); + + protected: friend class HYDROData_Iterator; -- 2.39.2