]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
using DTM object in stream
authorasl <asl@opencascade.com>
Wed, 5 Oct 2016 10:59:29 +0000 (13:59 +0300)
committerasl <asl@opencascade.com>
Wed, 5 Oct 2016 14:23:53 +0000 (17:23 +0300)
12 files changed:
src/HYDROData/HYDROData_Stream.cxx
src/HYDROData/HYDROData_Stream.h
src/HYDROGUI/HYDROGUI_StreamDlg.cxx
src/HYDROGUI/HYDROGUI_StreamDlg.h
src/HYDROGUI/HYDROGUI_StreamOp.cxx
src/HYDRO_tests/CMakeLists.txt
src/HYDRO_tests/ExternalFiles.cmake
src/HYDRO_tests/reference_data/CMakeLists.txt
src/HYDRO_tests/reference_data/StreamDlg.png [new file with mode: 0644]
src/HYDRO_tests/test_HYDROData_DTM.cxx
src/HYDRO_tests/test_HYDROData_Stream.cxx [new file with mode: 0644]
src/HYDRO_tests/test_HYDROData_Stream.h [new file with mode: 0644]

index 44833c6afe4f3e00fb309d29f6bc66019d2e34f4..9f166d7a45e63dafe520072f1bdb6dd07163aa17 100644 (file)
@@ -27,6 +27,7 @@
 #include "HYDROData_IAltitudeObject.h"
 #include "HYDROData_IProfilesInterpolator.h"
 #include "HYDROData_Tool.h"
+#include "HYDROData_DTM.h"
 
 #include <TDataStd_RealArray.hxx>
 
@@ -103,6 +104,19 @@ HYDROData_Stream::~HYDROData_Stream()
 {
 }
 
+void HYDROData_Stream::SetLabel( const TDF_Label& theLabel )
+{
+  HYDROData_NaturalObject::SetLabel( theLabel );
+
+  if( GetAltitudeObject().IsNull() )
+  {
+    Handle(HYDROData_Document) aDoc = HYDROData_Document::Document( myLab );
+    Handle(HYDROData_DTM) aDTM = 
+      Handle(HYDROData_DTM)::DownCast( aDoc->CreateObject( KIND_DTM ) );
+    SetAltitudeObject( aDTM );
+  }
+}
+
 QStringList HYDROData_Stream::DumpToPython( const QString&       thePyScriptPath,
                                             MapOfTreatedObjects& theTreatedObjects ) const
 {
@@ -125,6 +139,11 @@ QStringList HYDROData_Stream::DumpToPython( const QString&       thePyScriptPath
     setPythonReferenceObject( thePyScriptPath, theTreatedObjects, aResList, aBottomPolyline, "SetBottomPolyline" );
   }
 
+  QString aDDZs = QString::number( GetDDZ(), 'f', 3 );
+  QString aSSteps = QString::number( GetSpatialStep(), 'f', 3 );
+  aResList << QString( "%1.SetDDZ( %2 )" ).arg( aName ).arg( aDDZs );
+  aResList << QString( "%1.SetSpatialStep( %2 )" ).arg( aName ).arg( aSSteps );
+
   aResList << QString( "" );
   aResList << QString( "%1.Update()" ).arg( aName );
   aResList << QString( "" );
@@ -318,6 +337,31 @@ TopoDS_Shape HYDROData_Stream::GetOutletShape() const
   return HYDROData_Tool::getFirstShapeFromGroup( aGroups, 4);
 }
 
