PROJECT(SalomeHYDRO C CXX)
+ADD_SUBDIRECTORY (src/HYDRO_tests)
+
# Ensure a proper linker behavior:
CMAKE_POLICY(SET CMP0003 NEW)
set(PROJECT_LIBRARIES shapelib HYDROData)
-# tests
-if(SALOME_BUILD_TESTS)
-
- set(TEST_HEADERS
- test_HYDROData_Bathymetry.h
- test_HYDROData_BSplineOperation.h
- test_HYDROData_CalculationCase.h
- test_HYDROData_Document.h
- test_HYDROData_Entity.h
- test_HYDROData_Image.h
- test_HYDROData_Iterator.h
- test_HYDROData_OperationsFactory.h
- test_HYDROData_PolylineXY.h
- test_HYDROData_StricklerTable.h
- )
-
- set(TEST_SOURCES
- test_HYDROData_Main.cxx
- test_HYDROData_Bathymetry.cxx
- test_HYDROData_BSplineOperation.cxx
- test_HYDROData_CalculationCase.cxx
- test_HYDROData_Document.cxx
- test_HYDROData_Entity.cxx
- test_HYDROData_Image.cxx
- test_HYDROData_Iterator.cxx
- test_HYDROData_OperationsFactory.cxx
- test_HYDROData_PolylineXY.cxx
- test_HYDROData_StricklerTable.cxx
- )
-
- set(TEST_EXE test_HYDROData)
- include(../../CMake/CPPUnitTests.cmake)
- target_link_libraries(test_HYDROData ${CAS_OCAF} ${CAS_MODELER} ${QT_LIBRARIES} ${CPPUNIT_LIBRARIES} HYDROData)
-
-endif(SALOME_BUILD_TESTS)
-
#include(../../CMake/CommonInstall.cmake)
#ifndef HYDRODATA_H
#define HYDRODATA_H
-#if defined HYDRODATA_EXPORTS
-#if defined WIN32
-#define HYDRODATA_EXPORT __declspec( dllexport )
+#ifdef HYDRODATA_STATIC
+ #define HYDRODATA_EXPORT
#else
-#define HYDRODATA_EXPORT
-#endif
-#else
-#if defined WIN32
-#define HYDRODATA_EXPORT __declspec( dllimport )
-#else
-#define HYDRODATA_EXPORT
-#endif
+ #ifdef HYDRODATA_EXPORTS
+ #ifdef WIN32
+ #define HYDRODATA_EXPORT __declspec( dllexport )
+ #else
+ #define HYDRODATA_EXPORT
+ #endif
+ #else
+ #ifdef WIN32
+ #define HYDRODATA_EXPORT __declspec( dllimport )
+ #else
+ #define HYDRODATA_EXPORT
+ #endif
+ #endif
#endif
#endif
#include <gp_Pnt.hxx>
#include <TColgp_HArray1OfPnt.hxx>
#include <QPainterPath>
+
+#ifndef LIGHT_MODE
#include <CurveCreator_Utils.hxx>
+#endif
Handle(Geom_BSplineCurve) HYDROData_BSplineOperation::ComputeCurve(
const NCollection_Sequence<gp_XYZ>& thePoints,
// compute BSpline
Handle(Geom_BSplineCurve) aBSpline;
+#ifndef LIGHT_MODE
if( CurveCreator_Utils::constructBSpline( aHCurvePoints, theIsClosed, aBSpline ) )
return aBSpline;
else
+#endif
return Handle(Geom_BSplineCurve)();
}
#include "HYDROData_Tool.h"
#include "HYDROData_GeomTool.h"
+#ifndef LIGHT_MODE
#include <GEOMBase.h>
+#endif
#include <QSet>
QString HYDROData_CalculationCase::Export( int theStudyId ) const
{
+#ifdef LIGHT_MODE
+ return "";
+#else
GEOM::GEOM_Gen_var aGEOMEngine = HYDROData_GeomTool::GetGeomGen();
SALOMEDS::Study_var aDSStudy = HYDROData_GeomTool::GetStudyByID( theStudyId );
QString aGeomObjEntry, anErrorMsg;
bool isOK = Export( aGEOMEngine, aDSStudy, aGeomObjEntry, anErrorMsg );
return isOK ? aGeomObjEntry : QString();
+#endif
}
+#ifndef LIGHT_MODE
bool HYDROData_CalculationCase::Export( GEOM::GEOM_Gen_var theGeomEngine,
SALOMEDS::Study_ptr theStudy,
QString& theGeomObjEntry,
return true;
}
+#endif
void HYDROData_CalculationCase::ClearRules( HYDROData_CalculationCase::DataTag theDataTag,
const bool theIsSetToUpdate )
#include <HYDROData_Zone.h>
#include <HYDROData_Warning.h>
+#ifndef LIGHT_MODE
// IDL includes
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(GEOM_Gen)
+#endif
class gp_XY;
* \param theErrorMsg the error message
* \return true in case of success
*/
+#ifndef LIGHT_MODE
HYDRODATA_EXPORT virtual bool Export( GEOM::GEOM_Gen_var theGeomEngine,
SALOMEDS::Study_ptr theStudy,
QString& theGeomObjEntry,
QString& theErrorMsg ) const;
+#endif
public:
// Public methods to work with Calculation services
* \param theSplittedGroups the list of groups
* \return true in case of success
*/
+#ifndef LIGHT_MODE
bool Export( GEOM::GEOM_Gen_var theGeomEngine,
SALOMEDS::Study_ptr theStudy,
const TopTools_ListOfShape& theFaces,
const HYDROData_ShapesGroup::SeqOfGroupsDefs& theGroupsDefs,
QString& theGeomObjEntry ) const;
+#endif
void CreateRegionsDef( const Handle(HYDROData_Document)& theDoc,
const HYDROData_SplitToZonesTool::SplitDataList& theZones,
#include "HYDROData_GeomTool.h"
+#ifndef LIGHT_MODE
+
#include <TopoDS_Shape.hxx>
#include <BRepTools.hxx>
return anEntry;
}
+
+#endif
#include "HYDROData.h"
+#ifndef LIGHT_MODE
#include <GEOM_Client.hxx>
class TopoDS_Shape;
#endif
+#endif
+
#include "HYDROData_Tool.h"
#include "HYDROData_GeomTool.h"
+#ifndef LIGHT_MODE
#include <Basics_Utils.hxx>
+#endif
#include <BRepTools.hxx>
#include <BRep_Builder.hxx>
{
bool aRes = false;
+#ifndef LIGHT_MODE
if ( theIOR.IsEmpty() ) {
return aRes;
}
SetShape3D( aShape );
aRes = true;
}
-
+#endif
+
return aRes;
}
return aRes;
}
+#ifndef LIGHT_MODE
SALOMEDS::Study_var aDSStudy = HYDROData_GeomTool::GetStudyByID( aDocId );
if ( !aDSStudy->_is_nil() ) {
aRes = TCollection_AsciiString( aSObject->GetName() );
}
}
-
+#endif
return aRes;
}
{
TopoDS_Shape aResShape;
+#ifndef LIGHT_MODE
// Set "C" numeric locale to save numbers correctly
Kernel_Utils::Localizer loc;
catch(Standard_Failure) {
aResShape.Nullify();
}
+#endif
return aResShape;
}
{
TopoDS_Shape aResShape;
+#ifndef LIGHT_MODE
// Set "C" numeric locale to save numbers correctly
Kernel_Utils::Localizer loc;
catch (Standard_Failure) {
aResShape.Nullify();
}
+#endif
return aResShape;
}
#include <HYDROData_Document.h>
#include <HYDROData_TopoCurve.h>
+#ifndef LIGHT_MODE
#include <CurveCreator_Utils.hxx>
+#endif
#include <BRepAdaptor_Curve.hxx>
#include <BRep_Builder.hxx>
#include <TopExp_Explorer.hxx>
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
#include <QString>
+#include <Geom_BSplineCurve.hxx>
template<class T> void append( std::vector<T>& theList, const std::vector<T>& theList2 )
{
}
Handle(Geom_BSplineCurve) aBSpline2;
const bool isClosed = theCurve.IsClosed();
+#ifndef LIGHT_MODE
if (!CurveCreator_Utils::constructBSpline(aPs2, isClosed, aBSpline2))
+#endif
{
return -1;
}
#include <BRepBuilderAPI_MakeFace.hxx>
#include <BRepOffsetAPI_NormalProjection.hxx>
+#ifndef LIGHT_MODE
#include <GEOMBase.h>
+#endif
#include <GeomAPI_ProjectPointOnCurve.hxx>
#include <GeomAdaptor_Curve.hxx>
bool HYDROData_PolylineXY::ImportFromGeomIOR( const TCollection_AsciiString& theIOR )
{
+#ifdef LIGHT_MODE
+ return false;
+#else
if ( theIOR.IsEmpty() )
return false;
return false;
return ImportShape( aShape );
+#endif
}
void HYDROData_PolylineXY::SetGeomObjectEntry( const TCollection_AsciiString& theEntry )
if( aMap.IsNull() )
return false;
- std::ofstream aStream( theFileName.ToCString(), std::ios::out | std::ios::binary );
- if( !aStream )
+ QFile aFile( theFileName.ToCString() );
+ if( !aFile.open( QFile::WriteOnly | QFile::Text ) )
return false;
- aStream << GetAttrName().toStdString() << "\r\n";
+ QTextStream aStream( &aFile );
+ aStream.setCodec( "UTF-8" );
+
+ aStream << GetAttrName() << "\n";
bool aRes = true;
for ( TDataStd_DataMapIteratorOfDataMapOfStringReal it( aMap->GetRealsContainer() ); it.More() && aRes; it.Next() )
{
- TCollection_ExtendedString aType = it.Key();
- TCollection_ExtendedString aLine = TCollection_ExtendedString( '\"' ) + aType + TCollection_ExtendedString( '\"' ) +
- TCollection_ExtendedString( ' ' ) + TCollection_ExtendedString( it.Value() );
- Standard_PCharacter aBuf = (Standard_PCharacter)malloc( aLine.LengthOfCString() + 1 );
- aStream.write( aBuf, aLine.ToUTF8CString( aBuf ) );
-
- QString aColor = QString::number( aMap->GetInteger( aType ), 16 );
- QString anAttrValue = toQString( aMap->GetString( aType ) );
-
- aStream << " " << aColor.toStdString() << " " << anAttrValue.toStdString();
- aStream.write( "\r\n", 2 );
- free( aBuf );
+ QString aType = toQString( it.Key() );
+ aStream << "\"" << aType << "\" " << it.Value();
+
+ QString aColor = QString::number( aMap->GetInteger( it.Key() ), 16 ).toUpper();
+ QString anAttrValue = toQString( aMap->GetString( it.Key() ) );
+
+ aStream << " " << aColor << " " << anAttrValue << "\n";
}
- aStream.close();
+ aFile.close();
return aRes;
}
+++ /dev/null
-// 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_BSplineOperation.h>
-
-#include <HYDROData_BSplineOperation.h>
-#include <gp_Pnt.hxx>
-#include <QTransform>
-
-const double LOCAL_SELECTION_TOLERANCE = 0.0001;
-
-void test_HYDROData_BSplineOperation::testCurve()
-{
- /*// prepare points: function of sin(x)
- NCollection_Sequence<gp_XYZ> aPoints;
- for ( double x = 0; x < 6.28; x += 0.1 )
- {
- gp_XYZ aPoint( x, sin( x ), 0.0 );
- aPoints.Append( aPoint );
- }
- // compute BSpline
- HYDROData_BSplineOperation aBSpline( aPoints, false, LOCAL_SELECTION_TOLERANCE );
-
- Handle(Geom_BSplineCurve) aBS = aBSpline.Curve();
- CPPUNIT_ASSERT( !aBS.IsNull() );
- CPPUNIT_ASSERT( !aBS->IsClosed() );
- CPPUNIT_ASSERT_EQUAL( aBS->Continuity(), GeomAbs_C2 );
-
- // check that values of BSpline are not far from original "sin" function
- // in all points of the curve
- for ( double x = 0; x < 6.29; x += 0.001 )
- {
- double aDiff = aBS->Value( x ).Y() - sin( aBS->Value( x ).X() );
- if ( aDiff < 0 ) aDiff = -aDiff;
- CPPUNIT_ASSERT( aDiff < 3.e-6 ); // this number is found manually
- }*/
-}
-
-void test_HYDROData_BSplineOperation::testPath()
-{
- /*// prepare points: function of sin(x)
- static const double aScale = 10000000.;
-
- NCollection_Sequence<gp_XYZ> aPoints;
- for ( double x = 0; x < 6.28; x += 0.1 )
- {
- gp_XYZ aPoint( x * aScale, sin( x ) * aScale, 0.0 );
- aPoints.Append( aPoint );
- }
-
- // convert to QPainterPath
- HYDROData_BSplineOperation aBSpline( aPoints, false, LOCAL_SELECTION_TOLERANCE );
-
- CPPUNIT_ASSERT( !aBSpline.Curve().IsNull() );
-
- QPainterPath aPath;
- aBSpline.ComputePath( aPath );
- CPPUNIT_ASSERT( !aPath.isEmpty() );*/
-
- /*
- QImage aPic(1300, 600, QImage::Format_RGB32);
- QPainter aPainter(&aPic);
- aPainter.setBrush(QBrush(Qt::white));
- aPainter.drawPath(aPath);
- aPic.save("pic.bmp");
- */
-
- /*// check that values of Path are not far from original "sin" function
- // in all points of the curve
- QList<QPolygonF> aPolyF = aPath.toSubpathPolygons( QTransform() );
- QList<QPolygonF>::iterator aFIter = aPolyF.begin();
- for(; aFIter != aPolyF.end();aFIter++) {
- QPolygon aPoly = aFIter->toPolygon();
- QPolygon::iterator aPoints = aPoly.begin();
- for(; aPoints != aPoly.end(); aPoints++) {
- double aDiff = aPoints->y() / aScale - sin(aPoints->x() / aScale);
- if (aDiff < 0) aDiff = -aDiff;
- CPPUNIT_ASSERT(aDiff < 4.e-6); // this number is found manually
- }
- }*/
-}
+++ /dev/null
-// 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_BSplineOperation : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(test_HYDROData_BSplineOperation);
- CPPUNIT_TEST(testCurve);
- CPPUNIT_TEST(testPath);
- CPPUNIT_TEST_SUITE_END();
-
-private:
-
-public:
-
- void setUp() {}
-
- void tearDown() {}
-
- // checks generation of BSpline curve by points
- void testCurve();
-
- // checks generation of QPainterPath
- void testPath();
-
-};
-
-CPPUNIT_TEST_SUITE_REGISTRATION(test_HYDROData_BSplineOperation);
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(test_HYDROData_BSplineOperation, "HYDROData_BSplineOperation");
+++ /dev/null
-// 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_Bathymetry.h>
-
-#include <HYDROData_Document.h>
-#include <HYDROData_Tool.h>
-#include <HYDROData_Bathymetry.h>
-
-#include <gp_XY.hxx>
-#include <gp_XYZ.hxx>
-
-#include <QDir>
-#include <QFile>
-#include <QTextStream>
-
-#include <gp_Pnt2d.hxx>
-
-void generateOne( QTextStream& theStream,
- double theFirstX, double theFirstY,
- double theLastX, double theLastY )
-{
- const int aNbPoints = 50;
-
- double aComDist = gp_Pnt2d( theFirstX, theFirstY ).Distance( gp_Pnt2d( theLastX, theLastY ) );
- double aStep = aComDist / (double)aNbPoints;
-
- double aStepZ = -5;
- double aCurDist = 0.0;
- for ( int i = 0; i <= aNbPoints; ++i )
- {
- double aRatio = ( aCurDist / ( aComDist - aCurDist ) );
-
- double anX = ( theFirstX + aRatio * theLastX ) / ( 1 + aRatio );
- double anY = ( theFirstY + aRatio * theLastY ) / ( 1 + aRatio );
- double aZ = aStepZ * aStepZ + sin( (float)rand() );
- theStream << anX << " " << anY << " " << aZ << " \n";
-
- aCurDist += aStep;
- aStepZ += 0.2;
- }
-}
-
-bool test_HYDROData_Bathymetry::createTestFile( const QString& theFileName )
-{
- QFile aTmpFile( theFileName );
- if ( !aTmpFile.open( QIODevice::WriteOnly | QIODevice::Text ) )
- return false;
-
- {
- QTextStream anOutStream( &aTmpFile );
-
- srand( 4587 );
- generateOne( anOutStream, 0, 5, 0, -5 );
- generateOne( anOutStream, 10, 5, 10, -5 );
- generateOne( anOutStream, 20, 5, 20, -5 );
- generateOne( anOutStream, 30, 5, 30, -5 );
- generateOne( anOutStream, 40, 5, 40, -5 );
- generateOne( anOutStream, 45.833271, 6.703101, 50.85397, -3.794724 );
- generateOne( anOutStream, 50.85397, 11.267372, 56.787525, 2.367043 );
- generateOne( anOutStream, 52.67968, 16.516285, 62.721077, 10.354518 );
- generateOne( anOutStream, 55.190029, 23.819118, 65.23143, 17.657352 );
- generateOne( anOutStream, 58.385021, 31.806595, 68.198204, 23.819118 );
- generateOne( anOutStream, 65.916069, 38.653004, 75.044609, 27.470537 );
- generateOne( anOutStream, 76.870323, 41.847992, 82.575661, 28.38339 );
- generateOne( anOutStream, 92.845276, 40.022282, 91.932419, 26.557682 );
- generateOne( anOutStream, 106.081657, 35.686226, 98.778824, 21.99341 );
- generateOne( anOutStream, 119.774475, 29.980886, 106.994514, 14.91879 );
- generateOne( anOutStream, 133.239075, 26.785896, 115.666634, 5.790246 );
- generateOne( anOutStream, 150.811523, 20.167702, 125.47982, -4.707579 );
- generateOne( anOutStream, 163.591476, 13.777717, 135.977631, -12.92327 );
- generateOne( anOutStream, 183.446045, 11.267367, 151.496155, -24.105736 );
- generateOne( anOutStream, 197.367081, 8.98523100, 172.720016, -31.180355 );
- generateOne( anOutStream, 214.026672, 9.669872, 197.823502, -38.483189 );
- generateOne( anOutStream, 235.706985, 9.89809100, 220.873108, -47.155304 );
- generateOne( anOutStream, 266.744019, 9.213447, 248.715134, -58.565987 );
- generateOne( anOutStream, 307.366028, 10.354514, 278.611145, -67.922737 );
- generateOne( anOutStream, 342.510925, 7.159524, 316.951019, -84.81053 );
- generateOne( anOutStream, 384.659393, -4.55408, 350.913635, -100.02983 );
- generateOne( anOutStream, 443.097107, -21.015415, 391.243927, -118.960365 );
- generateOne( anOutStream, 500.711792, -34.184483, 440.62793, -147.7677 );
- generateOne( anOutStream, 547.626587, -52.291954, 482.604309, -169.990509 );
- generateOne( anOutStream, 589.603027, -68.753288, 534.45752, -193.8594 );
- generateOne( anOutStream, 633.225525, -97.560631, 569.026306, -206.205444 );
- generateOne( anOutStream, 673.555786, -120.606499, 601.948975, -224.312912 );
- generateOne( anOutStream, 719.647522, -148.590775, 654.625305, -248.181854 );
- generateOne( anOutStream, 770.677673, -183.982635, 708.947693, -278.635315 );
- generateOne( anOutStream, 824.177002, -225.959045, 742.69342, -314.027191 );
- generateOne( anOutStream, 855.937317, -260.368958, 793.05932, -341.853638 );
- generateOne( anOutStream, 884.168213, -294.37439, 838.6137700, -355.969116 );
- generateOne( anOutStream, 915.607178, -327.096588, 875.185669, -366.234894 );
- generateOne( anOutStream, 940.630066, -348.269775, 903.416565, -381.633575 );
- generateOne( anOutStream, 963.728088, -370.726166, 936.780396, -397.032257 );
- generateOne( anOutStream, 983.618042, -390.61615, 959.878418, -411.789337 );
- generateOne( anOutStream, 999.658325, -407.939667, 978.485107, -425.904785 );
- generateOne( anOutStream, 1018.265076, -422.696716, 996.450256, -443.228302 );
- generateOne( anOutStream, 1040.079834, -441.303467, 1017.623413, -459.9102175 );
- generateOne( anOutStream, 1055.478516, -456.060547, 1034.946899, -475.9505 );
- generateOne( anOutStream, 1074.085327, -474.025665, 1058.044922, -493.274017 );
- }
-
- aTmpFile.close();
-
- return true;
-}
-
-void test_HYDROData_Bathymetry::testFileImport()
-{
- Handle(HYDROData_Document) aDoc = HYDROData_Document::Document( 1 );
-
- Handle(HYDROData_Bathymetry) aBathymetry =
- Handle(HYDROData_Bathymetry)::DownCast( aDoc->CreateObject( KIND_BATHYMETRY ) );
-
- QString aFileName = QDir::tempPath() + QDir::separator() + "test.xyz";
- if ( !createTestFile( aFileName ) )
- return; // No file has been created
-
- CPPUNIT_ASSERT( aBathymetry->ImportFromFile( aFileName.toStdString().c_str() ) );
-
- HYDROData_Bathymetry::AltitudePoints anAltitudePoints = aBathymetry->GetAltitudePoints();
- CPPUNIT_ASSERT( anAltitudePoints.Length() == 20 );
-
- gp_XY aTestPoint( 1, 1 );
- double anAltitude = aBathymetry->GetAltitudeForPoint( aTestPoint );
- CPPUNIT_ASSERT( ValuesEquals( anAltitude, 10.0 ) );
-
- aTestPoint = gp_XY( 0.5, 0.5 );
- anAltitude = aBathymetry->GetAltitudeForPoint( aTestPoint );
- CPPUNIT_ASSERT( ValuesEquals( anAltitude, 5.0 ) );
-
- aTestPoint = gp_XY( 1.5, 1 );
- anAltitude = aBathymetry->GetAltitudeForPoint( aTestPoint );
- CPPUNIT_ASSERT( ValuesEquals( anAltitude, 10.0 ) );
-
- aTestPoint = gp_XY( 1.5, 0.7 );
- anAltitude = aBathymetry->GetAltitudeForPoint( aTestPoint );
- CPPUNIT_ASSERT( ValuesEquals( anAltitude, 7.0 ) );
-
- aTestPoint = gp_XY( 1.5, -0.7 );
- anAltitude = aBathymetry->GetAltitudeForPoint( aTestPoint );
- CPPUNIT_ASSERT( ValuesEquals( anAltitude, HYDROData_Bathymetry::GetInvalidAltitude() ) );
-
- aTestPoint = gp_XY( 2, 3.5 );
- anAltitude = aBathymetry->GetAltitudeForPoint( aTestPoint );
- CPPUNIT_ASSERT( ValuesEquals( anAltitude, 35.0 ) );
-
- aDoc->Close();
-}
-
-
-void test_HYDROData_Bathymetry::testCopy()
-{
- Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
-
- Handle(HYDROData_Bathymetry) aBathymetry1 =
- Handle(HYDROData_Bathymetry)::DownCast( aDoc->CreateObject( KIND_BATHYMETRY ) );
-
- QString aFileName = QDir::tempPath() + QDir::separator() + "test.xyz";
-
- bool anIsFileCreated = createTestFile( aFileName );
-
- if ( anIsFileCreated )
- {
- CPPUNIT_ASSERT( aBathymetry1->ImportFromFile( aFileName.toStdString().c_str() ) );
-
- HYDROData_Bathymetry::AltitudePoints anAltitudePoints = aBathymetry1->GetAltitudePoints();
- CPPUNIT_ASSERT( anAltitudePoints.Length() == 20 );
- }
-
- Handle(HYDROData_Bathymetry) aBathymetry2 =
- Handle(HYDROData_Bathymetry)::DownCast( aDoc->CreateObject( KIND_BATHYMETRY ) );
-
- aBathymetry1->CopyTo( aBathymetry2, true );
-
- if ( anIsFileCreated )
- {
- HYDROData_Bathymetry::AltitudePoints anAltitudePoints = aBathymetry2->GetAltitudePoints();
- CPPUNIT_ASSERT( anAltitudePoints.Length() == 20 );
- }
-
- aDoc->Close();
-}
+++ /dev/null
-// 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 Handle_HYDROData_Bathymetry;
-class QString;
-
-class test_HYDROData_Bathymetry : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(test_HYDROData_Bathymetry);
- CPPUNIT_TEST(testFileImport);
- CPPUNIT_TEST(testCopy);
- CPPUNIT_TEST_SUITE_END();
-
-private:
-
- static bool createTestFile( const QString& theFileName );
-
-public:
-
- void setUp() {}
-
- void tearDown() {}
-
- // checks file importing information
- void testFileImport();
-
- // checks the copy/paste mechanism
- void testCopy();
-
-};
-
-CPPUNIT_TEST_SUITE_REGISTRATION(test_HYDROData_Bathymetry);
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(test_HYDROData_Bathymetry, "HYDROData_Bathymetry");
+++ /dev/null
-// 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_CalculationCase.h>
-
-#include <HYDROData_CalculationCase.h>
-
+++ /dev/null
-// 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 Handle_HYDROData_CalculationCase;
-class QString;
-
-class test_HYDROData_CalculationCase : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(test_HYDROData_CalculationCase);
- CPPUNIT_TEST_SUITE_END();
-
-public:
-
- void setUp() {}
-
- void tearDown() {}
-
-};
-
-CPPUNIT_TEST_SUITE_REGISTRATION(test_HYDROData_CalculationCase);
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(test_HYDROData_CalculationCase, "HYDROData_CalculationCase");
+++ /dev/null
-// 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_Document.h>
-
-#include <HYDROData_Document.h>
-#include <QFile>
-
-void test_HYDROData_Document::testSaveOpen()
-{
- // temporarly created file name (in the current directory)
- const char* aTestFile = "TestDoc.cbf";
- // save
- Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
- CPPUNIT_ASSERT(!aDoc.IsNull());
- // keep some saved information to check after retreive
- aDoc->NewID();
- int anID = aDoc->NewID();
- Data_DocError aStatus = aDoc->Save(aTestFile);
- CPPUNIT_ASSERT(aStatus == DocError_OK);
- aDoc->Close();
- CPPUNIT_ASSERT(!HYDROData_Document::HasDocument(1));
-
- // open
- aStatus = HYDROData_Document::Load(aTestFile, 2);
- CPPUNIT_ASSERT(aStatus == DocError_OK);
- CPPUNIT_ASSERT(HYDROData_Document::HasDocument(2));
- aDoc = HYDROData_Document::Document(2);
- CPPUNIT_ASSERT(!aDoc.IsNull());
- // check that retreived correctly
- CPPUNIT_ASSERT(aDoc->NewID() == anID + 1);
-
- // remove the created file using Qt functionality
- QFile aFile(aTestFile);
- aFile.remove();
-
- aDoc->Close();
-}
-
-void test_HYDROData_Document::testOperations()
-{
- Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
- CPPUNIT_ASSERT(!aDoc.IsNull());
- CPPUNIT_ASSERT(!aDoc->IsOperation());
- CPPUNIT_ASSERT(!aDoc->IsModified());
- // commit operation
- aDoc->StartOperation();
- CPPUNIT_ASSERT(aDoc->IsOperation());
- int anID = aDoc->NewID();
- aDoc->CommitOperation();
- CPPUNIT_ASSERT(!aDoc->IsOperation());
- CPPUNIT_ASSERT(aDoc->IsModified());
- // abort operation
- aDoc->StartOperation();
- CPPUNIT_ASSERT(aDoc->IsOperation());
- int anIDAborted = aDoc->NewID();
- aDoc->AbortOperation();
- CPPUNIT_ASSERT(!aDoc->IsOperation());
- CPPUNIT_ASSERT(aDoc->IsModified());
-
- CPPUNIT_ASSERT(anID + 1 == aDoc->NewID());
-
- aDoc->Close();
-}
-
-void test_HYDROData_Document::testUndoRedo()
-{
- Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
- CPPUNIT_ASSERT(!aDoc.IsNull());
- CPPUNIT_ASSERT(!aDoc->CanUndo());
- CPPUNIT_ASSERT(!aDoc->CanRedo());
- // commit operation
- aDoc->StartOperation();
- CPPUNIT_ASSERT(aDoc->IsOperation());
- int anID = aDoc->NewID();
- aDoc->CommitOperation();
- CPPUNIT_ASSERT(aDoc->CanUndo());
- CPPUNIT_ASSERT(!aDoc->CanRedo());
- CPPUNIT_ASSERT(aDoc->IsModified());
- // undo
- aDoc->Undo();
- CPPUNIT_ASSERT(!aDoc->CanUndo());
- CPPUNIT_ASSERT(aDoc->CanRedo());
- CPPUNIT_ASSERT(anID == aDoc->NewID());
- CPPUNIT_ASSERT(!aDoc->IsModified());
- // redo
- aDoc->Redo();
- CPPUNIT_ASSERT(aDoc->CanUndo());
- CPPUNIT_ASSERT(!aDoc->CanRedo());
- CPPUNIT_ASSERT(aDoc->IsModified());
-
- aDoc->Close();
-}
+++ /dev/null
-// 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_Document : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(test_HYDROData_Document);
- CPPUNIT_TEST(testSaveOpen);
- CPPUNIT_TEST(testOperations);
- CPPUNIT_TEST(testUndoRedo);
- CPPUNIT_TEST_SUITE_END();
-
-private:
-
-public:
-
- void setUp() {}
-
- void tearDown() {}
-
- // checks the save and open document as a file
- void testSaveOpen();
-
- // checks the operations management: open/commit/abort, etc
- void testOperations();
-
- // checks the operations undo/redo
- void testUndoRedo();
-};
-
-CPPUNIT_TEST_SUITE_REGISTRATION(test_HYDROData_Document);
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(test_HYDROData_Document, "HYDROData_Document");
+++ /dev/null
-// 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_Entity.h>
-
-#include <HYDROData_Document.h>
-#include <HYDROData_Entity.h>
-
-#include <QString>
-
-void test_HYDROData_Entity::testName()
-{
- Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
-
- Handle(HYDROData_Entity) anObj = aDoc->CreateObject(KIND_IMAGE); // any object
- static const QString aName("test_name");
- anObj->SetName(aName);
- CPPUNIT_ASSERT_EQUAL(aName.toStdString(), anObj->GetName().toStdString());
-
- aDoc->Close();
-}
-
-void test_HYDROData_Entity::testRemove()
-{
- Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
-
- Handle(HYDROData_Entity) anObj = aDoc->CreateObject(KIND_IMAGE); // any object
- CPPUNIT_ASSERT(!anObj->IsRemoved());
- anObj->Remove();
- CPPUNIT_ASSERT(anObj->IsRemoved());
-
- aDoc->Close();
-}
-
-void test_HYDROData_Entity::testCopy()
-{
- Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
-
- Handle(HYDROData_Entity) anObj = aDoc->CreateObject(KIND_IMAGE); // any object
- static const QString aName("test_name");
- anObj->SetName(aName);
-
- Handle(HYDROData_Entity) aCopy = aDoc->CreateObject(KIND_IMAGE); // object for copy
- CPPUNIT_ASSERT(aCopy->GetName().isEmpty());
- anObj->CopyTo(aCopy, true);
-
- // check the copied object has same name as original
- CPPUNIT_ASSERT_EQUAL(aName.toStdString(), aCopy->GetName().toStdString());
-
- aDoc->Close();
-}
+++ /dev/null
-// 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_Entity : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(test_HYDROData_Entity);
- CPPUNIT_TEST(testName);
- CPPUNIT_TEST(testRemove);
- CPPUNIT_TEST(testCopy);
- CPPUNIT_TEST_SUITE_END();
-
-private:
-
-public:
-
- void setUp() {}
-
- void tearDown() {}
-
- // checks the "name" methods
- void testName();
-
- // checks the remove of object
- void testRemove();
-
- // checks the copying of object
- void testCopy();
-};
-
-CPPUNIT_TEST_SUITE_REGISTRATION(test_HYDROData_Entity);
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(test_HYDROData_Entity, "HYDROData_Entity");
+++ /dev/null
-// 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_Image.h>
-
-#include <HYDROData_Document.h>
-#include <HYDROData_Image.h>
-#include <QPainter>
-
-static QImage TestImage() {
- QImage aPic(50, 40, QImage::Format_RGB32);
- QPainter aPainter(&aPic);
- aPainter.drawEllipse(6, 7, 38, 30);
- aPainter.drawLine(0, 40, 10, 0);
- aPainter.drawLine(10, 0, 25, 35);
- aPainter.drawLine(25, 35, 40, 0);
- aPainter.drawLine(40, 0, 50, 40);
- return aPic;
-}
-
-void test_HYDROData_Image::testQImage()
-{
- Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
-
- Handle(HYDROData_Image) anImage =
- Handle(HYDROData_Image)::DownCast(aDoc->CreateObject(KIND_IMAGE));
- // empty image
- QImage anEmpty = anImage->Image();
- CPPUNIT_ASSERT(anEmpty.isNull());
-
- // prepare Qt Image for testing
- QImage aPic(TestImage());
- anImage->SetImage(aPic);
- QImage aRestored = anImage->Image();
-
- CPPUNIT_ASSERT(!aRestored.isNull());
- //aRestored.save("pic2.bmp");
- CPPUNIT_ASSERT(aPic == aRestored);
-
- aDoc->Close();
-}
-
-void test_HYDROData_Image::testTrsf()
-{
- Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
-
- Handle(HYDROData_Image) anImage =
- Handle(HYDROData_Image)::DownCast(aDoc->CreateObject(KIND_IMAGE));
- // empty trsf
- QTransform anEmpty = anImage->Trsf();
- CPPUNIT_ASSERT(anEmpty.isIdentity());
-
- // prepare Qt transformation for testing
- QTransform aTrsf;
- aTrsf.translate(50, 50);
- aTrsf.rotate(45);
- aTrsf.scale(0.5, 1.0);
-
- anImage->SetTrsf(aTrsf);
- QTransform aRestored = anImage->Trsf();
-
- CPPUNIT_ASSERT(!aRestored.isIdentity());
- CPPUNIT_ASSERT(aTrsf == aRestored);
-
- aDoc->Close();
-}
-
-void test_HYDROData_Image::testReferences()
-{
- Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
-
- Handle(HYDROData_Image) anImage1 =
- Handle(HYDROData_Image)::DownCast(aDoc->CreateObject(KIND_IMAGE));
- Handle(HYDROData_Image) anImage2 =
- Handle(HYDROData_Image)::DownCast(aDoc->CreateObject(KIND_IMAGE));
- Handle(HYDROData_Image) anImage3 =
- Handle(HYDROData_Image)::DownCast(aDoc->CreateObject(KIND_IMAGE));
-
- // check initially there is no references
- CPPUNIT_ASSERT_EQUAL(anImage3->NbReferences(), 0);
-
- // append reference
- anImage3->AppendReference(anImage1);
- CPPUNIT_ASSERT_EQUAL(anImage3->NbReferences(), 1);
- CPPUNIT_ASSERT(IsEqual(anImage3->Reference(0), anImage1));
-
- // change reference
- anImage3->ChangeReference(0, anImage2);
- CPPUNIT_ASSERT_EQUAL(anImage3->NbReferences(), 1);
- CPPUNIT_ASSERT(IsEqual(anImage3->Reference(0), anImage2));
-
- // append one more reference
- anImage3->AppendReference(anImage1);
- CPPUNIT_ASSERT_EQUAL(anImage3->NbReferences(), 2);
- CPPUNIT_ASSERT(IsEqual(anImage3->Reference(0), anImage2));
- CPPUNIT_ASSERT(IsEqual(anImage3->Reference(1), anImage1));
-
- // remove reference
- anImage3->RemoveReference(0);
- CPPUNIT_ASSERT_EQUAL(anImage3->NbReferences(), 1);
- CPPUNIT_ASSERT(IsEqual(anImage3->Reference(0), anImage1));
-
- // remove reference
- anImage3->RemoveReference(0);
- CPPUNIT_ASSERT_EQUAL(anImage3->NbReferences(), 0);
-
- // append two references once again and remove all references
- anImage3->ChangeReference(0, anImage1);
- anImage3->ChangeReference(1, anImage2);
- CPPUNIT_ASSERT_EQUAL(anImage3->NbReferences(), 2);
- CPPUNIT_ASSERT(IsEqual(anImage3->Reference(0), anImage1));
- CPPUNIT_ASSERT(IsEqual(anImage3->Reference(1), anImage2));
- anImage3->ClearReferences();
- CPPUNIT_ASSERT_EQUAL(anImage3->NbReferences(), 0);
-
- aDoc->Close();
-}
-
-void test_HYDROData_Image::testCopy()
-{
- Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
-
- Handle(HYDROData_Image) anImage1 =
- Handle(HYDROData_Image)::DownCast(aDoc->CreateObject(KIND_IMAGE));
- // fill image 1
- anImage1->SetImage(TestImage());
-
- QTransform aTrsf;
- aTrsf.translate(50, 50);
- aTrsf.rotate(45);
- aTrsf.scale(0.5, 1.0);
- anImage1->SetTrsf(aTrsf);
-
- Handle(HYDROData_Image) anImage2 =
- Handle(HYDROData_Image)::DownCast(aDoc->CreateObject(KIND_IMAGE));
-
- anImage1->AppendReference(anImage2);
-
- // copy image to the new one
- Handle(HYDROData_Image) anImage3 =
- Handle(HYDROData_Image)::DownCast(aDoc->CreateObject(KIND_IMAGE));
- anImage1->CopyTo(anImage3, true);
-
- // check all fields are correctly copied
- CPPUNIT_ASSERT(anImage1->Image() == anImage3->Image());
- CPPUNIT_ASSERT(anImage1->Trsf() == anImage3->Trsf());
- CPPUNIT_ASSERT_EQUAL(anImage3->NbReferences(), 1);
- CPPUNIT_ASSERT(IsEqual(anImage3->Reference(0), anImage2));
-
- aDoc->Close();
-}
+++ /dev/null
-// 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_Image : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(test_HYDROData_Image);
- CPPUNIT_TEST(testQImage);
- CPPUNIT_TEST(testTrsf);
- CPPUNIT_TEST(testReferences);
- CPPUNIT_TEST(testCopy);
- CPPUNIT_TEST_SUITE_END();
-
-private:
-
-public:
-
- void setUp() {}
-
- void tearDown() {}
-
- // checks save/restore QImages information
- void testQImage();
-
- // checks the transformations
- void testTrsf();
-
- // checks the references management
- void testReferences();
-
- // checks the image properties copy/paste
- void testCopy();
-};
-
-CPPUNIT_TEST_SUITE_REGISTRATION(test_HYDROData_Image);
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(test_HYDROData_Image, "HYDROData_Image");
+++ /dev/null
-// 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_Iterator.h>
-
-#include <HYDROData_Document.h>
-#include <HYDROData_Iterator.h>
-
-#include <QString>
-
-void test_HYDROData_Iterator::testOneKind()
-{
- static const QString aName1("test_name1");
- static const QString aName2("test_name2");
- Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
-
- Handle(HYDROData_Entity) anObj = aDoc->CreateObject(KIND_IMAGE); // image object
- anObj->SetName(aName1);
- // first HYDROData_Entity must be destroyed because there is no hander pointer naymore
- anObj = aDoc->CreateObject(KIND_IMAGE); // second image object
- anObj->SetName(aName2);
-
- HYDROData_Iterator anIter(aDoc, KIND_IMAGE);
- CPPUNIT_ASSERT(anIter.More());
- CPPUNIT_ASSERT(!anIter.Current().IsNull());
- CPPUNIT_ASSERT_EQUAL(aName1.toStdString(), anIter.Current()->GetName().toStdString());
-
- anIter.Next();
- CPPUNIT_ASSERT(anIter.More());
- CPPUNIT_ASSERT(!anIter.Current().IsNull());
- CPPUNIT_ASSERT_EQUAL(aName2.toStdString(), anIter.Current()->GetName().toStdString());
-
- anIter.Next();
- CPPUNIT_ASSERT(!anIter.More());
-
- aDoc->Close();
-}
-
-void test_HYDROData_Iterator::testAllKinds()
-{
- static const QString aName1("test_name1");
- static const QString aName2("test_name2");
- Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
-
- Handle(HYDROData_Entity) anObj = aDoc->CreateObject(KIND_IMAGE); // image object
- anObj->SetName(aName1);
- // first HYDROData_Entity must be destroyed because there is no hander pointer naymore
- anObj = aDoc->CreateObject(KIND_IMAGE); // second image object
- anObj->SetName(aName2);
-
- HYDROData_Iterator anIter(aDoc, KIND_UNKNOWN);
- CPPUNIT_ASSERT(anIter.More());
- CPPUNIT_ASSERT(!anIter.Current().IsNull());
- CPPUNIT_ASSERT_EQUAL(aName1.toStdString(), anIter.Current()->GetName().toStdString());
-
- anIter.Next();
- CPPUNIT_ASSERT(anIter.More());
- CPPUNIT_ASSERT(!anIter.Current().IsNull());
- CPPUNIT_ASSERT_EQUAL(aName2.toStdString(), anIter.Current()->GetName().toStdString());
-
- anIter.Next();
- CPPUNIT_ASSERT(!anIter.More());
-
- aDoc->Close();
-}
+++ /dev/null
-// 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_Iterator : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(test_HYDROData_Iterator);
- CPPUNIT_TEST(testOneKind);
- CPPUNIT_TEST(testAllKinds);
- CPPUNIT_TEST_SUITE_END();
-
-private:
-
-public:
-
- void setUp() {}
-
- void tearDown() {}
-
- // checks iteration by one kind
- void testOneKind();
-
- // checks iteration by all kinds
- void testAllKinds();
-};
-
-CPPUNIT_TEST_SUITE_REGISTRATION(test_HYDROData_Iterator);
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(test_HYDROData_Iterator, "HYDROData_Iterator");
+++ /dev/null
-// 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/TestFactoryRegistry.h>
-#include <cppunit/CompilerOutputter.h>
-#include <cppunit/TestResult.h>
-#include <cppunit/TestResultCollector.h>
-#include <cppunit/TestRunner.h>
-#include <cppunit/TextTestProgressListener.h>
-#include <stdexcept>
-
-int
- main( int argc, char* argv[] )
-{
- std::string testPath = (argc > 1) ? std::string(argv[1]) : "";
-
- // Create the event manager and test controller
- CppUnit::TestResult controller;
-
- // Add a listener that colllects test result
- CppUnit::TestResultCollector result;
- controller.addListener( &result );
-
- // Add a listener that print dots as test run.
- CppUnit::TextTestProgressListener progress;
- controller.addListener( &progress );
-
- CppUnit::TestFactoryRegistry& registry =
- CppUnit::TestFactoryRegistry::getRegistry();
- // Add the top suite to the test runner
- CppUnit::TestRunner runner;
- runner.addTest( registry.makeTest() );
- try
- {
- std::cout << "Running " << testPath;
- runner.run( controller, testPath );
-
- std::cerr << std::endl;
-
- // Print test in a compiler compatible format.
- CppUnit::CompilerOutputter outputter( &result, std::cerr );
- outputter.write();
- }
- catch ( std::invalid_argument &e ) // Test path not resolved
- {
- std::cerr << std::endl
- << "ERROR: " << e.what()
- << std::endl;
- return 0;
- }
-
- return result.wasSuccessful() ? 0 : 1;
-}
+++ /dev/null
-// 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_OperationsFactory.h>
-
-#include <HYDROData_Document.h>
-#include <HYDROData_Image.h>
-#include <HYDROData_PolylineXY.h>
-#include <HYDROData_OperationsFactory.h>
-
-#include <ImageComposer_CropOperator.h>
-
-#include <gp_XY.hxx>
-
-#include <QPainter>
-
-void test_HYDROData_OperationsFactory::testCreate()
-{
- Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
-
- HYDROData_OperationsFactory* aFactory = HYDROData_OperationsFactory::Factory();
- CPPUNIT_ASSERT(aFactory);
- Handle(HYDROData_Image) anImage = aFactory->CreateImage(aDoc, NULL);
- CPPUNIT_ASSERT(!anImage.IsNull());
- CPPUNIT_ASSERT(anImage->Image().isNull());
-
- aDoc->Close();
-}
-
-static QImage TestImage() {
- QImage aPic(50, 40, QImage::Format_RGB32);
- aPic.fill(Qt::white);
- QPainter aPainter(&aPic);
- aPainter.drawEllipse(6, 7, 38, 30);
- aPainter.drawLine(0, 40, 10, 0);
- aPainter.drawLine(10, 0, 25, 35);
- aPainter.drawLine(25, 35, 40, 0);
- aPainter.drawLine(40, 0, 50, 40);
- return aPic;
-}
-
-void test_HYDROData_OperationsFactory::testCrop()
-{
- Handle(HYDROData_Document) aDoc = HYDROData_Document::Document( 1 );
- HYDROData_OperationsFactory* aFactory = HYDROData_OperationsFactory::Factory();
-
- // prepare the original image and crop-path
- Handle(HYDROData_Image) anOriImage =
- Handle(HYDROData_Image)::DownCast( aDoc->CreateObject( KIND_IMAGE ) );
-
- QImage aTestImage = TestImage();
- anOriImage->SetImage( aTestImage );
-
- Handle(HYDROData_PolylineXY) aCropPolyline =
- Handle(HYDROData_PolylineXY)::DownCast( aDoc->CreateObject( KIND_POLYLINEXY ) );
-
- aCropPolyline->AddSection( "", HYDROData_PolylineXY::SECTION_POLYLINE, true );
-
- aCropPolyline->AddPoint( 0, HYDROData_PolylineXY::Point( 25, 0 ) );
- aCropPolyline->AddPoint( 0, HYDROData_PolylineXY::Point( 0, 20 ) );
- aCropPolyline->AddPoint( 0, HYDROData_PolylineXY::Point( 25, 40 ) );
- aCropPolyline->AddPoint( 0, HYDROData_PolylineXY::Point( 50, 20 ) );
-
- // prepare Composer Operation
- ImageComposer_Operator* aCropOp =
- aFactory->Operator( ImageComposer_CropOperator::Type() );
-
- CPPUNIT_ASSERT( aCropOp );
-
- aCropOp->setArgs( Qt::red );
-
- // create crop - image
- Handle(HYDROData_Image) aCropImage = aFactory->CreateImage( aDoc, aCropOp );
- CPPUNIT_ASSERT( !aCropImage.IsNull() );
-
- aCropImage->AppendReference( anOriImage );
- aCropImage->AppendReference( aCropPolyline );
- aCropImage->Update();
-
- // check crop operation was performed
- CPPUNIT_ASSERT( !aCropImage->Image().isNull() );
- CPPUNIT_ASSERT( aCropImage->Image() != aTestImage );
-
- aDoc->Close();
-}
+++ /dev/null
-// 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_OperationsFactory : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(test_HYDROData_OperationsFactory);
- CPPUNIT_TEST(testCreate);
- CPPUNIT_TEST(testCrop);
- CPPUNIT_TEST_SUITE_END();
-
-private:
-
-public:
-
- void setUp() {}
-
- void tearDown() {}
-
- // checks creation of images using null operators
- void testCreate();
-
- // checks creation of images using crop operator
- void testCrop();
-};
-
-CPPUNIT_TEST_SUITE_REGISTRATION(test_HYDROData_OperationsFactory);
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(test_HYDROData_OperationsFactory, "HYDROData_OperationsFactory");
+++ /dev/null
-// 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_PolylineXY.h>
-
-#include <HYDROData_Document.h>
-#include <HYDROData_PolylineXY.h>
-
-#include <QList>
-#include <QPointF>
-
-void test_HYDROData_PolylineXY::testPolyline()
-{
- Handle(HYDROData_Document) aDoc = HYDROData_Document::Document( 1 );
-
- Handle(HYDROData_PolylineXY) aPolyline =
- Handle(HYDROData_PolylineXY)::DownCast(aDoc->CreateObject(KIND_POLYLINEXY));
-
- aPolyline->AddSection( "Section_1", HYDROData_PolylineXY::SECTION_POLYLINE, false );
- aPolyline->AddSection( "Section_2", HYDROData_PolylineXY::SECTION_SPLINE, true );
-
- int aNbSections = aPolyline->NbSections();
- CPPUNIT_ASSERT( aNbSections == 2 );
-
- NCollection_Sequence<TCollection_AsciiString> aSectNames;
- NCollection_Sequence<HYDROData_PolylineXY::SectionType> aSectTypes;
- NCollection_Sequence<bool> aSectClosures;
- aPolyline->GetSections( aSectNames, aSectTypes, aSectClosures );
-
- CPPUNIT_ASSERT( aSectNames.Value( 0 ) == "Section_1" );
- CPPUNIT_ASSERT( aSectTypes.Value( 0 ) == HYDROData_PolylineXY::SECTION_POLYLINE );
- CPPUNIT_ASSERT( aSectClosures.Value( 0 ) == false );
-
- CPPUNIT_ASSERT( aSectNames.Value( 1 ) == "Section_2" );
- CPPUNIT_ASSERT( aSectTypes.Value( 1 ) == HYDROData_PolylineXY::SECTION_SPLINE );
- CPPUNIT_ASSERT( aSectClosures.Value( 1 ) == true );
-
- aDoc->Close();
-}
-
-
-void test_HYDROData_PolylineXY::testCopy()
-{
- Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
- Handle(HYDROData_PolylineXY) aPolyline1 =
- Handle(HYDROData_PolylineXY)::DownCast(aDoc->CreateObject(KIND_POLYLINEXY));
-
-
-// aPolyline1->setPoints(aPoints);
-
- Handle(HYDROData_PolylineXY) aPolyline2 =
- Handle(HYDROData_PolylineXY)::DownCast(aDoc->CreateObject(KIND_POLYLINEXY));
-
- aPolyline1->CopyTo(aPolyline2, true);
-
-
- aDoc->Close();
-}
+++ /dev/null
-// 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_PolylineXY : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(test_HYDROData_PolylineXY);
- CPPUNIT_TEST(testPolyline);
- CPPUNIT_TEST(testCopy);
- CPPUNIT_TEST_SUITE_END();
-
-private:
-
-public:
-
- void setUp() {}
-
- void tearDown() {}
-
- // checks save/restore QImages information
- void testPolyline();
-
- // checks the image properties copy/paste
- void testCopy();
-};
-
-CPPUNIT_TEST_SUITE_REGISTRATION(test_HYDROData_PolylineXY);
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(test_HYDROData_PolylineXY, "HYDROData_PolylineXY");
+++ /dev/null
-// 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_Profile.h>
-
-#include <HYDROData_Document.h>
-#include <HYDROData_Tool.h>
-#include <HYDROData_Profile.h>
-#include <HYDROData_Iterator.h>
-
-#include <TopoDS_Shape.hxx>
-
-#include <gp_XY.hxx>
-#include <gp_XYZ.hxx>
-
-#include <QDir>
-#include <QFile>
-#include <QTextStream>
-
-bool test_HYDROData_Profile::createTestFile( const QString& theFileName,
- const bool theIsParametric )
-{
- QFile aTmpFile( theFileName );
- if ( !aTmpFile.open( QIODevice::WriteOnly | QIODevice::Text ) )
- return false;
-
- if ( theIsParametric )
- {
- QTextStream anOutStream( &aTmpFile );
-
- anOutStream << "0 182.15 \n";
- anOutStream << "4 181.95 \n";
- anOutStream << "10.18 181.63 \n";
- anOutStream << "14.75 179.27 \n";
- anOutStream << "19.75 178.87 \n";
-
- anOutStream << "\n";
-
- anOutStream << "-5 50 \n";
- anOutStream << "0 15 \n";
- anOutStream << "10.1 10 \n";
- anOutStream << "20 20 \n";
- anOutStream << "250 0.005 \n";
- }
- else
- {
- QTextStream anOutStream( &aTmpFile );
-
- anOutStream << "1040499.17 6788618.13 182.15 \n";
- anOutStream << "1040503.12 6788618.79 181.95 \n";
- anOutStream << "1040509.21 6788619.81 181.63 \n";
- anOutStream << "1040513.72 6788620.56 179.27 \n";
- anOutStream << "1040518.65 6788621.38 178.87 \n";
- }
-
- aTmpFile.close();
-
- return true;
-}
-
-void test_HYDROData_Profile::testFileImport()
-{
- Handle(HYDROData_Document) aDoc = HYDROData_Document::Document( 1 );
-
- QString aParamFileName = QDir::tempPath() + QDir::separator() + "parametric.pa";
- QString aGeorefFileName = QDir::tempPath() + QDir::separator() + "georef.pa";
- if ( !createTestFile( aParamFileName, true ) || !createTestFile( aGeorefFileName, false ) )
- return; // No file has been created
-
- TCollection_AsciiString aFileName( aParamFileName.toStdString().c_str() );
-
- CPPUNIT_ASSERT( HYDROData_Profile::ImportFromFile( aDoc, aFileName ) );
-
- int aProfileCount = 0;
- HYDROData_Iterator aDocIter( aDoc, KIND_PROFILE );
- for ( ; aDocIter.More(); aDocIter.Next() )
- {
- Handle(HYDROData_Profile) aProfile =
- Handle(HYDROData_Profile)::DownCast( aDocIter.Current() );
- if ( aProfile.IsNull() )
- continue;
-
- CPPUNIT_ASSERT( aProfile->IsValid() == false );
- CPPUNIT_ASSERT( aProfile->NbPoints() == 5 );
-
- aProfileCount++;
- }
-
- CPPUNIT_ASSERT( aProfileCount == 2 );
-
- Handle(HYDROData_Profile) aGeorefProfile =
- Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) );
-
- aFileName = TCollection_AsciiString( aGeorefFileName.toStdString().c_str() );
- CPPUNIT_ASSERT( aGeorefProfile->ImportFromFile( aFileName ) );
-
- // Check validity of imported profile
- CPPUNIT_ASSERT( aGeorefProfile->IsValid() );
-
- CPPUNIT_ASSERT( aGeorefProfile->GetTopShape().IsNull() == false );
-
- aGeorefProfile->UpdateShape3D();
- CPPUNIT_ASSERT( aGeorefProfile->GetShape3D().IsNull() == false );
-
- HYDROData_Profile::ProfilePoints aProfilePoints = aGeorefProfile->GetProfilePoints();
- CPPUNIT_ASSERT( aProfilePoints.Length() == 5 );
-
- HYDROData_Profile::ProfilePoint aProfilePoint = aProfilePoints.Value( 3 );
- CPPUNIT_ASSERT( ValuesEquals( aProfilePoint.X(), 1040509.21 ) );
- CPPUNIT_ASSERT( ValuesEquals( aProfilePoint.Y(), 6788619.81 ) );
- CPPUNIT_ASSERT( ValuesEquals( aProfilePoint.Z(), 181.63 ) );
-
- aDoc->Close();
-}
-
-
-void test_HYDROData_Profile::testCopy()
-{
- Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
-
- Handle(HYDROData_Profile) aProfile1 =
- Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) );
-
- QString aFileName = QDir::tempPath() + QDir::separator() + "georef.pa";
-
- bool anIsFileCreated = createTestFile( aFileName, false );
-
- if ( anIsFileCreated )
- {
- TCollection_AsciiString anAsciiFileName( aFileName.toStdString().c_str() );
- CPPUNIT_ASSERT( aProfile1->ImportFromFile( anAsciiFileName ) );
-
- CPPUNIT_ASSERT( aProfile1->IsValid() );
- CPPUNIT_ASSERT( aProfile1->NbPoints() == 5 );
- }
-
- Handle(HYDROData_Profile) aProfile2 =
- Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) );
-
- aProfile1->CopyTo( aProfile2 );
-
- if ( anIsFileCreated )
- {
- CPPUNIT_ASSERT( aProfile2->IsValid() );
- CPPUNIT_ASSERT( aProfile2->NbPoints() == 5 );
- }
-
- aDoc->Close();
-}
+++ /dev/null
-// 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 Handle_HYDROData_Profile;
-class QString;
-
-class test_HYDROData_Profile : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(test_HYDROData_Profile);
- CPPUNIT_TEST(testFileImport);
- CPPUNIT_TEST(testCopy);
- CPPUNIT_TEST_SUITE_END();
-
-private:
-
- static bool createTestFile( const QString& theFileName,
- const bool theIsParametric );
-
-public:
-
- void setUp() {}
-
- void tearDown() {}
-
- // checks file importing information
- void testFileImport();
-
- // checks the copy/paste mechanism
- void testCopy();
-
-};
-
-CPPUNIT_TEST_SUITE_REGISTRATION(test_HYDROData_Profile);
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(test_HYDROData_Profile, "HYDROData_Profile");
+++ /dev/null
-// 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_StricklerTable.h>
-#include <HYDROData_Document.h>
-
-void test_HYDROData_StricklerTable::testImport()
-{
- Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
-
- Handle(HYDROData_Entity) anObj = aDoc->CreateObject( KIND_STRICKLER_TABLE );
- TCollection_AsciiString aFileName = "test_name";
-
- aDoc->Close();
-}
+++ /dev/null
-// 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
-//
-
-#ifdef WIN32
- #pragma warning( disable: 4251 )
-#endif
-
-#include <cppunit/extensions/HelperMacros.h>
-
-class test_HYDROData_StricklerTable : public CppUnit::TestFixture
-{
- CPPUNIT_TEST_SUITE( test_HYDROData_StricklerTable );
- CPPUNIT_TEST( testImport );
- CPPUNIT_TEST_SUITE_END();
-
-public:
- void testImport();
-};
-
-CPPUNIT_TEST_SUITE_REGISTRATION( test_HYDROData_StricklerTable );
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( test_HYDROData_StricklerTable, "HYDROData_StricklerTable" );
-
-#ifdef WIN32
- #pragma warning( default: 4251 )
-#endif
FILE(GLOB GUITXT_DATA "${CMAKE_CURRENT_SOURCE_DIR}/resources/*.txt")
SET(GUI_DATA ${GUIPNG_DATA} ${GUIXML_DATA} ${GUITXT_DATA})
INSTALL(FILES ${GUI_DATA} DESTINATION ${SALOME_HYDRO_INSTALL_RES_DATA})
-
-# tests
-if(SALOME_BUILD_TESTS)
-
- set(TEST_HEADERS
- test_HYDROGUI_ListModel.h
- )
-
- set(TEST_SOURCES
- test_HYDROGUI_Main.cxx
- test_HYDROGUI_ListModel.cxx
- )
-
- set(TEST_EXE test_HYDROGUI)
- include(../../CMake/CPPUnitTests.cmake)
- target_link_libraries(test_HYDROGUI ${CPPUNIT_LIBRARIES} HYDROData HYDROGUI)
-
- INSTALL(TARGETS test_HYDROGUI EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_BINS})
-
-endif(SALOME_BUILD_TESTS)
-
#ifndef HYDROGUI_H
#define HYDROGUI_H
-#if defined HYDROGUI_EXPORTS
-#if defined WNT
-#define HYDRO_EXPORT __declspec( dllexport )
+#ifdef HYDROGUI_STATIC
+ #define HYDRO_EXPORT
#else
-#define HYDRO_EXPORT
-#endif
-#else
-#if defined WNT
-#define HYDRO_EXPORT __declspec( dllimport )
-#else
-#define HYDRO_EXPORT
-#endif
+ #if defined HYDROGUI_EXPORTS
+ #if defined WNT
+ #define HYDRO_EXPORT __declspec( dllexport )
+ #else
+ #define HYDRO_EXPORT
+ #endif
+ #else
+ #if defined WNT
+ #define HYDRO_EXPORT __declspec( dllimport )
+ #else
+ #define HYDRO_EXPORT
+ #endif
+ #endif
#endif
#ifdef WNT
*/
class HYDRO_EXPORT HYDROGUI_ListModel : public QAbstractListModel
{
- Q_OBJECT
-
public:
enum OpType { Top, Up, Down, Bottom, DragAndDrop };
+++ /dev/null
-// 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
-//
-
-#undef HYDROGUI_EXPORTS
-
-#include <test_HYDROGUI_ListModel.h>
-#include <HYDROData_Document.h>
-#include <HYDROGUI_ListModel.h>
-
-Handle_HYDROData_Document GetDocument()
-{
- return HYDROData_Document::Document( 0 );
-}
-
-HYDROGUI_ListModel::Object2VisibleList CreateTestObjects( int theObjCount )
-{
- HYDROGUI_ListModel::Object2VisibleList anObjects;
-
- for( int i=0; i<theObjCount; i++ )
- {
- Handle_HYDROData_Entity anObj = GetDocument()->CreateObject( KIND_IMMERSIBLE_ZONE );
-
- std::string aName = " ";
- aName[0] = 'A' + i;
- anObj->SetName( QString::fromStdString( aName ) );
-
- bool isVisible = i%2==0;
-
- anObjects.append( HYDROGUI_ListModel::Object2Visible( anObj, isVisible ) );
- }
- return anObjects;
-}
-
-std::string test_HYDROGUI_ListModel::GetObjects( HYDROGUI_ListModel* theModel ) const
-{
- std::string anObjects;
- for( int i=0, n=theModel->myObjects.size(); i<n; i++ )
- {
- std::string anObjName = theModel->myObjects[i].first->GetName().toStdString();
- if( theModel->isObjectVisible( i ) )
- anObjName = "*" + anObjName;
- if( i>0 )
- anObjects += ", ";
- anObjects += anObjName;
- }
- return anObjects;
-}
-
-/**
- Test move up algorithm.
-*/
-void test_HYDROGUI_ListModel::testMoveUp()
-{
- HYDROGUI_ListModel* aModel = new HYDROGUI_ListModel();
- aModel->setObjects( CreateTestObjects( 6 ) );
- const HYDROGUI_ListModel::OpType anUp = HYDROGUI_ListModel::Up;
-
- // 0. Check the initial state
- CPPUNIT_ASSERT_EQUAL( std::string( "*A, B, *C, D, *E, F" ), GetObjects( aModel ) );
-
- // 1. [ *A ] / ALL OBJECTS
- aModel->move( QList<int>() << 0, anUp, false );
- CPPUNIT_ASSERT_EQUAL( std::string( "*A, B, *C, D, *E, F" ), GetObjects( aModel ) );
-
- // 2. [ *A, B ] / ALL OBJECTS
- aModel->move( QList<int>() << 0 << 1, anUp, false );
- CPPUNIT_ASSERT_EQUAL( std::string( "*A, B, *C, D, *E, F" ), GetObjects( aModel ) );
-
- // 3. [ *A, *C ] / ALL OBJECTS
- aModel->move( QList<int>() << 0 << 2, anUp, false );
- CPPUNIT_ASSERT_EQUAL( std::string( "*A, B, *C, D, *E, F" ), GetObjects( aModel ) );
-
- // 4. [ *A, F ] / ALL OBJECTS
- aModel->move( QList<int>() << 0 << 5, anUp, false );
- CPPUNIT_ASSERT_EQUAL( std::string( "*A, B, *C, D, *E, F" ), GetObjects( aModel ) );
-
- // 5. [ F ] X 6 times / ALL OBJECTS
- aModel->move( QList<int>() << 5, anUp, false );
- CPPUNIT_ASSERT_EQUAL( std::string( "*A, B, *C, D, F, *E" ), GetObjects( aModel ) );
- aModel->move( QList<int>() << 4, anUp, false );
- CPPUNIT_ASSERT_EQUAL( std::string( "*A, B, *C, F, D, *E" ), GetObjects( aModel ) );
- aModel->move( QList<int>() << 3, anUp, false );
- CPPUNIT_ASSERT_EQUAL( std::string( "*A, B, F, *C, D, *E" ), GetObjects( aModel ) );
- aModel->move( QList<int>() << 2, anUp, false );
- CPPUNIT_ASSERT_EQUAL( std::string( "*A, F, B, *C, D, *E" ), GetObjects( aModel ) );
- aModel->move( QList<int>() << 1, anUp, false );
- CPPUNIT_ASSERT_EQUAL( std::string( "F, *A, B, *C, D, *E" ), GetObjects( aModel ) );
- aModel->move( QList<int>() << 0, anUp, false );
- CPPUNIT_ASSERT_EQUAL( std::string( "F, *A, B, *C, D, *E" ), GetObjects( aModel ) );
-
- // 6. [ *A, B ] / ALL OBJECTS
- aModel->move( QList<int>() << 1 << 2, anUp, false );
- CPPUNIT_ASSERT_EQUAL( std::string( "*A, B, F, *C, D, *E" ), GetObjects( aModel ) );
-
- // 7. [ B, *C, *E ] / ALL OBJECTS
- aModel->move( QList<int>() << 1 << 3 << 5, anUp, false );
- CPPUNIT_ASSERT_EQUAL( std::string( "B, *A, *C, F, *E, D" ), GetObjects( aModel ) );
-
- // 8. [ *A, *C, F, *E, D ] / ALL OBJECTS
- aModel->move( QList<int>() << 1 << 2 << 3 << 4 << 5, anUp, false );
- CPPUNIT_ASSERT_EQUAL( std::string( "*A, *C, F, *E, D, B" ), GetObjects( aModel ) );
-
- // 9. [ *E ] / VISIBLE OBJECTS
- aModel->move( QList<int>() << 3, anUp, true );
- CPPUNIT_ASSERT_EQUAL( std::string( "*A, *E, *C, F, D, B" ), GetObjects( aModel ) );
-
- // 10. [ *E, *C ] / VISIBLE OBJECTS
- aModel->move( QList<int>() << 1 << 2, anUp, true );
- CPPUNIT_ASSERT_EQUAL( std::string( "*E, *C, *A, F, D, B" ), GetObjects( aModel ) );
-
- // 11. [ *A, F ] / ALL OBJECTS
- aModel->move( QList<int>() << 2 << 3, anUp, false );
- CPPUNIT_ASSERT_EQUAL( std::string( "*E, *A, F, *C, D, B" ), GetObjects( aModel ) );
-
- // 12. [ *A, *C ] / VISIBLE OBJECTS
- aModel->move( QList<int>() << 1 << 3, anUp, true );
- CPPUNIT_ASSERT_EQUAL( std::string( "*A, *C, *E, F, D, B" ), GetObjects( aModel ) );
-
- // 13. [] / ALL OBJECTS
- aModel->move( QList<int>(), anUp, false );
- CPPUNIT_ASSERT_EQUAL( std::string( "*A, *C, *E, F, D, B"), GetObjects( aModel ) );
-
- // 14. [ *A, *C, *E, F, D, B ] / ALL OBJECTS
- aModel->move( QList<int>() << 0 << 1 << 2 << 3 << 4 << 5, anUp, false );
- CPPUNIT_ASSERT_EQUAL( std::string( "*A, *C, *E, F, D, B"), GetObjects( aModel ) );
-
- delete aModel;
-}
-
-/**
- Test move on top algorithm.
-*/
-void test_HYDROGUI_ListModel::testMoveOnTop()
-{
- HYDROGUI_ListModel* aModel = new HYDROGUI_ListModel();
- aModel->setObjects( CreateTestObjects( 6 ) );
- const HYDROGUI_ListModel::OpType aTop = HYDROGUI_ListModel::Top;
-
- // 0. Check the initial state
- CPPUNIT_ASSERT_EQUAL( std::string( "*A, B, *C, D, *E, F" ), GetObjects( aModel ) );
-
- // 1. [ *A ] / ALL OBJECTS
- aModel->move( QList<int>() << 0, aTop, false );
- CPPUNIT_ASSERT_EQUAL( std::string( "*A, B, *C, D, *E, F" ), GetObjects( aModel ) );
-
- // 2. [ *A ] / VISIBLE OBJECTS
- aModel->move( QList<int>() << 0, aTop, true );
- CPPUNIT_ASSERT_EQUAL( std::string( "*A, B, *C, D, *E, F" ), GetObjects( aModel ) );
-
- // 3. [ F ] / ALL OBJECTS
- aModel->move( QList<int>() << 5, aTop, false );
- CPPUNIT_ASSERT_EQUAL( std::string( "F, *A, B, *C, D, *E" ), GetObjects( aModel ) );
-
- // 4. [ *E ] / VISIBLE OBJECTS
- aModel->move( QList<int>() << 5, aTop, true );
- CPPUNIT_ASSERT_EQUAL( std::string( "*E, F, *A, B, *C, D" ), GetObjects( aModel ) );
-
- // 5. [ *E, F ] / ALL OBJECTS
- aModel->move( QList<int>() << 0 << 1, aTop, false );
- CPPUNIT_ASSERT_EQUAL( std::string( "*E, F, *A, B, *C, D" ), GetObjects( aModel ) );
-
- // 6. [ *E, *A ] / ALL OBJECTS
- aModel->move( QList<int>() << 0 << 2, aTop, false );
- CPPUNIT_ASSERT_EQUAL( std::string( "*E, *A, F, B, *C, D" ), GetObjects( aModel ) );
-
- // 7. [ *A, F, *C ] / ALL OBJECTS
- aModel->move( QList<int>() << 1 << 2 << 4, aTop, false );
- CPPUNIT_ASSERT_EQUAL( std::string( "*A, F, *C, *E, B, D" ), GetObjects( aModel ) );
-
- // 8. [ F, *C, *E, B, D ] / ALL OBJECTS
- aModel->move( QList<int>() << 1 << 2 << 3 << 4 << 5, aTop, false );
- CPPUNIT_ASSERT_EQUAL( std::string( "F, *C, *E, B, D, *A" ), GetObjects( aModel ) );
-
- // 9. [] / ALL OBJECTS
- aModel->move( QList<int>(), aTop, false );
- CPPUNIT_ASSERT_EQUAL( std::string( "F, *C, *E, B, D, *A" ), GetObjects( aModel ) );
-
- // 10. [*F, *C, *E, B, D, *A] / ALL OBJECTS
- aModel->move( QList<int>() << 0 << 1 << 2 << 3 << 4 << 5, aTop, false );
- CPPUNIT_ASSERT_EQUAL( std::string( "F, *C, *E, B, D, *A" ), GetObjects( aModel ) );
-
- delete aModel;
-}
-
-/**
- Test move down algorithm.
-*/
-void test_HYDROGUI_ListModel::testMoveDown()
-{
- HYDROGUI_ListModel* aModel = new HYDROGUI_ListModel();
- aModel->setObjects( CreateTestObjects( 6 ) );
- const HYDROGUI_ListModel::OpType aDown = HYDROGUI_ListModel::Down;
-
- // 0. Check the initial state
- CPPUNIT_ASSERT_EQUAL( std::string( "*A, B, *C, D, *E, F" ), GetObjects( aModel ) );
-
- // 1. [ F ] / ALL OBJECTS
- aModel->move( QList<int>() << 5, aDown, false );
- CPPUNIT_ASSERT_EQUAL( std::string( "*A, B, *C, D, *E, F" ), GetObjects( aModel ) );
-
- // 2. [ *E, F ] / ALL OBJECTS
- aModel->move( QList<int>() << 4 << 5, aDown, false );
- CPPUNIT_ASSERT_EQUAL( std::string( "*A, B, *C, D, *E, F" ), GetObjects( aModel ) );
-
- // 3. [ D, F ] / ALL OBJECTS
- aModel->move( QList<int>() << 3 << 5, aDown, false );
- CPPUNIT_ASSERT_EQUAL( std::string( "*A, B, *C, D, *E, F" ), GetObjects( aModel ) );
-
- // 4. [ *A, F ] / ALL OBJECTS
- aModel->move( QList<int>() << 0 << 5, aDown, false );
- CPPUNIT_ASSERT_EQUAL( std::string( "*A, B, *C, D, *E, F" ), GetObjects( aModel ) );
-
- // 5. [ *A ] X 6 times / ALL OBJECTS
- aModel->move( QList<int>() << 0, aDown, false );
- CPPUNIT_ASSERT_EQUAL( std::string( "B, *A, *C, D, *E, F" ), GetObjects( aModel ) );
- aModel->move( QList<int>() << 1, aDown, false );
- CPPUNIT_ASSERT_EQUAL( std::string( "B, *C, *A, D, *E, F" ), GetObjects( aModel ) );
- aModel->move( QList<int>() << 2, aDown, false );
- CPPUNIT_ASSERT_EQUAL( std::string( "B, *C, D, *A, *E, F" ), GetObjects( aModel ) );
- aModel->move( QList<int>() << 3, aDown, false );
- CPPUNIT_ASSERT_EQUAL( std::string( "B, *C, D, *E, *A, F" ), GetObjects( aModel ) );
- aModel->move( QList<int>() << 4, aDown, false );
- CPPUNIT_ASSERT_EQUAL( std::string( "B, *C, D, *E, F, *A" ), GetObjects( aModel ) );
- aModel->move( QList<int>() << 5, aDown, false );
- CPPUNIT_ASSERT_EQUAL( std::string( "B, *C, D, *E, F, *A" ), GetObjects( aModel ) );
-
- // 6. [ *E, *F ] / ALL OBJECTS
- aModel->move( QList<int>() << 3 << 4, aDown, false );
- CPPUNIT_ASSERT_EQUAL( std::string( "B, *C, D, *A, *E, F" ), GetObjects( aModel ) );
-
- // 7. [ B, D, *E ] / ALL OBJECTS
- aModel->move( QList<int>() << 0 << 2 << 4, aDown, false );
- CPPUNIT_ASSERT_EQUAL( std::string( "*C, B, *A, D, F, *E" ), GetObjects( aModel ) );
-
- // 8. [ *C, B, *A, D, F ] / ALL OBJECTS
- aModel->move( QList<int>() << 0 << 1 << 2 << 3 << 4, aDown, false );
- CPPUNIT_ASSERT_EQUAL( std::string( "*E, *C, B, *A, D, F" ), GetObjects( aModel ) );
-
- // 9. [ *C ] / VISIBLE OBJECTS
- aModel->move( QList<int>() << 1, aDown, true );
- CPPUNIT_ASSERT_EQUAL( std::string( "*E, B, *A, *C, D, F" ), GetObjects( aModel ) );
-
- // 10. [ *E, *A ] / VISIBLE OBJECTS
- aModel->move( QList<int>() << 0 << 2, aDown, true );
- CPPUNIT_ASSERT_EQUAL( std::string( "B, *C, *E, *A, D, F" ), GetObjects( aModel ) );
-
- // 11. [ *E, *A ] / VISIBLE OBJECTS
- aModel->move( QList<int>() << 2 << 3, aDown, true );
- CPPUNIT_ASSERT_EQUAL( std::string( "B, *C, *E, *A, D, F" ), GetObjects( aModel ) );
-
- // 12. [ *C, *E, *A ] / VISIBLE OBJECTS
- aModel->move( QList<int>() << 1 << 2 << 3, aDown, true );
- CPPUNIT_ASSERT_EQUAL( std::string( "B, *C, *E, *A, D, F" ), GetObjects( aModel ) );
-
- // 13. [] / ALL OBJECTS
- aModel->move( QList<int>(), aDown, false );
- CPPUNIT_ASSERT_EQUAL( std::string( "B, *C, *E, *A, D, F"), GetObjects( aModel ) );
-
- // 14. [ B, *C, *E, *A, D, F ] / ALL OBJECTS
- aModel->move( QList<int>() << 0 << 1 << 2 << 3 << 4 << 5, aDown, false );
- CPPUNIT_ASSERT_EQUAL( std::string( "B, *C, *E, *A, D, F"), GetObjects( aModel ) );
-
- delete aModel;
-}
-
-/**
- Test move on bottom algorithm.
-*/
-void test_HYDROGUI_ListModel::testMoveOnBottom()
-{
- HYDROGUI_ListModel* aModel = new HYDROGUI_ListModel();
- aModel->setObjects( CreateTestObjects( 6 ) );
- const HYDROGUI_ListModel::OpType aBottom = HYDROGUI_ListModel::Bottom;
-
- // 0. Check the initial state
- CPPUNIT_ASSERT_EQUAL( std::string( "*A, B, *C, D, *E, F" ), GetObjects( aModel ) );
-
- // 1. [ F ] / ALL OBJECTS
- aModel->move( QList<int>() << 5, aBottom, false );
- CPPUNIT_ASSERT_EQUAL( std::string( "*A, B, *C, D, *E, F" ), GetObjects( aModel ) );
-
- // 2. [ F ] / VISIBLE OBJECTS
- aModel->move( QList<int>() << 5, aBottom, true );
- CPPUNIT_ASSERT_EQUAL( std::string( "*A, B, *C, D, *E, F" ), GetObjects( aModel ) );
-
- // 3. [ *A ] / ALL OBJECTS
- aModel->move( QList<int>() << 0, aBottom, false );
- CPPUNIT_ASSERT_EQUAL( std::string( "B, *C, D, *E, F, *A" ), GetObjects( aModel ) );
-
- // 4. [ *C ] / VISIBLE OBJECTS
- aModel->move( QList<int>() << 1, aBottom, true );
- CPPUNIT_ASSERT_EQUAL( std::string( "B, D, *E, F, *A, *C" ), GetObjects( aModel ) );
-
- // 5. [ B, D ] / ALL OBJECTS
- aModel->move( QList<int>() << 0 << 1, aBottom, false );
- CPPUNIT_ASSERT_EQUAL( std::string( "*E, F, *A, *C, B, D" ), GetObjects( aModel ) );
-
- // 6. [ *C, *D ] / ALL OBJECTS
- aModel->move( QList<int>() << 3 << 5, aBottom, false );
- CPPUNIT_ASSERT_EQUAL( std::string( "*E, F, *A, B, *C, D" ), GetObjects( aModel ) );
-
- // 7. [ *E, *A, *C ] / ALL OBJECTS
- aModel->move( QList<int>() << 0 << 2 << 4, aBottom, false );
- CPPUNIT_ASSERT_EQUAL( std::string( "F, B, D, *E, *A, *C" ), GetObjects( aModel ) );
-
- // 8. [ B, D, *E, *A ] / ALL OBJECTS
- aModel->move( QList<int>() << 1 << 2 << 3 << 4 , aBottom, false );
- CPPUNIT_ASSERT_EQUAL( std::string( "F, *C, B, D, *E, *A" ), GetObjects( aModel ) );
-
- // 9. [] / ALL OBJECTS
- aModel->move( QList<int>(), aBottom, false );
- CPPUNIT_ASSERT_EQUAL( std::string( "F, *C, B, D, *E, *A" ), GetObjects( aModel ) );
-
- // 10. [F, *C, B, D, *E, *A] / ALL OBJECTS
- aModel->move( QList<int>() << 0 << 1 << 2 << 3 << 4 << 5, aBottom, false );
- CPPUNIT_ASSERT_EQUAL( std::string( "F, *C, B, D, *E, *A" ), GetObjects( aModel ) );
-
- delete aModel;
-}
-
-/**
- Test drag and drop algorithm.
-*/
-void test_HYDROGUI_ListModel::testDragAndDrop()
-{
- HYDROGUI_ListModel* aModel = new HYDROGUI_ListModel();
- aModel->setObjects( CreateTestObjects( 8 ) );
- const HYDROGUI_ListModel::OpType aDnD = HYDROGUI_ListModel::DragAndDrop;
-
- // 0. Check the initial state
- std::string anInitialState = std::string( "*A, B, *C, D, *E, F, *G, H" );
- CPPUNIT_ASSERT_EQUAL( anInitialState, GetObjects( aModel ) );
-
- // 1. [] -> B ( i=1 )
- bool aRes = aModel->move( QList<int>(), aDnD, false, 1 );
- CPPUNIT_ASSERT_EQUAL( false, aRes );
- CPPUNIT_ASSERT_EQUAL( anInitialState, GetObjects( aModel ) );
-
- // 2. ALL -> B ( i=1 )
- QList<int> anAll;
- anAll << 0 << 1 << 2 << 3 << 4 << 5 << 6 << 7;
- aRes = aModel->move( anAll, aDnD, false, 1 );
- CPPUNIT_ASSERT_EQUAL( false, aRes );
- CPPUNIT_ASSERT_EQUAL( anInitialState, GetObjects( aModel ) );
-
- // 3. [D, *E, *G] -> D : drop item is among dragged items ( at the beginning )
- aRes = aModel->move( QList<int>() << 3 << 4 << 6, aDnD, false, 3 );
- CPPUNIT_ASSERT_EQUAL( false, aRes );
- CPPUNIT_ASSERT_EQUAL( anInitialState, GetObjects( aModel ) );
-
- // 4. [D, *E, *G] -> *E : drop item is among dragged items ( in the middle )
- aRes = aModel->move( QList<int>() << 3 << 4 << 6, aDnD, false, 4 );
- CPPUNIT_ASSERT_EQUAL( false, aRes );
- CPPUNIT_ASSERT_EQUAL( anInitialState, GetObjects( aModel ) );
-
- // 5. [D, *E, *G] -> *G : drop item is among dragged items ( at the end )
- aRes = aModel->move( QList<int>() << 3 << 4 << 6, aDnD, false, 6 );
- CPPUNIT_ASSERT_EQUAL( false, aRes );
- CPPUNIT_ASSERT_EQUAL( anInitialState, GetObjects( aModel ) );
-
- // 6. [D, *E, *G] -> -1 : drop item index is out of range ( less than zero )
- aRes = aModel->move( QList<int>() << 3 << 4 << 6, aDnD, false, -1 );
- CPPUNIT_ASSERT_EQUAL( false, aRes );
- CPPUNIT_ASSERT_EQUAL( anInitialState, GetObjects( aModel ) );
-
- // 7. [D, *E, *G] -> -1 : drop item index is out of range ( more than than list length )
- aRes = aModel->move( QList<int>() << 3 << 4 << 6, aDnD, false, 9 );
- CPPUNIT_ASSERT_EQUAL( false, aRes );
- CPPUNIT_ASSERT_EQUAL( anInitialState, GetObjects( aModel ) );
-
- // 8. [D, *E, *G] -> B ( i = 1 )
- aRes = aModel->move( QList<int>() << 3 << 4 << 6, aDnD, false, 1 );
- CPPUNIT_ASSERT_EQUAL( true, aRes );
- CPPUNIT_ASSERT_EQUAL( std::string( "*A, D, *E, *G, B, *C, F, H" ), GetObjects( aModel ) );
-
- // 9. [*E, F] -> *G
- aRes = aModel->move( QList<int>() << 2 << 6, aDnD, false, 3 );
- CPPUNIT_ASSERT_EQUAL( true, aRes );
- CPPUNIT_ASSERT_EQUAL( std::string( "*A, D, *E, F, *G, B, *C, H" ), GetObjects( aModel ) );
-
- // 10. [*E, F, *G] -> *A
- aRes = aModel->move( QList<int>() << 2 << 3 << 4, aDnD, false, 0 );
- CPPUNIT_ASSERT_EQUAL( true, aRes );
- CPPUNIT_ASSERT_EQUAL( std::string( "*E, F, *G, *A, D, B, *C, H" ), GetObjects( aModel ) );
-
- // 11. [*G, D, *C, H] -> B
- aRes = aModel->move( QList<int>() << 2 << 4 << 6 << 7, aDnD, false, 5 );
- CPPUNIT_ASSERT_EQUAL( true, aRes );
- CPPUNIT_ASSERT_EQUAL( std::string( "*E, F, *A, *G, D, *C, H, B" ), GetObjects( aModel ) );
-
- // 12. [F, *A, *G, D, *C, H, B] -> *E
- QList<int> anAllWithoutFirst;
- anAllWithoutFirst << 1 << 2 << 3 << 4 << 5 << 6 << 7;
- aRes = aModel->move( anAllWithoutFirst, aDnD, false, 0 );
- CPPUNIT_ASSERT_EQUAL( true, aRes );
- CPPUNIT_ASSERT_EQUAL( std::string( "F, *A, *G, D, *C, H, B, *E" ), GetObjects( aModel ) );
-
- // 13. [*A, *G] -> D : no changes
- aRes = aModel->move( QList<int>() << 1 << 2, aDnD, false, 3 );
- CPPUNIT_ASSERT_EQUAL( true, aRes );
- CPPUNIT_ASSERT_EQUAL( std::string( "F, *A, *G, D, *C, H, B, *E" ), GetObjects( aModel ) );
-
- // 14. [F, *G] -> D
- aRes = aModel->move( QList<int>() << 0 << 2, aDnD, false, 3 );
- CPPUNIT_ASSERT_EQUAL( true, aRes );
- CPPUNIT_ASSERT_EQUAL( std::string( "*A, F, *G, D, *C, H, B, *E" ), GetObjects( aModel ) );
-
- // 15. [*A, *G, *C, H, *E] -> D
- aRes = aModel->move( QList<int>() << 0 << 2 << 4 << 5 << 7, aDnD, false, 3 );
- CPPUNIT_ASSERT_EQUAL( true, aRes );
- CPPUNIT_ASSERT_EQUAL( std::string( "F, *A, *G, *C, H, *E, D, B" ), GetObjects( aModel ) );
-}
\ No newline at end of file
+++ /dev/null
-// 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 HYDROGUI_ListModel;
-
-class test_HYDROGUI_ListModel : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(test_HYDROGUI_ListModel);
- CPPUNIT_TEST(testMoveUp);
- CPPUNIT_TEST(testMoveOnTop);
- CPPUNIT_TEST(testMoveDown);
- CPPUNIT_TEST(testMoveOnBottom);
- CPPUNIT_TEST(testDragAndDrop);
- CPPUNIT_TEST_SUITE_END();
-
-private:
- std::string GetObjects( HYDROGUI_ListModel* theModel ) const;
-
-public:
- void testMoveUp();
- void testMoveOnTop();
- void testMoveDown();
- void testMoveOnBottom();
- void testDragAndDrop();
-};
-
-CPPUNIT_TEST_SUITE_REGISTRATION(test_HYDROGUI_ListModel);
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(test_HYDROGUI_ListModel, "HYDROGUI_ListModel");
+++ /dev/null
-// 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/TestFactoryRegistry.h>
-#include <cppunit/CompilerOutputter.h>
-#include <cppunit/TestResult.h>
-#include <cppunit/TestResultCollector.h>
-#include <cppunit/TestRunner.h>
-#include <cppunit/TextTestProgressListener.h>
-#include <stdexcept>
-#include <QApplication>
-
-int main( int argc, char* argv[] )
-{
- QApplication anApp( argc, argv );
-
- std::string testPath = (argc > 1) ? std::string(argv[1]) : "";
-
- // Create the event manager and test controller
- CppUnit::TestResult controller;
-
- // Add a listener that colllects test result
- CppUnit::TestResultCollector result;
- controller.addListener( &result );
-
- // Add a listener that print dots as test run.
- CppUnit::TextTestProgressListener progress;
- controller.addListener( &progress );
-
- CppUnit::TestFactoryRegistry& registry =
- CppUnit::TestFactoryRegistry::getRegistry();
- // Add the top suite to the test runner
- CppUnit::TestRunner runner;
- runner.addTest( registry.makeTest() );
- try
- {
- std::cout << "Running " << testPath;
- runner.run( controller, testPath );
-
- std::cerr << std::endl;
-
- // Print test in a compiler compatible format.
- CppUnit::CompilerOutputter outputter( &result, std::cerr );
- outputter.write();
- }
- catch ( std::invalid_argument &e ) // Test path not resolved
- {
- std::cerr << std::endl
- << "ERROR: " << e.what()
- << std::endl;
- return 0;
- }
-
- return result.wasSuccessful() ? 0 : 1;
-}
--- /dev/null
+#include(../../CMake/Common.cmake)
+
+set(PROJECT_HEADERS
+ test_HYDROData_Bathymetry.h
+ test_HYDROData_Document.h
+ test_HYDROData_Entity.h
+ test_HYDROData_Image.h
+ test_HYDROData_Iterator.h
+ test_HYDROData_OperationsFactory.h
+ test_HYDROData_PolylineXY.h
+ test_HYDROData_Profile.h
+ test_HYDROData_StricklerTable.h
+ test_HYDROGUI_ListModel.h
+)
+
+set(PROJECT_SOURCES
+ test_HYDROData_Bathymetry.cxx
+ test_HYDROData_Document.cxx
+ test_HYDROData_Entity.cxx
+ test_HYDROData_Image.cxx
+ test_HYDROData_Iterator.cxx
+ test_HYDROData_Main.cxx
+ test_HYDROData_OperationsFactory.cxx
+ test_HYDROData_PolylineXY.cxx
+ test_HYDROData_Profile.cxx
+ test_HYDROData_StricklerTable.cxx
+ test_HYDROGUI_ListModel.cxx
+
+ ../HYDROData/HYDROData_AltitudeObject.cxx
+ ../HYDROData/HYDROData_Application.cxx
+ ../HYDROData/HYDROData_ArtificialObject.cxx
+ ../HYDROData/HYDROData_Bathymetry.cxx
+ ../HYDROData/HYDROData_BSplineOperation.cxx
+ ../HYDROData/HYDROData_CalculationCase.cxx
+ ../HYDROData/HYDROData_Channel.cxx
+ ../HYDROData/HYDROData_Confluence.cxx
+ ../HYDROData/HYDROData_Digue.cxx
+ ../HYDROData/HYDROData_Document.cxx
+ ../HYDROData/HYDROData_DummyObject3D.cxx
+ ../HYDROData/HYDROData_Entity.cxx
+ ../HYDROData/HYDROData_IAltitudeObject.cxx
+ ../HYDROData/HYDROData_IInterpolator.cxx
+ ../HYDROData/HYDROData_Image.cxx
+ ../HYDROData/HYDROData_ImmersibleZone.cxx
+ ../HYDROData/HYDROData_IPolyline.cxx
+ ../HYDROData/HYDROData_Iterator.cxx
+ ../HYDROData/HYDROData_Lambert93.cxx
+ ../HYDROData/HYDROData_NaturalObject.cxx
+ ../HYDROData/HYDROData_Object.cxx
+ ../HYDROData/HYDROData_Obstacle.cxx
+ ../HYDROData/HYDROData_ObstacleAltitude.cxx
+ ../HYDROData/HYDROData_OperationsFactory.cxx
+ ../HYDROData/HYDROData_Pipes.cxx
+ ../HYDROData/HYDROData_PolylineOperator.cxx
+ ../HYDROData/HYDROData_PolylineXY.cxx
+ ../HYDROData/HYDROData_Polyline3D.cxx
+ ../HYDROData/HYDROData_PriorityQueue.cxx
+ ../HYDROData/HYDROData_Profile.cxx
+ ../HYDROData/HYDROData_ProfileUZ.cxx
+ ../HYDROData/HYDROData_Projection.cxx
+ ../HYDROData/HYDROData_Region.cxx
+ ../HYDROData/HYDROData_River.cxx
+ ../HYDROData/HYDROData_ShapesGroup.cxx
+ ../HYDROData/HYDROData_ShapesTool.cxx
+ ../HYDROData/HYDROData_SplittedShapesGroup.cxx
+ ../HYDROData/HYDROData_SplitToZonesTool.cxx
+ ../HYDROData/HYDROData_Stream.cxx
+ ../HYDROData/HYDROData_StreamAltitude.cxx
+ ../HYDROData/HYDROData_StricklerTable.cxx
+ ../HYDROData/HYDROData_LandCover.cxx
+ ../HYDROData/HYDROData_Tool.cxx
+ ../HYDROData/HYDROData_TopoCurve.cxx
+ ../HYDROData/HYDROData_Transform.cxx
+ ../HYDROData/HYDROData_VisualState.cxx
+ ../HYDROData/HYDROData_Zone.cxx
+ ../HYDROData/HYDROData_GeomTool.cxx
+ ../HYDROData/HYDROData_IProfilesInterpolator.cxx
+ ../HYDROData/HYDROData_LinearInterpolator.cxx
+ ../HYDROData/HYDROData_InterpolatorsFactory.cxx
+ ../HYDROData/HYDROData_SinusX.cxx
+ ../HYDROData/HYDROData_ShapeFile.cxx
+ ../HYDROData/HYDROData_LandCoverMap.cxx
+
+ ../HYDROGUI/HYDROGUI_ListModel.cxx
+ ../HYDROGUI/HYDROGUI_DataObject.cxx
+)
+
+add_definitions(
+ -DLIGHT_MODE -DHYDRODATA_STATIC -DHYDROGUI_STATIC
+)
+
+IF( ${WIN32} )
+ add_definitions( -DWNT )
+ENDIF()
+
+SET( BOOST_INCLUDES $ENV{BOOST_ROOT_DIR}/include/boost-1_52 )
+SET( CPPUNIT_INCLUDES $ENV{CPPUNIT_ROOT_DIR}/include )
+SET( QT_INCLUDES $ENV{QT_ROOT_DIR}/include $ENV{QT_ROOT_DIR}/include/QtCore $ENV{QT_ROOT_DIR}/include/QtGui )
+SET( GUI_INCLUDES $ENV{GUI_ROOT_DIR}/include/salome )
+
+link_directories( $ENV{CAS_ROOT_DIR}/win32/libd ) #TODO: more correct for release, linux etc
+SET( CAS_LIBRARIES TKernel TKLCAF TKCAF TKCDF TKMath TKG2d TKG3d TKBRep TKGeomBase TKTopAlgo TKGeomAlgo TKBool TKShHealing TKXSBase TKOffset TKHLR TKBO )
+
+link_directories( $ENV{QT_ROOT_DIR}/lib )
+SET( QT_LIBRARIES QtCored4 QtGuid4 )
+
+link_directories( $ENV{CPPUNIT_ROOT_DIR}/lib )
+SET( CPPUNIT_LIBRARIES cppunitd )
+
+link_directories( $ENV{GUI_ROOT_DIR}/lib/salome )
+SET( GUI_LIBRARIES ImageComposer Qtx SUIT LightApp CAM )
+
+include_directories(
+ ${BOOST_INCLUDES}
+ ${CAS_INCLUDE_DIRS}
+ ${QT_INCLUDES}
+ ${CPPUNIT_INCLUDES}
+ ${GUI_INCLUDES}
+ ${CMAKE_CURRENT_SOURCE_DIR}
+ ${CMAKE_CURRENT_SOURCE_DIR}/../HYDROData
+ ${CMAKE_CURRENT_SOURCE_DIR}/../HYDROGUI
+ ${CMAKE_CURRENT_SOURCE_DIR}/../shapelib
+)
+
+add_executable( HYDROData_tests ${PROJECT_SOURCES} ${PROJECT_HEADERS})
+target_link_libraries( HYDROData_tests ${GUI_LIBRARIES} ${CAS_LIBRARIES} ${QT_LIBRARIES} ${CPPUNIT_LIBRARIES} shapelib )
--- /dev/null
+// 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_Bathymetry.h>
+
+#include <HYDROData_Document.h>
+#include <HYDROData_Tool.h>
+#include <HYDROData_Bathymetry.h>
+
+#include <gp_XY.hxx>
+#include <gp_XYZ.hxx>
+
+#include <QDir>
+#include <QFile>
+#include <QTextStream>
+
+#include <gp_Pnt2d.hxx>
+
+void generateOne( QTextStream& theStream,
+ double theFirstX, double theFirstY,
+ double theLastX, double theLastY )
+{
+ const int aNbPoints = 50;
+
+ double aComDist = gp_Pnt2d( theFirstX, theFirstY ).Distance( gp_Pnt2d( theLastX, theLastY ) );
+ double aStep = aComDist / (double)aNbPoints;
+
+ double aStepZ = -5;
+ double aCurDist = 0.0;
+ for ( int i = 0; i <= aNbPoints; ++i )
+ {
+ double aRatio = ( aCurDist / ( aComDist - aCurDist ) );
+
+ double anX = ( theFirstX + aRatio * theLastX ) / ( 1 + aRatio );
+ double anY = ( theFirstY + aRatio * theLastY ) / ( 1 + aRatio );
+ double aZ = aStepZ * aStepZ + sin( (float)rand() );
+ theStream << anX << " " << anY << " " << aZ << " \n";
+
+ aCurDist += aStep;
+ aStepZ += 0.2;
+ }
+}
+
+bool test_HYDROData_Bathymetry::createTestFile( const QString& theFileName )
+{
+ QFile aTmpFile( theFileName );
+ if ( !aTmpFile.open( QIODevice::WriteOnly | QIODevice::Text ) )
+ return false;
+
+ {
+ QTextStream anOutStream( &aTmpFile );
+
+ srand( 4587 );
+ generateOne( anOutStream, 0, 5, 0, -5 );
+ generateOne( anOutStream, 10, 5, 10, -5 );
+ generateOne( anOutStream, 20, 5, 20, -5 );
+ generateOne( anOutStream, 30, 5, 30, -5 );
+ generateOne( anOutStream, 40, 5, 40, -5 );
+ generateOne( anOutStream, 45.833271, 6.703101, 50.85397, -3.794724 );
+ generateOne( anOutStream, 50.85397, 11.267372, 56.787525, 2.367043 );
+ generateOne( anOutStream, 52.67968, 16.516285, 62.721077, 10.354518 );
+ generateOne( anOutStream, 55.190029, 23.819118, 65.23143, 17.657352 );
+ generateOne( anOutStream, 58.385021, 31.806595, 68.198204, 23.819118 );
+ generateOne( anOutStream, 65.916069, 38.653004, 75.044609, 27.470537 );
+ generateOne( anOutStream, 76.870323, 41.847992, 82.575661, 28.38339 );
+ generateOne( anOutStream, 92.845276, 40.022282, 91.932419, 26.557682 );
+ generateOne( anOutStream, 106.081657, 35.686226, 98.778824, 21.99341 );
+ generateOne( anOutStream, 119.774475, 29.980886, 106.994514, 14.91879 );
+ generateOne( anOutStream, 133.239075, 26.785896, 115.666634, 5.790246 );
+ generateOne( anOutStream, 150.811523, 20.167702, 125.47982, -4.707579 );
+ generateOne( anOutStream, 163.591476, 13.777717, 135.977631, -12.92327 );
+ generateOne( anOutStream, 183.446045, 11.267367, 151.496155, -24.105736 );
+ generateOne( anOutStream, 197.367081, 8.98523100, 172.720016, -31.180355 );
+ generateOne( anOutStream, 214.026672, 9.669872, 197.823502, -38.483189 );
+ generateOne( anOutStream, 235.706985, 9.89809100, 220.873108, -47.155304 );
+ generateOne( anOutStream, 266.744019, 9.213447, 248.715134, -58.565987 );
+ generateOne( anOutStream, 307.366028, 10.354514, 278.611145, -67.922737 );
+ generateOne( anOutStream, 342.510925, 7.159524, 316.951019, -84.81053 );
+ generateOne( anOutStream, 384.659393, -4.55408, 350.913635, -100.02983 );
+ generateOne( anOutStream, 443.097107, -21.015415, 391.243927, -118.960365 );
+ generateOne( anOutStream, 500.711792, -34.184483, 440.62793, -147.7677 );
+ generateOne( anOutStream, 547.626587, -52.291954, 482.604309, -169.990509 );
+ generateOne( anOutStream, 589.603027, -68.753288, 534.45752, -193.8594 );
+ generateOne( anOutStream, 633.225525, -97.560631, 569.026306, -206.205444 );
+ generateOne( anOutStream, 673.555786, -120.606499, 601.948975, -224.312912 );
+ generateOne( anOutStream, 719.647522, -148.590775, 654.625305, -248.181854 );
+ generateOne( anOutStream, 770.677673, -183.982635, 708.947693, -278.635315 );
+ generateOne( anOutStream, 824.177002, -225.959045, 742.69342, -314.027191 );
+ generateOne( anOutStream, 855.937317, -260.368958, 793.05932, -341.853638 );
+ generateOne( anOutStream, 884.168213, -294.37439, 838.6137700, -355.969116 );
+ generateOne( anOutStream, 915.607178, -327.096588, 875.185669, -366.234894 );
+ generateOne( anOutStream, 940.630066, -348.269775, 903.416565, -381.633575 );
+ generateOne( anOutStream, 963.728088, -370.726166, 936.780396, -397.032257 );
+ generateOne( anOutStream, 983.618042, -390.61615, 959.878418, -411.789337 );
+ generateOne( anOutStream, 999.658325, -407.939667, 978.485107, -425.904785 );
+ generateOne( anOutStream, 1018.265076, -422.696716, 996.450256, -443.228302 );
+ generateOne( anOutStream, 1040.079834, -441.303467, 1017.623413, -459.9102175 );
+ generateOne( anOutStream, 1055.478516, -456.060547, 1034.946899, -475.9505 );
+ generateOne( anOutStream, 1074.085327, -474.025665, 1058.044922, -493.274017 );
+ }
+
+ aTmpFile.close();
+
+ return true;
+}
+
+void test_HYDROData_Bathymetry::testFileImport()
+{
+ Handle(HYDROData_Document) aDoc = HYDROData_Document::Document( 1 );
+
+ Handle(HYDROData_Bathymetry) aBathymetry =
+ Handle(HYDROData_Bathymetry)::DownCast( aDoc->CreateObject( KIND_BATHYMETRY ) );
+
+ QString aFileName = QDir::tempPath() + QDir::separator() + "test.xyz";
+ if ( !createTestFile( aFileName ) )
+ return; // No file has been created
+
+ CPPUNIT_ASSERT( aBathymetry->ImportFromFile( aFileName.toStdString().c_str() ) );
+
+ HYDROData_Bathymetry::AltitudePoints anAltitudePoints = aBathymetry->GetAltitudePoints();
+ CPPUNIT_ASSERT( anAltitudePoints.Length() == 20 );
+
+ gp_XY aTestPoint( 1, 1 );
+ double anAltitude = aBathymetry->GetAltitudeForPoint( aTestPoint );
+ CPPUNIT_ASSERT( ValuesEquals( anAltitude, 10.0 ) );
+
+ aTestPoint = gp_XY( 0.5, 0.5 );
+ anAltitude = aBathymetry->GetAltitudeForPoint( aTestPoint );
+ CPPUNIT_ASSERT( ValuesEquals( anAltitude, 5.0 ) );
+
+ aTestPoint = gp_XY( 1.5, 1 );
+ anAltitude = aBathymetry->GetAltitudeForPoint( aTestPoint );
+ CPPUNIT_ASSERT( ValuesEquals( anAltitude, 10.0 ) );
+
+ aTestPoint = gp_XY( 1.5, 0.7 );
+ anAltitude = aBathymetry->GetAltitudeForPoint( aTestPoint );
+ CPPUNIT_ASSERT( ValuesEquals( anAltitude, 7.0 ) );
+
+ aTestPoint = gp_XY( 1.5, -0.7 );
+ anAltitude = aBathymetry->GetAltitudeForPoint( aTestPoint );
+ CPPUNIT_ASSERT( ValuesEquals( anAltitude, HYDROData_Bathymetry::GetInvalidAltitude() ) );
+
+ aTestPoint = gp_XY( 2, 3.5 );
+ anAltitude = aBathymetry->GetAltitudeForPoint( aTestPoint );
+ CPPUNIT_ASSERT( ValuesEquals( anAltitude, 35.0 ) );
+
+ aDoc->Close();
+}
+
+
+void test_HYDROData_Bathymetry::testCopy()
+{
+ Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
+
+ Handle(HYDROData_Bathymetry) aBathymetry1 =
+ Handle(HYDROData_Bathymetry)::DownCast( aDoc->CreateObject( KIND_BATHYMETRY ) );
+
+ QString aFileName = QDir::tempPath() + QDir::separator() + "test.xyz";
+
+ bool anIsFileCreated = createTestFile( aFileName );
+
+ if ( anIsFileCreated )
+ {
+ CPPUNIT_ASSERT( aBathymetry1->ImportFromFile( aFileName.toStdString().c_str() ) );
+
+ HYDROData_Bathymetry::AltitudePoints anAltitudePoints = aBathymetry1->GetAltitudePoints();
+ CPPUNIT_ASSERT( anAltitudePoints.Length() == 20 );
+ }
+
+ Handle(HYDROData_Bathymetry) aBathymetry2 =
+ Handle(HYDROData_Bathymetry)::DownCast( aDoc->CreateObject( KIND_BATHYMETRY ) );
+
+ aBathymetry1->CopyTo( aBathymetry2, true );
+
+ if ( anIsFileCreated )
+ {
+ HYDROData_Bathymetry::AltitudePoints anAltitudePoints = aBathymetry2->GetAltitudePoints();
+ CPPUNIT_ASSERT( anAltitudePoints.Length() == 20 );
+ }
+
+ aDoc->Close();
+}
--- /dev/null
+// 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 Handle_HYDROData_Bathymetry;
+class QString;
+
+class test_HYDROData_Bathymetry : public CppUnit::TestFixture {
+ CPPUNIT_TEST_SUITE(test_HYDROData_Bathymetry);
+ CPPUNIT_TEST(testFileImport);
+ CPPUNIT_TEST(testCopy);
+ CPPUNIT_TEST_SUITE_END();
+
+private:
+
+ static bool createTestFile( const QString& theFileName );
+
+public:
+
+ void setUp() {}
+
+ void tearDown() {}
+
+ // checks file importing information
+ void testFileImport();
+
+ // checks the copy/paste mechanism
+ void testCopy();
+
+};
+
+CPPUNIT_TEST_SUITE_REGISTRATION(test_HYDROData_Bathymetry);
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(test_HYDROData_Bathymetry, "HYDROData_Bathymetry");
--- /dev/null
+// 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_Document.h>
+
+#include <HYDROData_Document.h>
+#include <QFile>
+
+void test_HYDROData_Document::testSaveOpen()
+{
+ // temporarly created file name (in the current directory)
+ const char* aTestFile = "TestDoc.cbf";
+ // save
+ Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
+ CPPUNIT_ASSERT(!aDoc.IsNull());
+ // keep some saved information to check after retreive
+ aDoc->NewID();
+ int anID = aDoc->NewID();
+ Data_DocError aStatus = aDoc->Save(aTestFile);
+ CPPUNIT_ASSERT(aStatus == DocError_OK);
+ aDoc->Close();
+ CPPUNIT_ASSERT(!HYDROData_Document::HasDocument(1));
+
+ // open
+ aStatus = HYDROData_Document::Load(aTestFile, 2);
+ CPPUNIT_ASSERT(aStatus == DocError_OK);
+ CPPUNIT_ASSERT(HYDROData_Document::HasDocument(2));
+ aDoc = HYDROData_Document::Document(2);
+ CPPUNIT_ASSERT(!aDoc.IsNull());
+ // check that retreived correctly
+ CPPUNIT_ASSERT(aDoc->NewID() == anID + 1);
+
+ // remove the created file using Qt functionality
+ QFile aFile(aTestFile);
+ aFile.remove();
+
+ aDoc->Close();
+}
+
+void test_HYDROData_Document::testOperations()
+{
+ Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
+ CPPUNIT_ASSERT(!aDoc.IsNull());
+ CPPUNIT_ASSERT(!aDoc->IsOperation());
+ CPPUNIT_ASSERT(!aDoc->IsModified());
+ // commit operation
+ aDoc->StartOperation();
+ CPPUNIT_ASSERT(aDoc->IsOperation());
+ int anID = aDoc->NewID();
+ aDoc->CommitOperation();
+ CPPUNIT_ASSERT(!aDoc->IsOperation());
+ CPPUNIT_ASSERT(aDoc->IsModified());
+ // abort operation
+ aDoc->StartOperation();
+ CPPUNIT_ASSERT(aDoc->IsOperation());
+ int anIDAborted = aDoc->NewID();
+ aDoc->AbortOperation();
+ CPPUNIT_ASSERT(!aDoc->IsOperation());
+ CPPUNIT_ASSERT(aDoc->IsModified());
+
+ CPPUNIT_ASSERT(anID + 1 == aDoc->NewID());
+
+ aDoc->Close();
+}
+
+void test_HYDROData_Document::testUndoRedo()
+{
+ Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
+ CPPUNIT_ASSERT(!aDoc.IsNull());
+ CPPUNIT_ASSERT(!aDoc->CanUndo());
+ CPPUNIT_ASSERT(!aDoc->CanRedo());
+ // commit operation
+ aDoc->StartOperation();
+ CPPUNIT_ASSERT(aDoc->IsOperation());
+ int anID = aDoc->NewID();
+ aDoc->CommitOperation();
+ CPPUNIT_ASSERT(aDoc->CanUndo());
+ CPPUNIT_ASSERT(!aDoc->CanRedo());
+ CPPUNIT_ASSERT(aDoc->IsModified());
+ // undo
+ aDoc->Undo();
+ CPPUNIT_ASSERT(!aDoc->CanUndo());
+ CPPUNIT_ASSERT(aDoc->CanRedo());
+ CPPUNIT_ASSERT(anID == aDoc->NewID());
+ CPPUNIT_ASSERT(!aDoc->IsModified());
+ // redo
+ aDoc->Redo();
+ CPPUNIT_ASSERT(aDoc->CanUndo());
+ CPPUNIT_ASSERT(!aDoc->CanRedo());
+ CPPUNIT_ASSERT(aDoc->IsModified());
+
+ aDoc->Close();
+}
--- /dev/null
+// 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_Document : public CppUnit::TestFixture {
+ CPPUNIT_TEST_SUITE(test_HYDROData_Document);
+ CPPUNIT_TEST(testSaveOpen);
+ CPPUNIT_TEST(testOperations);
+ CPPUNIT_TEST(testUndoRedo);
+ CPPUNIT_TEST_SUITE_END();
+
+private:
+
+public:
+
+ void setUp() {}
+
+ void tearDown() {}
+
+ // checks the save and open document as a file
+ void testSaveOpen();
+
+ // checks the operations management: open/commit/abort, etc
+ void testOperations();
+
+ // checks the operations undo/redo
+ void testUndoRedo();
+};
+
+CPPUNIT_TEST_SUITE_REGISTRATION(test_HYDROData_Document);
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(test_HYDROData_Document, "HYDROData_Document");
--- /dev/null
+// 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_Entity.h>
+
+#include <HYDROData_Document.h>
+#include <HYDROData_Entity.h>
+
+#include <QString>
+
+void test_HYDROData_Entity::testName()
+{
+ Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
+
+ Handle(HYDROData_Entity) anObj = aDoc->CreateObject(KIND_IMAGE); // any object
+ static const QString aName("test_name");
+ anObj->SetName(aName);
+ CPPUNIT_ASSERT_EQUAL(aName.toStdString(), anObj->GetName().toStdString());
+
+ aDoc->Close();
+}
+
+void test_HYDROData_Entity::testRemove()
+{
+ Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
+
+ Handle(HYDROData_Entity) anObj = aDoc->CreateObject(KIND_IMAGE); // any object
+ CPPUNIT_ASSERT(!anObj->IsRemoved());
+ anObj->Remove();
+ CPPUNIT_ASSERT(anObj->IsRemoved());
+
+ aDoc->Close();
+}
+
+void test_HYDROData_Entity::testCopy()
+{
+ Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
+
+ Handle(HYDROData_Entity) anObj = aDoc->CreateObject(KIND_IMAGE); // any object
+ static const QString aName("test_name");
+ anObj->SetName(aName);
+
+ Handle(HYDROData_Entity) aCopy = aDoc->CreateObject(KIND_IMAGE); // object for copy
+ CPPUNIT_ASSERT(aCopy->GetName().isEmpty());
+ anObj->CopyTo(aCopy, true);
+
+ // check the copied object has same name as original
+ CPPUNIT_ASSERT_EQUAL(aName.toStdString(), aCopy->GetName().toStdString());
+
+ aDoc->Close();
+}
--- /dev/null
+// 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_Entity : public CppUnit::TestFixture {
+ CPPUNIT_TEST_SUITE(test_HYDROData_Entity);
+ CPPUNIT_TEST(testName);
+ CPPUNIT_TEST(testRemove);
+ CPPUNIT_TEST(testCopy);
+ CPPUNIT_TEST_SUITE_END();
+
+private:
+
+public:
+
+ void setUp() {}
+
+ void tearDown() {}
+
+ // checks the "name" methods
+ void testName();
+
+ // checks the remove of object
+ void testRemove();
+
+ // checks the copying of object
+ void testCopy();
+};
+
+CPPUNIT_TEST_SUITE_REGISTRATION(test_HYDROData_Entity);
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(test_HYDROData_Entity, "HYDROData_Entity");
--- /dev/null
+// 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_Image.h>
+
+#include <HYDROData_Document.h>
+#include <HYDROData_Image.h>
+#include <QPainter>
+
+static QImage TestImage() {
+ QImage aPic(50, 40, QImage::Format_RGB32);
+ QPainter aPainter(&aPic);
+ aPainter.drawEllipse(6, 7, 38, 30);
+ aPainter.drawLine(0, 40, 10, 0);
+ aPainter.drawLine(10, 0, 25, 35);
+ aPainter.drawLine(25, 35, 40, 0);
+ aPainter.drawLine(40, 0, 50, 40);
+ return aPic;
+}
+
+void test_HYDROData_Image::testQImage()
+{
+ Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
+
+ Handle(HYDROData_Image) anImage =
+ Handle(HYDROData_Image)::DownCast(aDoc->CreateObject(KIND_IMAGE));
+ // empty image
+ QImage anEmpty = anImage->Image();
+ CPPUNIT_ASSERT(anEmpty.isNull());
+
+ // prepare Qt Image for testing
+ QImage aPic(TestImage());
+ anImage->SetImage(aPic);
+ QImage aRestored = anImage->Image();
+
+ CPPUNIT_ASSERT(!aRestored.isNull());
+ //aRestored.save("pic2.bmp");
+ CPPUNIT_ASSERT(aPic == aRestored);
+
+ aDoc->Close();
+}
+
+void test_HYDROData_Image::testTrsf()
+{
+ Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
+
+ Handle(HYDROData_Image) anImage =
+ Handle(HYDROData_Image)::DownCast(aDoc->CreateObject(KIND_IMAGE));
+ // empty trsf
+ QTransform anEmpty = anImage->Trsf();
+ CPPUNIT_ASSERT(anEmpty.isIdentity());
+
+ // prepare Qt transformation for testing
+ QTransform aTrsf;
+ aTrsf.translate(50, 50);
+ aTrsf.rotate(45);
+ aTrsf.scale(0.5, 1.0);
+
+ anImage->SetTrsf(aTrsf);
+ QTransform aRestored = anImage->Trsf();
+
+ CPPUNIT_ASSERT(!aRestored.isIdentity());
+ CPPUNIT_ASSERT(aTrsf == aRestored);
+
+ aDoc->Close();
+}
+
+void test_HYDROData_Image::testReferences()
+{
+ Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
+
+ Handle(HYDROData_Image) anImage1 =
+ Handle(HYDROData_Image)::DownCast(aDoc->CreateObject(KIND_IMAGE));
+ Handle(HYDROData_Image) anImage2 =
+ Handle(HYDROData_Image)::DownCast(aDoc->CreateObject(KIND_IMAGE));
+ Handle(HYDROData_Image) anImage3 =
+ Handle(HYDROData_Image)::DownCast(aDoc->CreateObject(KIND_IMAGE));
+
+ // check initially there is no references
+ CPPUNIT_ASSERT_EQUAL(anImage3->NbReferences(), 0);
+
+ // append reference
+ anImage3->AppendReference(anImage1);
+ CPPUNIT_ASSERT_EQUAL(anImage3->NbReferences(), 1);
+ CPPUNIT_ASSERT(IsEqual(anImage3->Reference(0), anImage1));
+
+ // change reference
+ anImage3->ChangeReference(0, anImage2);
+ CPPUNIT_ASSERT_EQUAL(anImage3->NbReferences(), 1);
+ CPPUNIT_ASSERT(IsEqual(anImage3->Reference(0), anImage2));
+
+ // append one more reference
+ anImage3->AppendReference(anImage1);
+ CPPUNIT_ASSERT_EQUAL(anImage3->NbReferences(), 2);
+ CPPUNIT_ASSERT(IsEqual(anImage3->Reference(0), anImage2));
+ CPPUNIT_ASSERT(IsEqual(anImage3->Reference(1), anImage1));
+
+ // remove reference
+ anImage3->RemoveReference(0);
+ CPPUNIT_ASSERT_EQUAL(anImage3->NbReferences(), 1);
+ CPPUNIT_ASSERT(IsEqual(anImage3->Reference(0), anImage1));
+
+ // remove reference
+ anImage3->RemoveReference(0);
+ CPPUNIT_ASSERT_EQUAL(anImage3->NbReferences(), 0);
+
+ // append two references once again and remove all references
+ anImage3->ChangeReference(0, anImage1);
+ anImage3->ChangeReference(1, anImage2);
+ CPPUNIT_ASSERT_EQUAL(anImage3->NbReferences(), 2);
+ CPPUNIT_ASSERT(IsEqual(anImage3->Reference(0), anImage1));
+ CPPUNIT_ASSERT(IsEqual(anImage3->Reference(1), anImage2));
+ anImage3->ClearReferences();
+ CPPUNIT_ASSERT_EQUAL(anImage3->NbReferences(), 0);
+
+ aDoc->Close();
+}
+
+void test_HYDROData_Image::testCopy()
+{
+ Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
+
+ Handle(HYDROData_Image) anImage1 =
+ Handle(HYDROData_Image)::DownCast(aDoc->CreateObject(KIND_IMAGE));
+ // fill image 1
+ anImage1->SetImage(TestImage());
+
+ QTransform aTrsf;
+ aTrsf.translate(50, 50);
+ aTrsf.rotate(45);
+ aTrsf.scale(0.5, 1.0);
+ anImage1->SetTrsf(aTrsf);
+
+ Handle(HYDROData_Image) anImage2 =
+ Handle(HYDROData_Image)::DownCast(aDoc->CreateObject(KIND_IMAGE));
+
+ anImage1->AppendReference(anImage2);
+
+ // copy image to the new one
+ Handle(HYDROData_Image) anImage3 =
+ Handle(HYDROData_Image)::DownCast(aDoc->CreateObject(KIND_IMAGE));
+ anImage1->CopyTo(anImage3, true);
+
+ // check all fields are correctly copied
+ CPPUNIT_ASSERT(anImage1->Image() == anImage3->Image());
+ CPPUNIT_ASSERT(anImage1->Trsf() == anImage3->Trsf());
+ CPPUNIT_ASSERT_EQUAL(anImage3->NbReferences(), 1);
+ CPPUNIT_ASSERT(IsEqual(anImage3->Reference(0), anImage2));
+
+ aDoc->Close();
+}
--- /dev/null
+// 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_Image : public CppUnit::TestFixture {
+ CPPUNIT_TEST_SUITE(test_HYDROData_Image);
+ CPPUNIT_TEST(testQImage);
+ CPPUNIT_TEST(testTrsf);
+ CPPUNIT_TEST(testReferences);
+ CPPUNIT_TEST(testCopy);
+ CPPUNIT_TEST_SUITE_END();
+
+private:
+
+public:
+
+ void setUp() {}
+
+ void tearDown() {}
+
+ // checks save/restore QImages information
+ void testQImage();
+
+ // checks the transformations
+ void testTrsf();
+
+ // checks the references management
+ void testReferences();
+
+ // checks the image properties copy/paste
+ void testCopy();
+};
+
+CPPUNIT_TEST_SUITE_REGISTRATION(test_HYDROData_Image);
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(test_HYDROData_Image, "HYDROData_Image");
--- /dev/null
+// 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_Iterator.h>
+
+#include <HYDROData_Document.h>
+#include <HYDROData_Iterator.h>
+
+#include <QString>
+
+void test_HYDROData_Iterator::testOneKind()
+{
+ static const QString aName1("test_name1");
+ static const QString aName2("test_name2");
+ Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
+
+ Handle(HYDROData_Entity) anObj = aDoc->CreateObject(KIND_IMAGE); // image object
+ anObj->SetName(aName1);
+ // first HYDROData_Entity must be destroyed because there is no hander pointer naymore
+ anObj = aDoc->CreateObject(KIND_IMAGE); // second image object
+ anObj->SetName(aName2);
+
+ HYDROData_Iterator anIter(aDoc, KIND_IMAGE);
+ CPPUNIT_ASSERT(anIter.More());
+ CPPUNIT_ASSERT(!anIter.Current().IsNull());
+ CPPUNIT_ASSERT_EQUAL(aName1.toStdString(), anIter.Current()->GetName().toStdString());
+
+ anIter.Next();
+ CPPUNIT_ASSERT(anIter.More());
+ CPPUNIT_ASSERT(!anIter.Current().IsNull());
+ CPPUNIT_ASSERT_EQUAL(aName2.toStdString(), anIter.Current()->GetName().toStdString());
+
+ anIter.Next();
+ CPPUNIT_ASSERT(!anIter.More());
+
+ aDoc->Close();
+}
+
+void test_HYDROData_Iterator::testAllKinds()
+{
+ static const QString aName1("test_name1");
+ static const QString aName2("test_name2");
+ Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
+
+ Handle(HYDROData_Entity) anObj = aDoc->CreateObject(KIND_IMAGE); // image object
+ anObj->SetName(aName1);
+ // first HYDROData_Entity must be destroyed because there is no hander pointer naymore
+ anObj = aDoc->CreateObject(KIND_IMAGE); // second image object
+ anObj->SetName(aName2);
+
+ HYDROData_Iterator anIter(aDoc, KIND_UNKNOWN);
+ CPPUNIT_ASSERT(anIter.More());
+ CPPUNIT_ASSERT(!anIter.Current().IsNull());
+ CPPUNIT_ASSERT_EQUAL(aName1.toStdString(), anIter.Current()->GetName().toStdString());
+
+ anIter.Next();
+ CPPUNIT_ASSERT(anIter.More());
+ CPPUNIT_ASSERT(!anIter.Current().IsNull());
+ CPPUNIT_ASSERT_EQUAL(aName2.toStdString(), anIter.Current()->GetName().toStdString());
+
+ anIter.Next();
+ CPPUNIT_ASSERT(!anIter.More());
+
+ aDoc->Close();
+}
--- /dev/null
+// 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_Iterator : public CppUnit::TestFixture {
+ CPPUNIT_TEST_SUITE(test_HYDROData_Iterator);
+ CPPUNIT_TEST(testOneKind);
+ CPPUNIT_TEST(testAllKinds);
+ CPPUNIT_TEST_SUITE_END();
+
+private:
+
+public:
+
+ void setUp() {}
+
+ void tearDown() {}
+
+ // checks iteration by one kind
+ void testOneKind();
+
+ // checks iteration by all kinds
+ void testAllKinds();
+};
+
+CPPUNIT_TEST_SUITE_REGISTRATION(test_HYDROData_Iterator);
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(test_HYDROData_Iterator, "HYDROData_Iterator");
--- /dev/null
+// 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/TestFactoryRegistry.h>
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/TestResult.h>
+#include <cppunit/TestResultCollector.h>
+#include <cppunit/TestRunner.h>
+#include <cppunit/TextTestProgressListener.h>
+#include <stdexcept>
+
+int
+ main( int argc, char* argv[] )
+{
+ std::string testPath = (argc > 1) ? std::string(argv[1]) : "";
+
+ // Create the event manager and test controller
+ CppUnit::TestResult controller;
+
+ // Add a listener that colllects test result
+ CppUnit::TestResultCollector result;
+ controller.addListener( &result );
+
+ // Add a listener that print dots as test run.
+ CppUnit::TextTestProgressListener progress;
+ controller.addListener( &progress );
+
+ CppUnit::TestFactoryRegistry& registry =
+ CppUnit::TestFactoryRegistry::getRegistry();
+ // Add the top suite to the test runner
+ CppUnit::TestRunner runner;
+ runner.addTest( registry.makeTest() );
+ try
+ {
+ std::cout << "Running " << testPath;
+ runner.run( controller, testPath );
+
+ std::cerr << std::endl;
+
+ // Print test in a compiler compatible format.
+ CppUnit::CompilerOutputter outputter( &result, std::cerr );
+ outputter.write();
+ }
+ catch ( std::invalid_argument &e ) // Test path not resolved
+ {
+ std::cerr << std::endl
+ << "ERROR: " << e.what()
+ << std::endl;
+ return 0;
+ }
+
+ return result.wasSuccessful() ? 0 : 1;
+}
--- /dev/null
+// 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_OperationsFactory.h>
+
+#include <HYDROData_Document.h>
+#include <HYDROData_Image.h>
+#include <HYDROData_PolylineXY.h>
+#include <HYDROData_OperationsFactory.h>
+
+#include <ImageComposer_CropOperator.h>
+
+#include <gp_XY.hxx>
+
+#include <QPainter>
+
+void test_HYDROData_OperationsFactory::testCreate()
+{
+ Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
+
+ HYDROData_OperationsFactory* aFactory = HYDROData_OperationsFactory::Factory();
+ CPPUNIT_ASSERT(aFactory);
+ Handle(HYDROData_Image) anImage = aFactory->CreateImage(aDoc, NULL);
+ CPPUNIT_ASSERT(!anImage.IsNull());
+ CPPUNIT_ASSERT(anImage->Image().isNull());
+
+ aDoc->Close();
+}
+
+static QImage TestImage() {
+ QImage aPic(50, 40, QImage::Format_RGB32);
+ aPic.fill(Qt::white);
+ QPainter aPainter(&aPic);
+ aPainter.drawEllipse(6, 7, 38, 30);
+ aPainter.drawLine(0, 40, 10, 0);
+ aPainter.drawLine(10, 0, 25, 35);
+ aPainter.drawLine(25, 35, 40, 0);
+ aPainter.drawLine(40, 0, 50, 40);
+ return aPic;
+}
+
+void test_HYDROData_OperationsFactory::testCrop()
+{
+ Handle(HYDROData_Document) aDoc = HYDROData_Document::Document( 1 );
+ HYDROData_OperationsFactory* aFactory = HYDROData_OperationsFactory::Factory();
+
+ // prepare the original image and crop-path
+ Handle(HYDROData_Image) anOriImage =
+ Handle(HYDROData_Image)::DownCast( aDoc->CreateObject( KIND_IMAGE ) );
+
+ QImage aTestImage = TestImage();
+ anOriImage->SetImage( aTestImage );
+
+ Handle(HYDROData_PolylineXY) aCropPolyline =
+ Handle(HYDROData_PolylineXY)::DownCast( aDoc->CreateObject( KIND_POLYLINEXY ) );
+
+ aCropPolyline->AddSection( "", HYDROData_PolylineXY::SECTION_POLYLINE, true );
+
+ aCropPolyline->AddPoint( 0, HYDROData_PolylineXY::Point( 25, 0 ) );
+ aCropPolyline->AddPoint( 0, HYDROData_PolylineXY::Point( 0, 20 ) );
+ aCropPolyline->AddPoint( 0, HYDROData_PolylineXY::Point( 25, 40 ) );
+ aCropPolyline->AddPoint( 0, HYDROData_PolylineXY::Point( 50, 20 ) );
+
+ // prepare Composer Operation
+ ImageComposer_Operator* aCropOp =
+ aFactory->Operator( ImageComposer_CropOperator::Type() );
+
+ CPPUNIT_ASSERT( aCropOp );
+
+ aCropOp->setArgs( Qt::red );
+
+ // create crop - image
+ Handle(HYDROData_Image) aCropImage = aFactory->CreateImage( aDoc, aCropOp );
+ CPPUNIT_ASSERT( !aCropImage.IsNull() );
+
+ aCropImage->AppendReference( anOriImage );
+ aCropImage->AppendReference( aCropPolyline );
+ aCropImage->Update();
+
+ // check crop operation was performed
+ CPPUNIT_ASSERT( !aCropImage->Image().isNull() );
+ CPPUNIT_ASSERT( aCropImage->Image() != aTestImage );
+
+ aDoc->Close();
+}
--- /dev/null
+// 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_OperationsFactory : public CppUnit::TestFixture {
+ CPPUNIT_TEST_SUITE(test_HYDROData_OperationsFactory);
+ CPPUNIT_TEST(testCreate);
+ CPPUNIT_TEST(testCrop);
+ CPPUNIT_TEST_SUITE_END();
+
+private:
+
+public:
+
+ void setUp() {}
+
+ void tearDown() {}
+
+ // checks creation of images using null operators
+ void testCreate();
+
+ // checks creation of images using crop operator
+ void testCrop();
+};
+
+CPPUNIT_TEST_SUITE_REGISTRATION(test_HYDROData_OperationsFactory);
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(test_HYDROData_OperationsFactory, "HYDROData_OperationsFactory");
--- /dev/null
+// 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_PolylineXY.h>
+
+#include <HYDROData_Document.h>
+#include <HYDROData_PolylineXY.h>
+
+#include <QList>
+#include <QPointF>
+
+void test_HYDROData_PolylineXY::testPolyline()
+{
+ Handle(HYDROData_Document) aDoc = HYDROData_Document::Document( 1 );
+
+ Handle(HYDROData_PolylineXY) aPolyline =
+ Handle(HYDROData_PolylineXY)::DownCast(aDoc->CreateObject(KIND_POLYLINEXY));
+
+ aPolyline->AddSection( "Section_1", HYDROData_PolylineXY::SECTION_POLYLINE, false );
+ aPolyline->AddSection( "Section_2", HYDROData_PolylineXY::SECTION_SPLINE, true );
+
+ int aNbSections = aPolyline->NbSections();
+ CPPUNIT_ASSERT( aNbSections == 2 );
+
+ NCollection_Sequence<TCollection_AsciiString> aSectNames;
+ NCollection_Sequence<HYDROData_PolylineXY::SectionType> aSectTypes;
+ NCollection_Sequence<bool> aSectClosures;
+ aPolyline->GetSections( aSectNames, aSectTypes, aSectClosures );
+
+ CPPUNIT_ASSERT( aSectNames.Value( 0 ) == "Section_1" );
+ CPPUNIT_ASSERT( aSectTypes.Value( 0 ) == HYDROData_PolylineXY::SECTION_POLYLINE );
+ CPPUNIT_ASSERT( aSectClosures.Value( 0 ) == false );
+
+ CPPUNIT_ASSERT( aSectNames.Value( 1 ) == "Section_2" );
+ CPPUNIT_ASSERT( aSectTypes.Value( 1 ) == HYDROData_PolylineXY::SECTION_SPLINE );
+ CPPUNIT_ASSERT( aSectClosures.Value( 1 ) == true );
+
+ aDoc->Close();
+}
+
+
+void test_HYDROData_PolylineXY::testCopy()
+{
+ Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
+ Handle(HYDROData_PolylineXY) aPolyline1 =
+ Handle(HYDROData_PolylineXY)::DownCast(aDoc->CreateObject(KIND_POLYLINEXY));
+
+
+// aPolyline1->setPoints(aPoints);
+
+ Handle(HYDROData_PolylineXY) aPolyline2 =
+ Handle(HYDROData_PolylineXY)::DownCast(aDoc->CreateObject(KIND_POLYLINEXY));
+
+ aPolyline1->CopyTo(aPolyline2, true);
+
+
+ aDoc->Close();
+}
--- /dev/null
+// 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_PolylineXY : public CppUnit::TestFixture {
+ CPPUNIT_TEST_SUITE(test_HYDROData_PolylineXY);
+ CPPUNIT_TEST(testPolyline);
+ CPPUNIT_TEST(testCopy);
+ CPPUNIT_TEST_SUITE_END();
+
+private:
+
+public:
+
+ void setUp() {}
+
+ void tearDown() {}
+
+ // checks save/restore QImages information
+ void testPolyline();
+
+ // checks the image properties copy/paste
+ void testCopy();
+};
+
+CPPUNIT_TEST_SUITE_REGISTRATION(test_HYDROData_PolylineXY);
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(test_HYDROData_PolylineXY, "HYDROData_PolylineXY");
--- /dev/null
+// 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_Profile.h>
+
+#include <HYDROData_Document.h>
+#include <HYDROData_Tool.h>
+#include <HYDROData_Profile.h>
+#include <HYDROData_Iterator.h>
+
+#include <TopoDS_Shape.hxx>
+
+#include <gp_XY.hxx>
+#include <gp_XYZ.hxx>
+
+#include <QDir>
+#include <QFile>
+#include <QTextStream>
+
+bool test_HYDROData_Profile::createTestFile( const QString& theFileName,
+ const bool theIsParametric )
+{
+ QFile aTmpFile( theFileName );
+ if ( !aTmpFile.open( QIODevice::WriteOnly | QIODevice::Text ) )
+ return false;
+
+ if ( theIsParametric )
+ {
+ QTextStream anOutStream( &aTmpFile );
+
+ anOutStream << "0 182.15 \n";
+ anOutStream << "4 181.95 \n";
+ anOutStream << "10.18 181.63 \n";
+ anOutStream << "14.75 179.27 \n";
+ anOutStream << "19.75 178.87 \n";
+
+ anOutStream << "\n";
+
+ anOutStream << "-5 50 \n";
+ anOutStream << "0 15 \n";
+ anOutStream << "10.1 10 \n";
+ anOutStream << "20 20 \n";
+ anOutStream << "250 0.005 \n";
+ }
+ else
+ {
+ QTextStream anOutStream( &aTmpFile );
+
+ anOutStream << "1040499.17 6788618.13 182.15 \n";
+ anOutStream << "1040503.12 6788618.79 181.95 \n";
+ anOutStream << "1040509.21 6788619.81 181.63 \n";
+ anOutStream << "1040513.72 6788620.56 179.27 \n";
+ anOutStream << "1040518.65 6788621.38 178.87 \n";
+ }
+
+ aTmpFile.close();
+
+ return true;
+}
+
+void test_HYDROData_Profile::testFileImport()
+{
+ Handle(HYDROData_Document) aDoc = HYDROData_Document::Document( 1 );
+
+ QString aParamFileName = QDir::tempPath() + QDir::separator() + "parametric.pa";
+ QString aGeorefFileName = QDir::tempPath() + QDir::separator() + "georef.pa";
+ if ( !createTestFile( aParamFileName, true ) || !createTestFile( aGeorefFileName, false ) )
+ return; // No file has been created
+
+ TCollection_AsciiString aFileName( aParamFileName.toStdString().c_str() );
+
+ NCollection_Sequence<int> aBadProfilesList;
+ CPPUNIT_ASSERT( HYDROData_Profile::ImportFromFile( aDoc, aFileName, aBadProfilesList ) );
+
+ int aProfileCount = 0;
+ HYDROData_Iterator aDocIter( aDoc, KIND_PROFILE );
+ for ( ; aDocIter.More(); aDocIter.Next() )
+ {
+ Handle(HYDROData_Profile) aProfile =
+ Handle(HYDROData_Profile)::DownCast( aDocIter.Current() );
+ if ( aProfile.IsNull() )
+ continue;
+
+ CPPUNIT_ASSERT( aProfile->IsValid() == false );
+ CPPUNIT_ASSERT( aProfile->NbPoints() == 5 );
+
+ aProfileCount++;
+ }
+
+ CPPUNIT_ASSERT( aProfileCount == 2 );
+
+ Handle(HYDROData_Profile) aGeorefProfile =
+ Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) );
+
+ aFileName = TCollection_AsciiString( aGeorefFileName.toStdString().c_str() );
+ CPPUNIT_ASSERT( aGeorefProfile->ImportFromFile( aFileName ) );
+
+ // Check validity of imported profile
+ CPPUNIT_ASSERT( aGeorefProfile->IsValid() );
+
+ CPPUNIT_ASSERT( aGeorefProfile->GetTopShape().IsNull() == false );
+
+ aGeorefProfile->Update();
+ CPPUNIT_ASSERT( aGeorefProfile->GetShape3D().IsNull() == false );
+
+ HYDROData_Profile::ProfilePoints aProfilePoints = aGeorefProfile->GetProfilePoints();
+ CPPUNIT_ASSERT( aProfilePoints.Length() == 5 );
+
+ HYDROData_Profile::ProfilePoint aProfilePoint = aProfilePoints.Value( 3 );
+ CPPUNIT_ASSERT( ValuesEquals( aProfilePoint.X(), 1040509.21 ) );
+ CPPUNIT_ASSERT( ValuesEquals( aProfilePoint.Y(), 6788619.81 ) );
+ CPPUNIT_ASSERT( ValuesEquals( aProfilePoint.Z(), 181.63 ) );
+
+ aDoc->Close();
+}
+
+
+void test_HYDROData_Profile::testCopy()
+{
+ Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
+
+ Handle(HYDROData_Profile) aProfile1 =
+ Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) );
+
+ QString aFileName = QDir::tempPath() + QDir::separator() + "georef.pa";
+
+ bool anIsFileCreated = createTestFile( aFileName, false );
+
+ if ( anIsFileCreated )
+ {
+ TCollection_AsciiString anAsciiFileName( aFileName.toStdString().c_str() );
+ CPPUNIT_ASSERT( aProfile1->ImportFromFile( anAsciiFileName ) );
+
+ CPPUNIT_ASSERT( aProfile1->IsValid() );
+ CPPUNIT_ASSERT( aProfile1->NbPoints() == 5 );
+ }
+
+ Handle(HYDROData_Profile) aProfile2 =
+ Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) );
+
+ aProfile1->CopyTo( aProfile2, false );
+
+ if ( anIsFileCreated )
+ {
+ CPPUNIT_ASSERT( aProfile2->IsValid() );
+ CPPUNIT_ASSERT( aProfile2->NbPoints() == 5 );
+ }
+
+ aDoc->Close();
+}
--- /dev/null
+// 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 Handle_HYDROData_Profile;
+class QString;
+
+class test_HYDROData_Profile : public CppUnit::TestFixture {
+ CPPUNIT_TEST_SUITE(test_HYDROData_Profile);
+ CPPUNIT_TEST(testFileImport);
+ CPPUNIT_TEST(testCopy);
+ CPPUNIT_TEST_SUITE_END();
+
+private:
+
+ static bool createTestFile( const QString& theFileName,
+ const bool theIsParametric );
+
+public:
+
+ void setUp() {}
+
+ void tearDown() {}
+
+ // checks file importing information
+ void testFileImport();
+
+ // checks the copy/paste mechanism
+ void testCopy();
+
+};
+
+CPPUNIT_TEST_SUITE_REGISTRATION(test_HYDROData_Profile);
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(test_HYDROData_Profile, "HYDROData_Profile");
--- /dev/null
+// 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_StricklerTable.h>
+#include <HYDROData_Document.h>
+
+void test_HYDROData_StricklerTable::testImport()
+{
+ Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
+
+ Handle(HYDROData_Entity) anObj = aDoc->CreateObject( KIND_STRICKLER_TABLE );
+ TCollection_AsciiString aFileName = "test_name";
+
+ aDoc->Close();
+}
--- /dev/null
+// 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
+//
+
+#ifdef WIN32
+ #pragma warning( disable: 4251 )
+#endif
+
+#include <cppunit/extensions/HelperMacros.h>
+
+class test_HYDROData_StricklerTable : public CppUnit::TestFixture
+{
+ CPPUNIT_TEST_SUITE( test_HYDROData_StricklerTable );
+ CPPUNIT_TEST( testImport );
+ CPPUNIT_TEST_SUITE_END();
+
+public:
+ void testImport();
+};
+
+CPPUNIT_TEST_SUITE_REGISTRATION( test_HYDROData_StricklerTable );
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( test_HYDROData_StricklerTable, "HYDROData_StricklerTable" );
+
+#ifdef WIN32
+ #pragma warning( default: 4251 )
+#endif
--- /dev/null
+// 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
+//
+
+#undef HYDROGUI_EXPORTS
+
+#include <test_HYDROGUI_ListModel.h>
+#include <HYDROData_Document.h>
+#include <HYDROGUI_ListModel.h>
+
+Handle_HYDROData_Document GetDocument()
+{
+ return HYDROData_Document::Document( 0 );
+}
+
+HYDROGUI_ListModel::Object2VisibleList CreateTestObjects( int theObjCount )
+{
+ HYDROGUI_ListModel::Object2VisibleList anObjects;
+
+ for( int i=0; i<theObjCount; i++ )
+ {
+ Handle_HYDROData_Entity anObj = GetDocument()->CreateObject( KIND_IMMERSIBLE_ZONE );
+
+ std::string aName = " ";
+ aName[0] = 'A' + i;
+ anObj->SetName( QString::fromStdString( aName ) );
+
+ bool isVisible = i%2==0;
+
+ anObjects.append( HYDROGUI_ListModel::Object2Visible( anObj, isVisible ) );
+ }
+ return anObjects;
+}
+
+std::string test_HYDROGUI_ListModel::GetObjects( HYDROGUI_ListModel* theModel ) const
+{
+ std::string anObjects;
+ for( int i=0, n=theModel->myObjects.size(); i<n; i++ )
+ {
+ std::string anObjName = theModel->myObjects[i].first->GetName().toStdString();
+ if( theModel->isObjectVisible( i ) )
+ anObjName = "*" + anObjName;
+ if( i>0 )
+ anObjects += ", ";
+ anObjects += anObjName;
+ }
+ return anObjects;
+}
+
+/**
+ Test move up algorithm.
+*/
+void test_HYDROGUI_ListModel::testMoveUp()
+{
+ HYDROGUI_ListModel* aModel = new HYDROGUI_ListModel();
+ aModel->setObjects( CreateTestObjects( 6 ) );
+ const HYDROGUI_ListModel::OpType anUp = HYDROGUI_ListModel::Up;
+
+ // 0. Check the initial state
+ CPPUNIT_ASSERT_EQUAL( std::string( "*A, B, *C, D, *E, F" ), GetObjects( aModel ) );
+
+ // 1. [ *A ] / ALL OBJECTS
+ aModel->move( QList<int>() << 0, anUp, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "*A, B, *C, D, *E, F" ), GetObjects( aModel ) );
+
+ // 2. [ *A, B ] / ALL OBJECTS
+ aModel->move( QList<int>() << 0 << 1, anUp, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "*A, B, *C, D, *E, F" ), GetObjects( aModel ) );
+
+ // 3. [ *A, *C ] / ALL OBJECTS
+ aModel->move( QList<int>() << 0 << 2, anUp, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "*A, B, *C, D, *E, F" ), GetObjects( aModel ) );
+
+ // 4. [ *A, F ] / ALL OBJECTS
+ aModel->move( QList<int>() << 0 << 5, anUp, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "*A, B, *C, D, *E, F" ), GetObjects( aModel ) );
+
+ // 5. [ F ] X 6 times / ALL OBJECTS
+ aModel->move( QList<int>() << 5, anUp, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "*A, B, *C, D, F, *E" ), GetObjects( aModel ) );
+ aModel->move( QList<int>() << 4, anUp, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "*A, B, *C, F, D, *E" ), GetObjects( aModel ) );
+ aModel->move( QList<int>() << 3, anUp, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "*A, B, F, *C, D, *E" ), GetObjects( aModel ) );
+ aModel->move( QList<int>() << 2, anUp, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "*A, F, B, *C, D, *E" ), GetObjects( aModel ) );
+ aModel->move( QList<int>() << 1, anUp, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "F, *A, B, *C, D, *E" ), GetObjects( aModel ) );
+ aModel->move( QList<int>() << 0, anUp, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "F, *A, B, *C, D, *E" ), GetObjects( aModel ) );
+
+ // 6. [ *A, B ] / ALL OBJECTS
+ aModel->move( QList<int>() << 1 << 2, anUp, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "*A, B, F, *C, D, *E" ), GetObjects( aModel ) );
+
+ // 7. [ B, *C, *E ] / ALL OBJECTS
+ aModel->move( QList<int>() << 1 << 3 << 5, anUp, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "B, *A, *C, F, *E, D" ), GetObjects( aModel ) );
+
+ // 8. [ *A, *C, F, *E, D ] / ALL OBJECTS
+ aModel->move( QList<int>() << 1 << 2 << 3 << 4 << 5, anUp, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "*A, *C, F, *E, D, B" ), GetObjects( aModel ) );
+
+ // 9. [ *E ] / VISIBLE OBJECTS
+ aModel->move( QList<int>() << 3, anUp, true );
+ CPPUNIT_ASSERT_EQUAL( std::string( "*A, *E, *C, F, D, B" ), GetObjects( aModel ) );
+
+ // 10. [ *E, *C ] / VISIBLE OBJECTS
+ aModel->move( QList<int>() << 1 << 2, anUp, true );
+ CPPUNIT_ASSERT_EQUAL( std::string( "*E, *C, *A, F, D, B" ), GetObjects( aModel ) );
+
+ // 11. [ *A, F ] / ALL OBJECTS
+ aModel->move( QList<int>() << 2 << 3, anUp, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "*E, *A, F, *C, D, B" ), GetObjects( aModel ) );
+
+ // 12. [ *A, *C ] / VISIBLE OBJECTS
+ aModel->move( QList<int>() << 1 << 3, anUp, true );
+ CPPUNIT_ASSERT_EQUAL( std::string( "*A, *C, *E, F, D, B" ), GetObjects( aModel ) );
+
+ // 13. [] / ALL OBJECTS
+ aModel->move( QList<int>(), anUp, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "*A, *C, *E, F, D, B"), GetObjects( aModel ) );
+
+ // 14. [ *A, *C, *E, F, D, B ] / ALL OBJECTS
+ aModel->move( QList<int>() << 0 << 1 << 2 << 3 << 4 << 5, anUp, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "*A, *C, *E, F, D, B"), GetObjects( aModel ) );
+
+ delete aModel;
+}
+
+/**
+ Test move on top algorithm.
+*/
+void test_HYDROGUI_ListModel::testMoveOnTop()
+{
+ HYDROGUI_ListModel* aModel = new HYDROGUI_ListModel();
+ aModel->setObjects( CreateTestObjects( 6 ) );
+ const HYDROGUI_ListModel::OpType aTop = HYDROGUI_ListModel::Top;
+
+ // 0. Check the initial state
+ CPPUNIT_ASSERT_EQUAL( std::string( "*A, B, *C, D, *E, F" ), GetObjects( aModel ) );
+
+ // 1. [ *A ] / ALL OBJECTS
+ aModel->move( QList<int>() << 0, aTop, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "*A, B, *C, D, *E, F" ), GetObjects( aModel ) );
+
+ // 2. [ *A ] / VISIBLE OBJECTS
+ aModel->move( QList<int>() << 0, aTop, true );
+ CPPUNIT_ASSERT_EQUAL( std::string( "*A, B, *C, D, *E, F" ), GetObjects( aModel ) );
+
+ // 3. [ F ] / ALL OBJECTS
+ aModel->move( QList<int>() << 5, aTop, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "F, *A, B, *C, D, *E" ), GetObjects( aModel ) );
+
+ // 4. [ *E ] / VISIBLE OBJECTS
+ aModel->move( QList<int>() << 5, aTop, true );
+ CPPUNIT_ASSERT_EQUAL( std::string( "*E, F, *A, B, *C, D" ), GetObjects( aModel ) );
+
+ // 5. [ *E, F ] / ALL OBJECTS
+ aModel->move( QList<int>() << 0 << 1, aTop, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "*E, F, *A, B, *C, D" ), GetObjects( aModel ) );
+
+ // 6. [ *E, *A ] / ALL OBJECTS
+ aModel->move( QList<int>() << 0 << 2, aTop, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "*E, *A, F, B, *C, D" ), GetObjects( aModel ) );
+
+ // 7. [ *A, F, *C ] / ALL OBJECTS
+ aModel->move( QList<int>() << 1 << 2 << 4, aTop, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "*A, F, *C, *E, B, D" ), GetObjects( aModel ) );
+
+ // 8. [ F, *C, *E, B, D ] / ALL OBJECTS
+ aModel->move( QList<int>() << 1 << 2 << 3 << 4 << 5, aTop, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "F, *C, *E, B, D, *A" ), GetObjects( aModel ) );
+
+ // 9. [] / ALL OBJECTS
+ aModel->move( QList<int>(), aTop, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "F, *C, *E, B, D, *A" ), GetObjects( aModel ) );
+
+ // 10. [*F, *C, *E, B, D, *A] / ALL OBJECTS
+ aModel->move( QList<int>() << 0 << 1 << 2 << 3 << 4 << 5, aTop, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "F, *C, *E, B, D, *A" ), GetObjects( aModel ) );
+
+ delete aModel;
+}
+
+/**
+ Test move down algorithm.
+*/
+void test_HYDROGUI_ListModel::testMoveDown()
+{
+ HYDROGUI_ListModel* aModel = new HYDROGUI_ListModel();
+ aModel->setObjects( CreateTestObjects( 6 ) );
+ const HYDROGUI_ListModel::OpType aDown = HYDROGUI_ListModel::Down;
+
+ // 0. Check the initial state
+ CPPUNIT_ASSERT_EQUAL( std::string( "*A, B, *C, D, *E, F" ), GetObjects( aModel ) );
+
+ // 1. [ F ] / ALL OBJECTS
+ aModel->move( QList<int>() << 5, aDown, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "*A, B, *C, D, *E, F" ), GetObjects( aModel ) );
+
+ // 2. [ *E, F ] / ALL OBJECTS
+ aModel->move( QList<int>() << 4 << 5, aDown, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "*A, B, *C, D, *E, F" ), GetObjects( aModel ) );
+
+ // 3. [ D, F ] / ALL OBJECTS
+ aModel->move( QList<int>() << 3 << 5, aDown, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "*A, B, *C, D, *E, F" ), GetObjects( aModel ) );
+
+ // 4. [ *A, F ] / ALL OBJECTS
+ aModel->move( QList<int>() << 0 << 5, aDown, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "*A, B, *C, D, *E, F" ), GetObjects( aModel ) );
+
+ // 5. [ *A ] X 6 times / ALL OBJECTS
+ aModel->move( QList<int>() << 0, aDown, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "B, *A, *C, D, *E, F" ), GetObjects( aModel ) );
+ aModel->move( QList<int>() << 1, aDown, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "B, *C, *A, D, *E, F" ), GetObjects( aModel ) );
+ aModel->move( QList<int>() << 2, aDown, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "B, *C, D, *A, *E, F" ), GetObjects( aModel ) );
+ aModel->move( QList<int>() << 3, aDown, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "B, *C, D, *E, *A, F" ), GetObjects( aModel ) );
+ aModel->move( QList<int>() << 4, aDown, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "B, *C, D, *E, F, *A" ), GetObjects( aModel ) );
+ aModel->move( QList<int>() << 5, aDown, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "B, *C, D, *E, F, *A" ), GetObjects( aModel ) );
+
+ // 6. [ *E, *F ] / ALL OBJECTS
+ aModel->move( QList<int>() << 3 << 4, aDown, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "B, *C, D, *A, *E, F" ), GetObjects( aModel ) );
+
+ // 7. [ B, D, *E ] / ALL OBJECTS
+ aModel->move( QList<int>() << 0 << 2 << 4, aDown, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "*C, B, *A, D, F, *E" ), GetObjects( aModel ) );
+
+ // 8. [ *C, B, *A, D, F ] / ALL OBJECTS
+ aModel->move( QList<int>() << 0 << 1 << 2 << 3 << 4, aDown, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "*E, *C, B, *A, D, F" ), GetObjects( aModel ) );
+
+ // 9. [ *C ] / VISIBLE OBJECTS
+ aModel->move( QList<int>() << 1, aDown, true );
+ CPPUNIT_ASSERT_EQUAL( std::string( "*E, B, *A, *C, D, F" ), GetObjects( aModel ) );
+
+ // 10. [ *E, *A ] / VISIBLE OBJECTS
+ aModel->move( QList<int>() << 0 << 2, aDown, true );
+ CPPUNIT_ASSERT_EQUAL( std::string( "B, *C, *E, *A, D, F" ), GetObjects( aModel ) );
+
+ // 11. [ *E, *A ] / VISIBLE OBJECTS
+ aModel->move( QList<int>() << 2 << 3, aDown, true );
+ CPPUNIT_ASSERT_EQUAL( std::string( "B, *C, *E, *A, D, F" ), GetObjects( aModel ) );
+
+ // 12. [ *C, *E, *A ] / VISIBLE OBJECTS
+ aModel->move( QList<int>() << 1 << 2 << 3, aDown, true );
+ CPPUNIT_ASSERT_EQUAL( std::string( "B, *C, *E, *A, D, F" ), GetObjects( aModel ) );
+
+ // 13. [] / ALL OBJECTS
+ aModel->move( QList<int>(), aDown, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "B, *C, *E, *A, D, F"), GetObjects( aModel ) );
+
+ // 14. [ B, *C, *E, *A, D, F ] / ALL OBJECTS
+ aModel->move( QList<int>() << 0 << 1 << 2 << 3 << 4 << 5, aDown, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "B, *C, *E, *A, D, F"), GetObjects( aModel ) );
+
+ delete aModel;
+}
+
+/**
+ Test move on bottom algorithm.
+*/
+void test_HYDROGUI_ListModel::testMoveOnBottom()
+{
+ HYDROGUI_ListModel* aModel = new HYDROGUI_ListModel();
+ aModel->setObjects( CreateTestObjects( 6 ) );
+ const HYDROGUI_ListModel::OpType aBottom = HYDROGUI_ListModel::Bottom;
+
+ // 0. Check the initial state
+ CPPUNIT_ASSERT_EQUAL( std::string( "*A, B, *C, D, *E, F" ), GetObjects( aModel ) );
+
+ // 1. [ F ] / ALL OBJECTS
+ aModel->move( QList<int>() << 5, aBottom, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "*A, B, *C, D, *E, F" ), GetObjects( aModel ) );
+
+ // 2. [ F ] / VISIBLE OBJECTS
+ aModel->move( QList<int>() << 5, aBottom, true );
+ CPPUNIT_ASSERT_EQUAL( std::string( "*A, B, *C, D, *E, F" ), GetObjects( aModel ) );
+
+ // 3. [ *A ] / ALL OBJECTS
+ aModel->move( QList<int>() << 0, aBottom, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "B, *C, D, *E, F, *A" ), GetObjects( aModel ) );
+
+ // 4. [ *C ] / VISIBLE OBJECTS
+ aModel->move( QList<int>() << 1, aBottom, true );
+ CPPUNIT_ASSERT_EQUAL( std::string( "B, D, *E, F, *A, *C" ), GetObjects( aModel ) );
+
+ // 5. [ B, D ] / ALL OBJECTS
+ aModel->move( QList<int>() << 0 << 1, aBottom, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "*E, F, *A, *C, B, D" ), GetObjects( aModel ) );
+
+ // 6. [ *C, *D ] / ALL OBJECTS
+ aModel->move( QList<int>() << 3 << 5, aBottom, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "*E, F, *A, B, *C, D" ), GetObjects( aModel ) );
+
+ // 7. [ *E, *A, *C ] / ALL OBJECTS
+ aModel->move( QList<int>() << 0 << 2 << 4, aBottom, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "F, B, D, *E, *A, *C" ), GetObjects( aModel ) );
+
+ // 8. [ B, D, *E, *A ] / ALL OBJECTS
+ aModel->move( QList<int>() << 1 << 2 << 3 << 4 , aBottom, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "F, *C, B, D, *E, *A" ), GetObjects( aModel ) );
+
+ // 9. [] / ALL OBJECTS
+ aModel->move( QList<int>(), aBottom, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "F, *C, B, D, *E, *A" ), GetObjects( aModel ) );
+
+ // 10. [F, *C, B, D, *E, *A] / ALL OBJECTS
+ aModel->move( QList<int>() << 0 << 1 << 2 << 3 << 4 << 5, aBottom, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "F, *C, B, D, *E, *A" ), GetObjects( aModel ) );
+
+ delete aModel;
+}
+
+/**
+ Test drag and drop algorithm.
+*/
+void test_HYDROGUI_ListModel::testDragAndDrop()
+{
+ HYDROGUI_ListModel* aModel = new HYDROGUI_ListModel();
+ aModel->setObjects( CreateTestObjects( 8 ) );
+ const HYDROGUI_ListModel::OpType aDnD = HYDROGUI_ListModel::DragAndDrop;
+
+ // 0. Check the initial state
+ std::string anInitialState = std::string( "*A, B, *C, D, *E, F, *G, H" );
+ CPPUNIT_ASSERT_EQUAL( anInitialState, GetObjects( aModel ) );
+
+ // 1. [] -> B ( i=1 )
+ bool aRes = aModel->move( QList<int>(), aDnD, false, 1 );
+ CPPUNIT_ASSERT_EQUAL( false, aRes );
+ CPPUNIT_ASSERT_EQUAL( anInitialState, GetObjects( aModel ) );
+
+ // 2. ALL -> B ( i=1 )
+ QList<int> anAll;
+ anAll << 0 << 1 << 2 << 3 << 4 << 5 << 6 << 7;
+ aRes = aModel->move( anAll, aDnD, false, 1 );
+ CPPUNIT_ASSERT_EQUAL( false, aRes );
+ CPPUNIT_ASSERT_EQUAL( anInitialState, GetObjects( aModel ) );
+
+ // 3. [D, *E, *G] -> D : drop item is among dragged items ( at the beginning )
+ aRes = aModel->move( QList<int>() << 3 << 4 << 6, aDnD, false, 3 );
+ CPPUNIT_ASSERT_EQUAL( false, aRes );
+ CPPUNIT_ASSERT_EQUAL( anInitialState, GetObjects( aModel ) );
+
+ // 4. [D, *E, *G] -> *E : drop item is among dragged items ( in the middle )
+ aRes = aModel->move( QList<int>() << 3 << 4 << 6, aDnD, false, 4 );
+ CPPUNIT_ASSERT_EQUAL( false, aRes );
+ CPPUNIT_ASSERT_EQUAL( anInitialState, GetObjects( aModel ) );
+
+ // 5. [D, *E, *G] -> *G : drop item is among dragged items ( at the end )
+ aRes = aModel->move( QList<int>() << 3 << 4 << 6, aDnD, false, 6 );
+ CPPUNIT_ASSERT_EQUAL( false, aRes );
+ CPPUNIT_ASSERT_EQUAL( anInitialState, GetObjects( aModel ) );
+
+ // 6. [D, *E, *G] -> -1 : drop item index is out of range ( less than zero )
+ aRes = aModel->move( QList<int>() << 3 << 4 << 6, aDnD, false, -1 );
+ CPPUNIT_ASSERT_EQUAL( false, aRes );
+ CPPUNIT_ASSERT_EQUAL( anInitialState, GetObjects( aModel ) );
+
+ // 7. [D, *E, *G] -> -1 : drop item index is out of range ( more than than list length )
+ aRes = aModel->move( QList<int>() << 3 << 4 << 6, aDnD, false, 9 );
+ CPPUNIT_ASSERT_EQUAL( false, aRes );
+ CPPUNIT_ASSERT_EQUAL( anInitialState, GetObjects( aModel ) );
+
+ // 8. [D, *E, *G] -> B ( i = 1 )
+ aRes = aModel->move( QList<int>() << 3 << 4 << 6, aDnD, false, 1 );
+ CPPUNIT_ASSERT_EQUAL( true, aRes );
+ CPPUNIT_ASSERT_EQUAL( std::string( "*A, D, *E, *G, B, *C, F, H" ), GetObjects( aModel ) );
+
+ // 9. [*E, F] -> *G
+ aRes = aModel->move( QList<int>() << 2 << 6, aDnD, false, 3 );
+ CPPUNIT_ASSERT_EQUAL( true, aRes );
+ CPPUNIT_ASSERT_EQUAL( std::string( "*A, D, *E, F, *G, B, *C, H" ), GetObjects( aModel ) );
+
+ // 10. [*E, F, *G] -> *A
+ aRes = aModel->move( QList<int>() << 2 << 3 << 4, aDnD, false, 0 );
+ CPPUNIT_ASSERT_EQUAL( true, aRes );
+ CPPUNIT_ASSERT_EQUAL( std::string( "*E, F, *G, *A, D, B, *C, H" ), GetObjects( aModel ) );
+
+ // 11. [*G, D, *C, H] -> B
+ aRes = aModel->move( QList<int>() << 2 << 4 << 6 << 7, aDnD, false, 5 );
+ CPPUNIT_ASSERT_EQUAL( true, aRes );
+ CPPUNIT_ASSERT_EQUAL( std::string( "*E, F, *A, *G, D, *C, H, B" ), GetObjects( aModel ) );
+
+ // 12. [F, *A, *G, D, *C, H, B] -> *E
+ QList<int> anAllWithoutFirst;
+ anAllWithoutFirst << 1 << 2 << 3 << 4 << 5 << 6 << 7;
+ aRes = aModel->move( anAllWithoutFirst, aDnD, false, 0 );
+ CPPUNIT_ASSERT_EQUAL( true, aRes );
+ CPPUNIT_ASSERT_EQUAL( std::string( "F, *A, *G, D, *C, H, B, *E" ), GetObjects( aModel ) );
+
+ // 13. [*A, *G] -> D : no changes
+ aRes = aModel->move( QList<int>() << 1 << 2, aDnD, false, 3 );
+ CPPUNIT_ASSERT_EQUAL( true, aRes );
+ CPPUNIT_ASSERT_EQUAL( std::string( "F, *A, *G, D, *C, H, B, *E" ), GetObjects( aModel ) );
+
+ // 14. [F, *G] -> D
+ aRes = aModel->move( QList<int>() << 0 << 2, aDnD, false, 3 );
+ CPPUNIT_ASSERT_EQUAL( true, aRes );
+ CPPUNIT_ASSERT_EQUAL( std::string( "*A, F, *G, D, *C, H, B, *E" ), GetObjects( aModel ) );
+
+ // 15. [*A, *G, *C, H, *E] -> D
+ aRes = aModel->move( QList<int>() << 0 << 2 << 4 << 5 << 7, aDnD, false, 3 );
+ CPPUNIT_ASSERT_EQUAL( true, aRes );
+ CPPUNIT_ASSERT_EQUAL( std::string( "F, *A, *G, *C, H, *E, D, B" ), GetObjects( aModel ) );
+}
\ No newline at end of file
--- /dev/null
+// 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 HYDROGUI_ListModel;
+
+class test_HYDROGUI_ListModel : public CppUnit::TestFixture {
+ CPPUNIT_TEST_SUITE(test_HYDROGUI_ListModel);
+ CPPUNIT_TEST(testMoveUp);
+ CPPUNIT_TEST(testMoveOnTop);
+ CPPUNIT_TEST(testMoveDown);
+ CPPUNIT_TEST(testMoveOnBottom);
+ CPPUNIT_TEST(testDragAndDrop);
+ CPPUNIT_TEST_SUITE_END();
+
+private:
+ std::string GetObjects( HYDROGUI_ListModel* theModel ) const;
+
+public:
+ void testMoveUp();
+ void testMoveOnTop();
+ void testMoveDown();
+ void testMoveOnBottom();
+ void testDragAndDrop();
+};
+
+CPPUNIT_TEST_SUITE_REGISTRATION(test_HYDROGUI_ListModel);
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(test_HYDROGUI_ListModel, "HYDROGUI_ListModel");
--- /dev/null
+// 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/TestFactoryRegistry.h>
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/TestResult.h>
+#include <cppunit/TestResultCollector.h>
+#include <cppunit/TestRunner.h>
+#include <cppunit/TextTestProgressListener.h>
+#include <stdexcept>
+#include <QApplication>
+
+int main( int argc, char* argv[] )
+{
+ QApplication anApp( argc, argv );
+
+ std::string testPath = (argc > 1) ? std::string(argv[1]) : "";
+
+ // Create the event manager and test controller
+ CppUnit::TestResult controller;
+
+ // Add a listener that colllects test result
+ CppUnit::TestResultCollector result;
+ controller.addListener( &result );
+
+ // Add a listener that print dots as test run.
+ CppUnit::TextTestProgressListener progress;
+ controller.addListener( &progress );
+
+ CppUnit::TestFactoryRegistry& registry =
+ CppUnit::TestFactoryRegistry::getRegistry();
+ // Add the top suite to the test runner
+ CppUnit::TestRunner runner;
+ runner.addTest( registry.makeTest() );
+ try
+ {
+ std::cout << "Running " << testPath;
+ runner.run( controller, testPath );
+
+ std::cerr << std::endl;
+
+ // Print test in a compiler compatible format.
+ CppUnit::CompilerOutputter outputter( &result, std::cerr );
+ outputter.write();
+ }
+ catch ( std::invalid_argument &e ) // Test path not resolved
+ {
+ std::cerr << std::endl
+ << "ERROR: " << e.what()
+ << std::endl;
+ return 0;
+ }
+
+ return result.wasSuccessful() ? 0 : 1;
+}