From 9cd1bdfa95443b2bd7ee04502737cb4c7d387063 Mon Sep 17 00:00:00 2001 From: asl Date: Wed, 5 Oct 2016 13:59:29 +0300 Subject: [PATCH] using DTM object in stream --- src/HYDROData/HYDROData_Stream.cxx | 50 ++++- src/HYDROData/HYDROData_Stream.h | 15 +- src/HYDROGUI/HYDROGUI_StreamDlg.cxx | 72 +++++-- src/HYDROGUI/HYDROGUI_StreamDlg.h | 13 +- src/HYDROGUI/HYDROGUI_StreamOp.cxx | 5 + src/HYDRO_tests/CMakeLists.txt | 2 + src/HYDRO_tests/ExternalFiles.cmake | 6 + src/HYDRO_tests/reference_data/CMakeLists.txt | 2 +- src/HYDRO_tests/reference_data/StreamDlg.png | Bin 0 -> 8087 bytes src/HYDRO_tests/test_HYDROData_DTM.cxx | 52 ++++- src/HYDRO_tests/test_HYDROData_Stream.cxx | 186 ++++++++++++++++++ src/HYDRO_tests/test_HYDROData_Stream.h | 41 ++++ 12 files changed, 426 insertions(+), 18 deletions(-) create mode 100644 src/HYDRO_tests/reference_data/StreamDlg.png create mode 100644 src/HYDRO_tests/test_HYDROData_Stream.cxx create mode 100644 src/HYDRO_tests/test_HYDROData_Stream.h diff --git a/src/HYDROData/HYDROData_Stream.cxx b/src/HYDROData/HYDROData_Stream.cxx index 44833c6a..9f166d7a 100644 --- a/src/HYDROData/HYDROData_Stream.cxx +++ b/src/HYDROData/HYDROData_Stream.cxx @@ -27,6 +27,7 @@ #include "HYDROData_IAltitudeObject.h" #include "HYDROData_IProfilesInterpolator.h" #include "HYDROData_Tool.h" +#include "HYDROData_DTM.h" #include @@ -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 ) diff --git a/src/HYDROData/HYDROData_Stream.h b/src/HYDROData/HYDROData_Stream.h index 73691575..06dd511d 100644 --- a/src/HYDROData/HYDROData_Stream.h +++ b/src/HYDROData/HYDROData_Stream.h @@ -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 diff --git a/src/HYDROGUI/HYDROGUI_StreamDlg.cxx b/src/HYDROGUI/HYDROGUI_StreamDlg.cxx index 591e175e..208b483f 100644 --- a/src/HYDROGUI/HYDROGUI_StreamDlg.cxx +++ b/src/HYDROGUI/HYDROGUI_StreamDlg.cxx @@ -17,16 +17,16 @@ // #include "HYDROGUI_StreamDlg.h" - #include "HYDROGUI_ListSelector.h" -#include "HYDROGUI_Module.h" #include "HYDROGUI_OrderedListWidget.h" -#include "HYDROGUI_Tool2.h" - #include -#include -#include +#ifndef LIGHT_MODE + #include "HYDROGUI_Module.h" + #include "HYDROGUI_Tool2.h" + #include + #include +#endif #include #include @@ -35,6 +35,7 @@ #include #include #include +#include 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(); +} + diff --git a/src/HYDROGUI/HYDROGUI_StreamDlg.h b/src/HYDROGUI/HYDROGUI_StreamDlg.h index a9679f4e..ee2c4441 100644 --- a/src/HYDROGUI/HYDROGUI_StreamDlg.h +++ b/src/HYDROGUI/HYDROGUI_StreamDlg.h @@ -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; diff --git a/src/HYDROGUI/HYDROGUI_StreamOp.cxx b/src/HYDROGUI/HYDROGUI_StreamOp.cxx index ca1f6e5d..7a66f2de 100755 --- a/src/HYDROGUI/HYDROGUI_StreamOp.cxx +++ b/src/HYDROGUI/HYDROGUI_StreamOp.cxx @@ -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(); diff --git a/src/HYDRO_tests/CMakeLists.txt b/src/HYDRO_tests/CMakeLists.txt index f220d401..4d5482b0 100644 --- a/src/HYDRO_tests/CMakeLists.txt +++ b/src/HYDRO_tests/CMakeLists.txt @@ -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 diff --git a/src/HYDRO_tests/ExternalFiles.cmake b/src/HYDRO_tests/ExternalFiles.cmake index dfa0344b..f84b75d5 100644 --- a/src/HYDRO_tests/ExternalFiles.cmake +++ b/src/HYDRO_tests/ExternalFiles.cmake @@ -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} ) diff --git a/src/HYDRO_tests/reference_data/CMakeLists.txt b/src/HYDRO_tests/reference_data/CMakeLists.txt index 891597b4..8dd4b2f8 100644 --- a/src/HYDRO_tests/reference_data/CMakeLists.txt +++ b/src/HYDRO_tests/reference_data/CMakeLists.txt @@ -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 index 0000000000000000000000000000000000000000..8371a7bc21f7ed42bcac03d6d18a7983d4fad71a GIT binary patch literal 8087 zcmeHscT|(x(sw{bK>-B;0RfMwAVE;7hb|Tnjr3;dRZ0j&Is}!bND&VmLzO1Y&>=vS z5}Nd0BhpI<5J*S}w^&pb2p+cSBm^Gt)4g^vXU z0IDL^wf!cBL@*ma z2qdKN_`y8`zfbtt5Z4hha%D&R%fZB}0D)<{Kyeqw8s_ioNQvAwaNY=-h4)0Z!ulv1 zb~@}wyv4W0#kwhbvYA@lyUDe((8ZiK+lk(;Wb{n9*Sl;MRi(eS6h^D{qGgH=i}=q8 zeyT8U!xo*s%1LY`HmNR0Vx);kAsnF*)*rWWKmHAdNI@WiI*7aELu6|I%4@6Jg&?)Q zWN!2cP!ubQQSH)yfl@|InEm)*7h*ElR}gPuo9ja`m%Wo5hlR;JMJSvYe`0vnuk?35RE zthfs2tJ1I>K*a#FR$-+^S~s~a@fk=Y^IeW=`n+LYHn?SS$vbXrykPxFQ?Z+S+&ykP z%L40UkcmCzYGIk&?ylF~-d(AL(z4PghkjNsbY!bxrTl~T-x^9G@tWHL_(B(FttN6q zO|Z9sMldtftC;hZ_n1vPYIKwkjmg*S@Xf~{%pnIjVF6Ox+1PIbSWVs zb3<%y^Q(fuk=dG?!M*`Z3DV7y4(l?j9H0&HjMBRSZ-6t`?ML5&)U{cZ&2G?8E@zLp zH2iF@F(hbpzH;}QR9q+7H%oX_)!UBCce^6H%o#s~&df1;?wt%hQFbhit>-}0Q)l;u zld<~a7cTK#es}UirDeOLS~}XIzQ&;etEW}8KGvN7J@zi^Of?L&#}hVG3AJyJ+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^zZP1fe{hyjF$??>gwuzA8`SB_?(jeuARMo-u&M& zqt-Q1uc@g?Utiy$!270vy}kX?(h>j;5W}oa01F@h_{rKS7=f-RbMJw!M4K@Df72%Y a#EOiRMIq;G74X+O=<&m656aZ7-uxfrE)1do literal 0 HcmV?d00001 diff --git a/src/HYDRO_tests/test_HYDROData_DTM.cxx b/src/HYDRO_tests/test_HYDROData_DTM.cxx index 97d122ab..6659e930 100644 --- a/src/HYDRO_tests/test_HYDROData_DTM.cxx +++ b/src/HYDRO_tests/test_HYDROData_DTM.cxx @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -38,6 +39,7 @@ const double EPS = 1E-3; +extern QString REF_DATA_PATH; NCollection_Sequence 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 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 index 00000000..d354d175 --- /dev/null +++ b/src/HYDRO_tests/test_HYDROData_Stream.cxx @@ -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 +#include +#include +#include +#include +#include +#include +#include +#include + +NCollection_Sequence 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 index 00000000..c3f6643a --- /dev/null +++ b/src/HYDRO_tests/test_HYDROData_Stream.h @@ -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 + +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" ); -- 2.39.2