+Handle_HYDROData_DTM HYDROData_Stream::DTM() const
+{
+  return Handle(HYDROData_DTM)::DownCast( GetAltitudeObject() );
+}
+
+double HYDROData_Stream::GetDDZ() const
+{
+  return DTM()->GetDDZ();
+}
+
+void HYDROData_Stream::SetDDZ( double theDDZ )
+{
+  DTM()->SetDDZ( theDDZ );
+}
+  
+double HYDROData_Stream::GetSpatialStep() const
+{
+  return DTM()->GetSpatialStep();
+}
+
+void HYDROData_Stream::SetSpatialStep( double theSpatialStep )
+{
+  DTM()->SetSpatialStep( theSpatialStep );
+}
+
 bool HYDROData_Stream::SetHydraulicAxis( const Handle(HYDROData_PolylineXY)& theAxis )
 {
   if ( !IsValidAsAxis( theAxis ) )
@@ -508,7 +552,10 @@ bool HYDROData_Stream::SetProfiles( const HYDROData_SequenceOfObjects& theProfil
         continue;
 
       if ( !AddProfile( aProfile ) )
+      {
+        DTM()->SetProfiles( HYDROData_SequenceOfObjects() );
         return false;
+      }
     }
   }
   else // Just store the sequence of objects as is
@@ -538,6 +585,7 @@ bool HYDROData_Stream::SetProfiles( const HYDROData_SequenceOfObjects& theProfil
       Changed( Geom_3d );
   }
 
+  DTM()->SetProfiles( GetProfiles() );
   return true;
 }
 
@@ -713,7 +761,7 @@ void HYDROData_Stream::updateProfilesOrder()
 
 ObjectKind HYDROData_Stream::getAltitudeObjectType() const
 {
-  return KIND_STREAM_ALTITUDE;
+  return KIND_DTM;
 }
 
 void HYDROData_Stream::setParametersArray( const TColStd_Array1OfReal& theArray )
index 73691575c13f3d943568859068000ad378c15d29..06dd511d19de35664cfa39f54484c6f705fc32ce 100644 (file)
@@ -34,6 +34,7 @@ class Handle(HYDROData_Profile);
 class HYDROData_IProfilesInterpolator;
 class TColStd_Array1OfReal;
 class Handle(TopTools_HArray1OfShape);
+class Handle_HYDROData_DTM;
 
 
 /**\class HYDROData_Stream
@@ -264,6 +265,13 @@ public:
    */
   HYDRODATA_EXPORT virtual bool Interpolate( HYDROData_IProfilesInterpolator* theInterpolator );
   
