Salome HOME
Profile object creation.
[modules/hydro.git] / src / HYDROData / HYDROData_Channel.cxx
index 0a1d13bd4d8ce2fe4c70412959e51f15135a82f6..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>
 
@@ -26,7 +29,7 @@ QStringList HYDROData_Channel::DumpToPython( MapOfTreatedObjects& theTreatedObje
 {
   QStringList aResList;
 
-  Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( this );
+  Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab );
   if ( aDocument.IsNull() )
     return aResList;
 
@@ -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 );
+}