Salome HOME
Abort document operation after error in process apply (Bug #340).
[modules/hydro.git] / src / HYDROData / HYDROData_Stream.cxx
index 45b38d4de0821f2c494423c44b21f104e978db38..df6ad67b532cbdb31289a6330ec2929853b49af7 100644 (file)
@@ -68,8 +68,6 @@
 #include <TCollection_AsciiString.hxx>
 #endif
 
-#define PYTHON_STREAM_ID "KIND_STREAM"
-
 typedef NCollection_DataMap<Standard_Real, Handle(HYDROData_Profile)> HYDROData_DataMapOfRealOfHDProfile;
 
 IMPLEMENT_STANDARD_HANDLE(HYDROData_Stream,HYDROData_NaturalObject)
@@ -87,22 +85,22 @@ HYDROData_Stream::~HYDROData_Stream()
 
 QStringList HYDROData_Stream::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const
 {
-  QStringList aResList;
+  QStringList aResList = dumpObjectCreation( theTreatedObjects );
+  QString aName = GetObjPyName();
 
-  Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab );
-  if ( aDocument.IsNull() )
-    return aResList;
+  Handle(HYDROData_PolylineXY) aHydAxis = GetHydraulicAxis();
+  setPythonReferenceObject( theTreatedObjects, aResList, aHydAxis, "SetHydraulicAxis" );
 
-  QString aDocName = aDocument->GetDocPyName();
-  QString aStreamName = GetName();
+  HYDROData_SequenceOfObjects aSeqOfProfiles = GetProfiles();
+  for ( int i = 1, aNb = aSeqOfProfiles.Size(); i <= aNb; ++i )
+  {
+    const Handle(HYDROData_Entity) aProfile = aSeqOfProfiles.Value( i );
+    setPythonReferenceObject( theTreatedObjects, aResList, aProfile, "AddProfile" );
+  }
 
-  aResList << QString( "%1 = %2.CreateObject( %3 );" )
-              .arg( aStreamName ).arg( aDocName ).arg( PYTHON_STREAM_ID );
-  aResList << QString( "%1.SetName( \"%2\" );" )
-              .arg( aStreamName ).arg( aStreamName );
   aResList << QString( "" );
-
-  // TODO
+  aResList << QString( "%1.Update();" ).arg( aName );
+  aResList << QString( "" );
 
   return aResList;
 }
@@ -267,15 +265,31 @@ void HYDROData_Stream::UpdatePrs()
   if(aMakeEdge3.IsDone()) 
     aTopEdge = aMakeEdge3.Edge();
 
-  BRepBuilderAPI_MakeWire aMakeWire( aBotEdge, anEdgLeft, aTopEdge,anEdgRight);
+  // Make wire for 2D presentation with updating of corresponding edges
+  BRepBuilderAPI_MakeWire aMakeWire;
+  
+  aMakeWire.Add( aBotEdge );
+  aBotEdge = aMakeWire.Edge();
+
+  aMakeWire.Add( anEdgLeft );
+  anEdgLeft = aMakeWire.Edge();
+
+  aMakeWire.Add( aTopEdge );
+  aTopEdge = aMakeWire.Edge();
+
+  aMakeWire.Add( anEdgRight );
+  anEdgRight = aMakeWire.Edge();
+
   TopoDS_Wire aSectProfileWire;
   if(aMakeWire.IsDone())
     aSectProfileWire = aMakeWire.Wire();
+
   BRepBuilderAPI_MakeFace aMakeFace( aSectProfileWire, Standard_True );
   TopoDS_Face aFace;
   aMakeFace.Build();
   if( aMakeFace.IsDone() )
     aFace = aMakeFace.Face();
+
   aCmp.Nullify();
   aBB.MakeCompound(aCmp);
   aBB.Add(aCmp,aFace);
@@ -315,14 +329,6 @@ void HYDROData_Stream::UpdatePrs()
   Handle(HYDROData_ShapesGroup) anOutGroup = createGroupObject();
   anOutGroup->SetName( anOutGroupName );
   anOutGroup->AddShape( aTopEdge );
-
-  // This peace of code is for testing of functionality of altitude,
-  // will be removed by adv when testing will be finished
-  Handle(HYDROData_IAltitudeObject) anAltObj = GetAltitudeObject();
-  gp_XY aTestPnt( 5, 0 );
-  anAltObj->GetAltitudeForPoint( aTestPnt );
-  // End of test code
-
 }
 
 QColor HYDROData_Stream::DefaultFillingColor()