+
+  HYDRODATA_EXPORT double GetDDZ() const;
+  HYDRODATA_EXPORT void   SetDDZ( double theDDZ );
+  
+  HYDRODATA_EXPORT double GetSpatialStep() const;
+  HYDRODATA_EXPORT void   SetSpatialStep( double theSpatialStep );
+  
 protected:
 
   /**
@@ -290,6 +298,8 @@ protected:
   static Handle(Geom_BSplineCurve) buildInterpolationCurve(
     const Handle(TColgp_HArray1OfPnt)& theArrayOfPnt );
 
+  HYDRODATA_EXPORT virtual void SetLabel( const TDF_Label& theLabel );
+
 private:
   
   void setParametersArray( const TColStd_Array1OfReal& theArray );
@@ -302,9 +312,12 @@ private:
 
   void removeParameter( const int& theIndex );
 
-protected:
+  Handle_HYDROData_DTM DTM() const;
+
 
+protected:
   friend class HYDROData_Iterator;
+  friend class test_HYDROData_Stream;
 
   /**
    * Creates new object in the internal data structure. Use higher level objects 
index 591e175e36c6138e5a436d8b623ac9902038da74..208b483f0496f05a8bbaf644baa0483182e5ada4 100644 (file)
 //
 
 #include "HYDROGUI_StreamDlg.h"
-
 #include "HYDROGUI_ListSelector.h"
-#include "HYDROGUI_Module.h"
 #include "HYDROGUI_OrderedListWidget.h"
-#include "HYDROGUI_Tool2.h"
-
 #include <HYDROData_Profile.h>
 
-#include <LightApp_Application.h>
-#include <LightApp_SelectionMgr.h>
+#ifndef LIGHT_MODE
+  #include "HYDROGUI_Module.h"
+  #include "HYDROGUI_Tool2.h"
+  #include <LightApp_Application.h>
+  #include <LightApp_SelectionMgr.h>
+#endif
 
 #include <QComboBox>
 #include <QGroupBox>
@@ -35,6 +35,7 @@
 #include <QLineEdit>
 #include <QListWidget>
 #include <QPushButton>
+#include <QDoubleSpinBox>
 
 HYDROGUI_StreamDlg::HYDROGUI_StreamDlg( HYDROGUI_Module* theModule, const QString& theTitle )
 : HYDROGUI_InputPanel( theModule, theTitle )
@@ -55,9 +56,25 @@ HYDROGUI_StreamDlg::HYDROGUI_StreamDlg( HYDROGUI_Module* theModule, const QStrin
 
   myAxes = new QComboBox( aParamGroup );
   myAxes->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
-  QBoxLayout* anAxisLayout = new QHBoxLayout();
-  anAxisLayout->addWidget( new QLabel( tr( "STREAM_HYDRAULIC_AXIS" ) ) );
-  anAxisLayout->addWidget( myAxes );
+  myDDZ = new QDoubleSpinBox( aParamGroup );
+  myDDZ->setRange( 1E-2, 100 );
+  myDDZ->setSingleStep( 1E-2 );
+  myDDZ->setValue( 0.1 );
+  myDDZ->setDecimals( 2 );
+  mySpatialStep = new QDoubleSpinBox( aParamGroup );
+  mySpatialStep->setRange( 1E-2, 100 );
+  mySpatialStep->setSingleStep( 1.0 );
+  mySpatialStep->setValue( 1 );
+  mySpatialStep->setDecimals( 2 );
+
+  QGridLayout* aParam1Layout = new QGridLayout();
+  aParam1Layout->setMargin( 0 );
+  aParam1Layout->addWidget( new QLabel( tr( "STREAM_HYDRAULIC_AXIS" ) ), 0, 0 );
+  aParam1Layout->addWidget( myAxes, 0, 1 );
+  aParam1Layout->addWidget( new QLabel( tr( "STREAM_DDZ" ) ), 1, 0 );
+  aParam1Layout->addWidget( myDDZ, 1, 1 );
+  aParam1Layout->addWidget( new QLabel( tr( "STREAM_SPATIAL_STEP" ) ), 2, 0 );
+  aParam1Layout->addWidget( mySpatialStep, 2, 1 );
 
   myProfiles = new HYDROGUI_OrderedListWidget( aParamGroup, 0 );
   myProfiles->setHiddenObjectsShown(true);
@@ -77,10 +94,12 @@ HYDROGUI_StreamDlg::HYDROGUI_StreamDlg( HYDROGUI_Module* theModule, const QStrin
   QBoxLayout* aParamLayout = new QVBoxLayout();
   aParamLayout->setMargin( 5 );
   aParamLayout->setSpacing( 5 );
-  aParamLayout->addLayout( anAxisLayout );
+  aParamLayout->addLayout( aParam1Layout );
   aParamLayout->addWidget( myProfiles );
   aParamLayout->addLayout( aButtonsLayout );
 
+
+
   aParamGroup->setLayout( aParamLayout );
 
   // Common
@@ -91,7 +110,11 @@ HYDROGUI_StreamDlg::HYDROGUI_StreamDlg( HYDROGUI_Module* theModule, const QStrin
   // Create selector
   if ( module() ) {
     HYDROGUI_ListSelector* aListSelector = 
+#ifdef LIGHT_MODE
+      new HYDROGUI_ListSelector( myProfiles, 0 );
+#else
       new HYDROGUI_ListSelector( myProfiles, module()->getApp()->selectionMgr() );
+#endif
     aListSelector->setAutoBlock( true );
   }
 
@@ -165,13 +188,17 @@ void HYDROGUI_StreamDlg::setProfiles( const QStringList& theProfiles )
   myProfiles->setUpdatesEnabled( false );
   
   HYDROGUI_ListModel::Object2VisibleList aProfiles;
-  foreach ( const QString& aProfileName, theProfiles ) {
+#ifndef LIGHT_MODE
+  foreach ( const QString& aProfileName, theProfiles )
+  {
     Handle(HYDROData_Profile) anObject = Handle(HYDROData_Profile)::DownCast( 
       HYDROGUI_Tool::FindObjectByName( module(), aProfileName ) );
-    if ( !anObject.IsNull() ) {
+    if ( !anObject.IsNull() )
+    {
       aProfiles.append( HYDROGUI_ListModel::Object2Visible( anObject, true ) );
     }
   }
+#endif
 
   myProfiles->setObjects( aProfiles );
 
@@ -188,3 +215,24 @@ void HYDROGUI_StreamDlg::onRemoveProfiles()
 
   emit RemoveProfiles( aSelectedProfiles );
 }
+
+void HYDROGUI_StreamDlg::setDDZ( const double theDDZ )
+{
+  myDDZ->setValue( theDDZ );
+}
+
+double HYDROGUI_StreamDlg::getDDZ() const
+{
+  return myDDZ->value();
+}
+
+void HYDROGUI_StreamDlg::setSpatialStep( const double theSpatialStep )
+{
+  mySpatialStep->setValue( theSpatialStep );
+}
+
+double HYDROGUI_StreamDlg::getSpatialStep() const
+{
+  return mySpatialStep->value();
+}
+
index a9679f4e7b16160b30d07f3b0199bc662e21e8ad..ee2c44418e4512db45ce111b019bc3fdd1f325dc 100644 (file)
@@ -28,6 +28,7 @@ class QGroupBox;
 class QLineEdit;
 class QListWidget;
 class QPushButton;
+class QDoubleSpinBox;
 
 class HYDROGUI_StreamDlg : public HYDROGUI_InputPanel
 {
@@ -49,6 +50,12 @@ public:
 
   void                       setProfiles( const QStringList& theProfiles );
 
+  void                       setDDZ( const double );
+  double                     getDDZ() const;
+
+  void                       setSpatialStep( const double );
+  double                     getSpatialStep() const;
+
 signals:
   void                       AddProfiles();
   void                       RemoveProfiles( const QStringList& );
@@ -58,8 +65,10 @@ private slots:
   void                       onRemoveProfiles();
 
 private:
-  QGroupBox*                 myObjectNameGroup;
-  QLineEdit*                 myObjectName;
+  QGroupBox*                  myObjectNameGroup;
+  QLineEdit*                  myObjectName;
+  QDoubleSpinBox*             myDDZ;
+  QDoubleSpinBox*             mySpatialStep;
 
   QComboBox*                  myAxes;
   HYDROGUI_OrderedListWidget* myProfiles;
index ca1f6e5df7c3038e9fd1f2799732eaee717f08a1..7a66f2de568afb21224f13236c306e3575e0a3b2 100755 (executable)
@@ -151,6 +151,9 @@ void HYDROGUI_StreamOp::startOperation()
   // set the existing 2D polylines names to the panel
   aPanel->setAxisNames( HYDROGUI_Tool::FindExistingObjectsNames( doc(), KIND_POLYLINEXY ) );
 
+  aPanel->setDDZ( myEditedObject->GetDDZ() );
+  aPanel->setSpatialStep( myEditedObject->GetSpatialStep() );
+
   // synchronize the panel state with the edited object state
   updatePanelData();
 
@@ -245,6 +248,8 @@ bool HYDROGUI_StreamOp::processApply( int& theUpdateFlags,
 
   myEditedObject->SetHydraulicAxis( aHydAxis );
   myEditedObject->SetProfiles( aRefProfiles, false );
+  myEditedObject->SetDDZ( aPanel->getDDZ() );
+  myEditedObject->SetSpatialStep( aPanel->getSpatialStep() );
 
   if ( myEditedObject->IsMustBeUpdated( HYDROData_Entity::Geom_2d ) )
     myEditedObject->Update();
index f220d40163d9a1d2a3d6c95832d1a473caabd2c3..4d5482b07b0a2e006135eb47c1c04f675fecadb4 100644 (file)
@@ -20,6 +20,7 @@ set(PROJECT_HEADERS
   test_HYDROGUI_Shape.h
   test_HYDROGUI_LandCoverMapDlg.h
   test_HYDROData_CalcCase.h
+  test_HYDROData_Stream.h
 
   test_Dependencies.h
   test_HYDROData_DTM.h
@@ -49,6 +50,7 @@ set(PROJECT_SOURCES
   test_HYDROGUI_Shape.cxx
   test_HYDROGUI_LandCoverMapDlg.cxx
   test_HYDROData_CalcCase.cxx
+  test_HYDROData_Stream.cxx
   test_Dependencies.cxx
 
   TestShape.cxx
index dfa0344b11a9603ed1445506ad21a5c67cd0791b..f84b75d56dab5d41f27ae6691674d0f72f027afb 100644 (file)
@@ -73,11 +73,17 @@ set( EXTERNAL_FILES
   ../HYDROGUI/HYDROGUI_StricklerTableDlg.cxx
   ../HYDROGUI/HYDROGUI_LineEditDoubleValidator.cxx
   ../HYDROGUI/HYDROGUI_Tool.cxx
+  ../HYDROGUI/HYDROGUI_StreamDlg.cxx
+  ../HYDROGUI/HYDROGUI_ListSelector.cxx
+  ../HYDROGUI/HYDROGUI_OrderedListWidget.cxx
 )
 
 set( MOC_HEADERS 
   ../HYDROGUI/HYDROGUI_InputPanel.h
   ../HYDROGUI/HYDROGUI_StricklerTableDlg.h
+  ../HYDROGUI/HYDROGUI_StreamDlg.h
+  ../HYDROGUI/HYDROGUI_ListSelector.h
+  ../HYDROGUI/HYDROGUI_OrderedListWidget.h
 )
 
 QT4_WRAP_CPP( PROJECT_MOC_HEADERS ${MOC_HEADERS} )
index 891597b4d13a802e73d92a90135d2873834b8df5..8dd4b2f8c1066629669479e1f4bdbbec449c0339 100644 (file)
@@ -109,7 +109,7 @@ SET(REFERENCE_DATA
     cc_int_w_1.png 
     cc_int_w_2.png
     cc_int_w_3.png
-    
+    StreamDlg.png    
 )
 
 # Application tests
diff --git a/src/HYDRO_tests/reference_data/StreamDlg.png b/src/HYDRO_tests/reference_data/StreamDlg.png
new file mode 100644 (file)
index 0000000..8371a7b
Binary files /dev/null and b/src/HYDRO_tests/reference_data/StreamDlg.png differ
index 97d122abf52250be0405377abbb079be7d87ce98..6659e93013f59edfb658ac6bff5ce3beb9dc30b7 100644 (file)
@@ -20,6 +20,7 @@
 #include <HYDROData_Document.h>
 #include <HYDROData_Profile.h>
 #include <HYDROData_DTM.h>
+#include <HYDROData_Iterator.h>
 #include <Geom2d_Curve.hxx>
 #include <Geom2d_BSplineCurve.hxx>
 #include <gp_XY.hxx>
@@ -38,6 +39,7 @@
 
 const double EPS = 1E-3;
 
+extern QString REF_DATA_PATH;
 NCollection_Sequence<HYDROData_IPolyline::Point> points;
 
 class DTM_item : public QGraphicsItem
@@ -564,5 +566,53 @@ void test_HYDROData_DTM::test_presentation()
 
 void test_HYDROData_DTM::test_garonne()
 {
-  //TODO
+  Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
+  
+  TCollection_AsciiString fname = REF_DATA_PATH.toLatin1().data();
+  fname += "/Profiles.xyz";
+  NCollection_Sequence<int> bad_ids;
+
+  int aSize = HYDROData_Profile::ImportFromFile( aDoc, fname, bad_ids, true );
+  
+  CPPUNIT_ASSERT_EQUAL( 0, bad_ids.Size() );
+  CPPUNIT_ASSERT_EQUAL( 46, aSize );
+
+  HYDROData_SequenceOfObjects profiles;
+  HYDROData_Iterator it( aDoc, KIND_PROFILE );
+  for( int i=0; it.More(); it.Next(), i++ )
+  {
+    if( i>=25 && i<=35 )
+      profiles.Append( Handle(HYDROData_Profile)::DownCast( it.Current() ) );
+  }
+
+  //CPPUNIT_ASSERT_EQUAL( 46, (int)profiles.Size() );
+
+
+
+  Handle(HYDROData_DTM) DTM = Handle(HYDROData_DTM)::DownCast( aDoc->CreateObject( KIND_DTM ) );
+  DTM->SetProfiles( profiles );
+  DTM->SetDDZ( 0.1 );
+  DTM->SetSpatialStep( 1.0 );
+  CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.1, DTM->GetDDZ(), EPS );
+  CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.0, DTM->GetSpatialStep(), EPS );
+  DTM->Update();
+  
+  CPPUNIT_ASSERT_EQUAL( 282336, (int)DTM->GetAltitudePoints().size() ); 
+
+  Handle_AIS_InteractiveContext aContext = TestViewer::context();
+  HYDROGUI_ShapeBathymetry* aBathPrs = new HYDROGUI_ShapeBathymetry( 0, aContext, DTM );
+  aBathPrs->update( true, false );
+
+  TestViewer::showColorScale( true );
+  Handle_Aspect_ColorScale aCS = TestViewer::colorScale();
+  aCS->SetMin( 0.0 );
+  aCS->SetMax( 25.0 );
+  aCS->SetNumberOfIntervals( 30 );
+  aBathPrs->UpdateWithColorScale( aCS );
+  
+  QImage aDTMPrs = draw_DTM( aBathPrs, 0.5, 600, 600 );
+  CPPUNIT_ASSERT_IMAGES2( &aDTMPrs, "DTM_2" );
+  delete aBathPrs;
+
+  aDoc->Close();
 }
diff --git a/src/HYDRO_tests/test_HYDROData_Stream.cxx b/src/HYDRO_tests/test_HYDROData_Stream.cxx
new file mode 100644 (file)
index 0000000..d354d17
--- /dev/null
@@ -0,0 +1,186 @@
+// Copyright (C) 2014-2015  EDF-R&D
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include <test_HYDROData_Stream.h>
+#include <HYDROGUI_StreamDlg.h>
+#include <HYDROData_Document.h>
+#include <HYDROData_DTM.h>
+#include <HYDROData_Stream.h>
+#include <HYDROData_IPolyline.h>
+#include <HYDROData_Profile.h>
+#include <TestViewer.h>
+#include <QApplication>
+
+NCollection_Sequence<HYDROData_IPolyline::Point> points2;
+const double EPS = 1E-3;
+
+void test_HYDROData_Stream::setUp()
+{
+  points2.Clear();
+  points2.Append( gp_XY( 0.0, 5.0 ) );
+  points2.Append( gp_XY( 1.0, 1.0 ) );
+  points2.Append( gp_XY( 1.5, 0.0 ) );
+  points2.Append( gp_XY( 4.0, 4.0 ) );
+}
+
+void test_HYDROData_Stream::tearDown()
+{
+}
+
+void test_HYDROData_Stream::test_dialog()
+{
+  HYDROGUI_StreamDlg* aDlg = new HYDROGUI_StreamDlg( 0, "stream" );
+  aDlg->show();
+  qApp->processEvents();
+
+  QImage aStreamDlgImage = QPixmap::grabWidget( aDlg ).toImage();
+  CPPUNIT_ASSERT_IMAGES2( &aStreamDlgImage, "StreamDlg" );
+
+  aDlg->setDDZ( 12.34 );
+  CPPUNIT_ASSERT_DOUBLES_EQUAL( 12.34, aDlg->getDDZ(), EPS );
+
+  aDlg->setSpatialStep( 56.78 );
+  CPPUNIT_ASSERT_DOUBLES_EQUAL( 56.78, aDlg->getSpatialStep(), EPS );
+
+  delete aDlg;
+}
+
+void test_HYDROData_Stream::test_alt_object()
+{
+  Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
+
+  Handle(HYDROData_Stream) aStream = 
+    Handle(HYDROData_Stream)::DownCast( aDoc->CreateObject( KIND_STREAM ) );
+
+  CPPUNIT_ASSERT_EQUAL( false, (bool)aStream.IsNull() );
+  CPPUNIT_ASSERT_EQUAL( false, (bool)aStream->GetAltitudeObject().IsNull() );
+  CPPUNIT_ASSERT_EQUAL( KIND_DTM, aStream->getAltitudeObjectType() );
+
+  Handle(HYDROData_DTM) aDTM = 
+    Handle(HYDROData_DTM)::DownCast( aStream->GetAltitudeObject() );
+  CPPUNIT_ASSERT_EQUAL( false, (bool)aDTM.IsNull() );
+
+  aDoc->Close();
+}
+
+void test_HYDROData_Stream::test_params_sync()
+{
+  Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
+
+  Handle(HYDROData_Stream) aStream = 
+    Handle(HYDROData_Stream)::DownCast( aDoc->CreateObject( KIND_STREAM ) );
+  Handle(HYDROData_DTM) aDTM = 
+    Handle(HYDROData_DTM)::DownCast( aStream->GetAltitudeObject() );
+  CPPUNIT_ASSERT_EQUAL( false, (bool)aDTM.IsNull() );
+
+  Handle(HYDROData_Profile) aProfile1 = 
+    Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) );
+
+  Handle(HYDROData_Profile) aProfile2 = 
+    Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) );
+
+  aProfile1->SetParametricPoints( points2 );
+  aProfile1->GetProfileUZ()->SetSectionType( 0, HYDROData_IPolyline::SECTION_POLYLINE );
+  aProfile1->SetLeftPoint( gp_XY( 10, 10 ) );
+  aProfile1->SetRightPoint( gp_XY( 20, 0 ) );
+
+  aProfile2->SetParametricPoints( points2 );
+  aProfile2->GetProfileUZ()->SetSectionType( 0, HYDROData_IPolyline::SECTION_POLYLINE );
+  aProfile2->SetLeftPoint( gp_XY( 50, 0 ) );
+  aProfile2->SetRightPoint( gp_XY( 60, 10 ) );
+
+  HYDROData_SequenceOfObjects profiles;
+  profiles.Append( aProfile1 );
+  profiles.Append( aProfile2 );
+
+  aStream->SetProfiles( profiles, false );
+  aStream->SetDDZ( 3.14 );
+  aStream->SetSpatialStep( 4.14 );
+
+  CPPUNIT_ASSERT_DOUBLES_EQUAL( 3.14, aStream->GetDDZ(), EPS );
+  CPPUNIT_ASSERT_DOUBLES_EQUAL( 3.14, aDTM->GetDDZ(), EPS );
+  CPPUNIT_ASSERT_DOUBLES_EQUAL( 4.14, aStream->GetSpatialStep(), EPS );
+  CPPUNIT_ASSERT_DOUBLES_EQUAL( 4.14, aDTM->GetSpatialStep(), EPS );
+
+  HYDROData_SequenceOfObjects profiles1 = aStream->GetProfiles();
+  CPPUNIT_ASSERT_EQUAL( 2, profiles1.Size() );
+  CPPUNIT_ASSERT( profiles.Value(1)->Label() == profiles1.Value(1)->Label() );
+  CPPUNIT_ASSERT( profiles.Value(2)->Label() == profiles1.Value(2)->Label() );
+
+  HYDROData_SequenceOfObjects profiles2 = aDTM->GetProfiles();
+  CPPUNIT_ASSERT_EQUAL( 2, profiles2.Size() );
+  CPPUNIT_ASSERT( profiles.Value(1)->Label() == profiles2.Value(1)->Label() );
+  CPPUNIT_ASSERT( profiles.Value(2)->Label() == profiles2.Value(2)->Label() );
+
+  aDoc->Close();
+}
+
+void test_HYDROData_Stream::test_dump()
+{
+  // Case 1. Without hydraulic axis
+  Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
+
+  Handle(HYDROData_Stream) aStream1 = 
+    Handle(HYDROData_Stream)::DownCast( aDoc->CreateObject( KIND_STREAM ) );
+  aStream1->SetName( "stream_1" );
+
+  Handle(HYDROData_Profile) aProfile1 = 
+    Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) );
+  aProfile1->SetName( "p1" );
+
+  Handle(HYDROData_Profile) aProfile2 = 
+    Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) );
+  aProfile2->SetName( "p2" );
+
+  aProfile1->SetParametricPoints( points2 );
+  aProfile1->GetProfileUZ()->SetSectionType( 0, HYDROData_IPolyline::SECTION_POLYLINE );
+  aProfile1->SetLeftPoint( gp_XY( 10, 10 ) );
+  aProfile1->SetRightPoint( gp_XY( 20, 0 ) );
+
+  aProfile2->SetParametricPoints( points2 );
+  aProfile2->GetProfileUZ()->SetSectionType( 0, HYDROData_IPolyline::SECTION_POLYLINE );
+  aProfile2->SetLeftPoint( gp_XY( 50, 0 ) );
+  aProfile2->SetRightPoint( gp_XY( 60, 10 ) );
+
+  HYDROData_SequenceOfObjects profiles;
+  profiles.Append( aProfile1 );
+  profiles.Append( aProfile2 );
+
+  aStream1->SetProfiles( profiles, false );
+  aStream1->SetDDZ( 0.2 );
+  aStream1->SetSpatialStep( 3.0 );
+
+  MapOfTreatedObjects objs;
+  objs["p1"] = aProfile1;
+  objs["p2"] = aProfile2;
+
+  QStringList aScript1 = aStream1->DumpToPython( "", objs );
+  CPPUNIT_ASSERT_EQUAL( 10, aScript1.size() );
+  CPPUNIT_ASSERT_EQUAL( std::string( "stream_1 = hydro_doc.CreateObject( KIND_STREAM )" ), aScript1[0].toStdString() );
+  CPPUNIT_ASSERT_EQUAL( std::string( "stream_1.SetName( \"stream_1\" )" ),                 aScript1[1].toStdString() );
+  CPPUNIT_ASSERT_EQUAL( std::string( "" ),                                                 aScript1[2].toStdString() );
+  CPPUNIT_ASSERT_EQUAL( std::string( "stream_1.AddProfile( p1 )" ),                        aScript1[3].toStdString() );
+  CPPUNIT_ASSERT_EQUAL( std::string( "stream_1.AddProfile( p2 )" ),                        aScript1[4].toStdString() );
+  CPPUNIT_ASSERT_EQUAL( std::string( "stream_1.SetDDZ( 0.200 )" ),                         aScript1[5].toStdString() );
+  CPPUNIT_ASSERT_EQUAL( std::string( "stream_1.SetSpatialStep( 3.000 )" ),                 aScript1[6].toStdString() );
+  CPPUNIT_ASSERT_EQUAL( std::string( "" ),                                                 aScript1[7].toStdString() );
+  CPPUNIT_ASSERT_EQUAL( std::string( "stream_1.Update()" ),                                aScript1[8].toStdString() );
+  CPPUNIT_ASSERT_EQUAL( std::string( "" ),                                                 aScript1[9].toStdString() );
+
+  aDoc->Close();
+}
diff --git a/src/HYDRO_tests/test_HYDROData_Stream.h b/src/HYDRO_tests/test_HYDROData_Stream.h
new file mode 100644 (file)
index 0000000..c3f6643
--- /dev/null
@@ -0,0 +1,41 @@
+// Copyright (C) 2014-2015  EDF-R&D
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include <cppunit/extensions/HelperMacros.h>
+
+class test_HYDROData_Stream : public CppUnit::TestFixture
+{
+  CPPUNIT_TEST_SUITE( test_HYDROData_Stream );
+  CPPUNIT_TEST( test_dialog );
+  CPPUNIT_TEST( test_alt_object );
+  CPPUNIT_TEST( test_params_sync );
+  CPPUNIT_TEST( test_dump );
+  CPPUNIT_TEST_SUITE_END();
+
+public:
+  void setUp();
+  void tearDown();
+
+  void test_dialog();
+  void test_alt_object();
+  void test_params_sync();
+  void test_dump();
+};
+
+CPPUNIT_TEST_SUITE_REGISTRATION( test_HYDROData_Stream );
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( test_HYDROData_Stream, "HYDROData_Stream" );