]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
Reference objetcs are added for chanel.
authoradv <adv@opencascade.com>
Fri, 29 Nov 2013 07:27:00 +0000 (07:27 +0000)
committeradv <adv@opencascade.com>
Fri, 29 Nov 2013 07:27:00 +0000 (07:27 +0000)
src/HYDROData/HYDROData_Channel.cxx
src/HYDROData/HYDROData_Channel.h

index b365008a5280479091ef9e993c304decc98046c6..9ad19c9716e70bc452562c8769c18b2d4c74dad0 100644 (file)
@@ -2,8 +2,11 @@
 #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>
 
@@ -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 );
+}
index fbb35f4a1d2d15a9baf5ee8af9c2683bbcfc5573..c1aea49c7c416158b74a188f9f2c78dc2b454ea4 100644 (file)
@@ -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;