#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 );
+}
#include "HYDROData_ArtificialObject.h"
+class Handle(HYDROData_Polyline3D);
+class Handle(HYDROData_Profile);
+
DEFINE_STANDARD_HANDLE(HYDROData_Channel, HYDROData_ArtificialObject)
/**\class HYDROData_Channel
enum DataTag
{
DataTag_First = HYDROData_ArtificialObject::DataTag_First + 100, ///< first tag, to reserve
+ DataTag_GuideLine,
+ DataTag_Profile,
};
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;