From: asl Date: Wed, 21 Oct 2015 14:25:31 +0000 (+0300) Subject: test for polyline presentation X-Git-Tag: v1.5~75^2~11 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=73c6183c872b9bef4db51730512666316f055553;p=modules%2Fhydro.git test for polyline presentation --- diff --git a/src/HYDROData/HYDROData_BSplineOperation.cxx b/src/HYDROData/HYDROData_BSplineOperation.cxx index 058005d9..64ae37d4 100644 --- a/src/HYDROData/HYDROData_BSplineOperation.cxx +++ b/src/HYDROData/HYDROData_BSplineOperation.cxx @@ -23,9 +23,7 @@ #include #include -#ifndef LIGHT_MODE #include -#endif Handle(Geom_BSplineCurve) HYDROData_BSplineOperation::ComputeCurve( const NCollection_Sequence& thePoints, @@ -58,11 +56,9 @@ Handle(Geom_BSplineCurve) HYDROData_BSplineOperation::ComputeCurve( // compute BSpline Handle(Geom_BSplineCurve) aBSpline; -#ifndef LIGHT_MODE if( CurveCreator_Utils::constructBSpline( aHCurvePoints, theIsClosed, aBSpline ) ) return aBSpline; else -#endif return Handle(Geom_BSplineCurve)(); } diff --git a/src/HYDROGUI/HYDROGUI_Polyline.cxx b/src/HYDROGUI/HYDROGUI_Polyline.cxx index 91e0a06a..4f070b47 100644 --- a/src/HYDROGUI/HYDROGUI_Polyline.cxx +++ b/src/HYDROGUI/HYDROGUI_Polyline.cxx @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -82,8 +83,11 @@ void HYDROGUI_Polyline::Compute(const Handle(PrsMgr_PresentationManager3d)& aPre aPrs->Clear(); Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup( aPrs ); - Handle(Graphic3d_AspectLine3d) anAspect = Attributes()->FaceBoundaryAspect()->Aspect(); - aGroup->SetGroupPrimitivesAspect( anAspect ); + Quantity_Color aColor; + Aspect_TypeOfLine aType; + Standard_Real anWidth; + Attributes()->LineAspect()->Aspect()->Values( aColor, aType, anWidth ); + Handle(Graphic3d_AspectLine3d) anAspect = new Graphic3d_AspectLine3d( aColor, aType, anWidth ); TopExp_Explorer Exp1 ( myshape, TopAbs_EDGE ); for ( ; Exp1.More(); Exp1.Next() ) @@ -91,7 +95,10 @@ void HYDROGUI_Polyline::Compute(const Handle(PrsMgr_PresentationManager3d)& aPre TopoDS_Edge anEdge = TopoDS::Edge( Exp1.Current() ); Handle( Graphic3d_ArrayOfPolylines ) anArray = BuildEdgePresentation( anEdge, 0.1 ); if( !anArray.IsNull() ) - aGroup->AddPrimitiveArray ( anArray ); + { + aGroup->SetPrimitivesAspect( anAspect ); + aGroup->AddPrimitiveArray( anArray ); + } } diff --git a/src/HYDRO_tests/CMakeLists.txt b/src/HYDRO_tests/CMakeLists.txt index 7f1e99b1..14b5b4dc 100644 --- a/src/HYDRO_tests/CMakeLists.txt +++ b/src/HYDRO_tests/CMakeLists.txt @@ -59,6 +59,7 @@ SET( CPPUNIT_INCLUDES $ENV{CPPUNIT_ROOT_DIR}/include ) SET( CAS_INCLUDES $ENV{CAS_ROOT_DIR}/inc ) SET( QT_INCLUDES $ENV{QT4_ROOT_DIR}/include $ENV{QT4_ROOT_DIR}/include/QtCore $ENV{QT4_ROOT_DIR}/include/QtGui $ENV{QT4_ROOT_DIR}/include/QtTest ) SET( GUI_INCLUDES $ENV{GUI_ROOT_DIR}/include/salome ) +SET( GEOM_INCLUDES $ENV{GEOM_ROOT_DIR}/include/salome ) IF( ${WIN32} ) link_directories( $ENV{CAS_ROOT_DIR}/win32/libd ) @@ -81,8 +82,9 @@ ELSE() SET( CPPUNIT_LIBRARIES cppunit ) ENDIF() -link_directories( $ENV{GUI_ROOT_DIR}/lib/salome ) +link_directories( $ENV{GUI_ROOT_DIR}/lib/salome $ENV{GEOM_ROOT_DIR}/lib/salome ) SET( GUI_LIBRARIES ImageComposer qtx suit LightApp CAM OCCViewer ) +SET( GEOM_LIBRARIES CurveCreator ) include_directories( ${BOOST_INCLUDES} @@ -90,6 +92,7 @@ include_directories( ${QT_INCLUDES} ${CPPUNIT_INCLUDES} ${GUI_INCLUDES} + ${GEOM_INCLUDES} ${CMAKE_CURRENT_SOURCE_DIR}/../HYDROData ${CMAKE_CURRENT_SOURCE_DIR}/../HYDROGUI ${CMAKE_CURRENT_SOURCE_DIR}/../shapelib @@ -98,7 +101,7 @@ include_directories( source_group( "External files" FILES ${EXTERNAL_FILES} ) add_executable( HYDROData_tests ${PROJECT_SOURCES} ${PROJECT_HEADERS} ${EXTERNAL_FILES} ) -target_link_libraries( HYDROData_tests ${GUI_LIBRARIES} ${CAS_LIBRARIES} ${QT_LIBRARIES} ${CPPUNIT_LIBRARIES} shapelib ) +target_link_libraries( HYDROData_tests ${GUI_LIBRARIES} ${GEOM_LIBRARIES} ${CAS_LIBRARIES} ${QT_LIBRARIES} ${CPPUNIT_LIBRARIES} shapelib ) IF( ${WIN32} ) add_custom_command( TARGET HYDROData_tests POST_BUILD COMMAND $(TargetPath) COMMENT "Running tests" ) diff --git a/src/HYDRO_tests/ExternalFiles.cmake b/src/HYDRO_tests/ExternalFiles.cmake index 663cd087..7ccb5c26 100644 --- a/src/HYDRO_tests/ExternalFiles.cmake +++ b/src/HYDRO_tests/ExternalFiles.cmake @@ -56,4 +56,5 @@ set( EXTERNAL_FILES ../HYDROGUI/HYDROGUI_ListModel.cxx ../HYDROGUI/HYDROGUI_DataObject.cxx ../HYDROGUI/HYDROGUI_LandCoverMapPrs.cxx + ../HYDROGUI/HYDROGUI_Polyline.cxx ) diff --git a/src/HYDRO_tests/TestViewer.cxx b/src/HYDRO_tests/TestViewer.cxx index d6ae86ff..44e3fc2c 100644 --- a/src/HYDRO_tests/TestViewer.cxx +++ b/src/HYDRO_tests/TestViewer.cxx @@ -89,17 +89,21 @@ QColor TestViewer::GetColor(int i) void TestViewer::show( const Handle(AIS_InteractiveObject)& theObject, int theMode, int theSelectionMode, bool isFitAll, const char* theKey ) { - context()->CloseLocalContext(); - context()->EraseAll( Standard_False ); + QString aNewKey = theKey; + if( !aNewKey.isEmpty() ) + { + myKey = aNewKey; + context()->CloseLocalContext(); + context()->EraseAll( Standard_False ); + } + + context()->Display( theObject, theMode, theSelectionMode ); if( theSelectionMode > 0 ) { - context()->Display( theObject, theMode, theSelectionMode ); context()->OpenLocalContext(); context()->Activate( theObject, theSelectionMode, Standard_True ); } - myKey = theKey; - if( isFitAll ) { viewWindow()->onTopView(); diff --git a/src/HYDRO_tests/reference_data/Polyline_Presentation.png b/src/HYDRO_tests/reference_data/Polyline_Presentation.png new file mode 100644 index 00000000..acbf8663 Binary files /dev/null and b/src/HYDRO_tests/reference_data/Polyline_Presentation.png differ diff --git a/src/HYDRO_tests/test_HYDROData_PolylineXY.cxx b/src/HYDRO_tests/test_HYDROData_PolylineXY.cxx index a311e48d..e11b3a23 100644 --- a/src/HYDRO_tests/test_HYDROData_PolylineXY.cxx +++ b/src/HYDRO_tests/test_HYDROData_PolylineXY.cxx @@ -27,8 +27,13 @@ #include #include #include +#include #include +#include +#include +#include +#include #include #include #include @@ -157,7 +162,7 @@ void test_HYDROData_PolylineXY::test_extraction_immersible_zone() void test_HYDROData_PolylineXY::test_extraction_channel_refs_611() { -Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1); + Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1); Handle(HYDROData_PolylineXY) aPolyline2d = Handle(HYDROData_PolylineXY)::DownCast( aDoc->CreateObject( KIND_POLYLINEXY ) ); @@ -211,3 +216,50 @@ Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1); aDoc->Close(); } + +void test_HYDROData_PolylineXY::test_presentation() +{ + Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1); + + Handle(HYDROData_PolylineXY) aPolyline2d = + Handle(HYDROData_PolylineXY)::DownCast( aDoc->CreateObject( KIND_POLYLINEXY ) ); + aPolyline2d->SetName( "polyline2d_1" ); + aPolyline2d->AddSection( "", HYDROData_IPolyline::SECTION_SPLINE, false ); + + QList aPoints = QList() << gp_XY( 0, 0 ) + << gp_XY( 10, 10 ) + << gp_XY( 20, 40 ) + << gp_XY( 30, 10 ) + << gp_XY( 40, 50 ) + << gp_XY( 50, 60 ) + << gp_XY( -10, 40 ) + << gp_XY( -9, 39 ) + << gp_XY( -8, 38 ) + << gp_XY( 0, 20 ); + Handle(TColgp_HArray1OfPnt) aPnts = new TColgp_HArray1OfPnt( 1, aPoints.size() ); + int i = 1; + foreach( gp_XY aPoint, aPoints ) + { + aPolyline2d->AddPoint( 0, aPoint ); + aPnts->SetValue( i, gp_Pnt( aPoint.X(), aPoint.Y(), 0 ) ); + i++; + } + aPolyline2d->Update(); + + CPPUNIT_ASSERT_EQUAL( false, (bool)aPolyline2d->GetShape().IsNull() ); + + Handle(AIS_PointCloud) aPointsPrs = new AIS_PointCloud(); + aPointsPrs->SetPoints( aPnts ); + aPointsPrs->SetColor( Quantity_NOC_BLUE1 ); + aPointsPrs->Attributes()->PointAspect()->SetTypeOfMarker( Aspect_TOM_O ); + + Handle(HYDROGUI_Polyline) aNewPolylinePrs = new HYDROGUI_Polyline( aPolyline2d->GetShape() ); + aNewPolylinePrs->SetColor( Quantity_NOC_DARKGREEN ); + + TestViewer::show( aPointsPrs, AIS_PointCloud::DM_Points, 0, true, "Polyline_Presentation" ); + TestViewer::show( aPolyline2d->GetShape(), 0, true, Qt::red ); + TestViewer::show( aNewPolylinePrs, AIS_PointCloud::DM_Points, 0, true, "" ); + CPPUNIT_ASSERT_IMAGES + + aDoc->Close(); +} diff --git a/src/HYDRO_tests/test_HYDROData_PolylineXY.h b/src/HYDRO_tests/test_HYDROData_PolylineXY.h index cf58c980..dde74539 100644 --- a/src/HYDRO_tests/test_HYDROData_PolylineXY.h +++ b/src/HYDRO_tests/test_HYDROData_PolylineXY.h @@ -23,6 +23,7 @@ class test_HYDROData_PolylineXY : public CppUnit::TestFixture { CPPUNIT_TEST( testPolyline ); CPPUNIT_TEST( testCopy ); CPPUNIT_TEST( testSplit_refs_624 ); + CPPUNIT_TEST( test_presentation ); CPPUNIT_TEST( test_extraction_immersible_zone ); CPPUNIT_TEST( test_extraction_channel_refs_611 ); CPPUNIT_TEST_SUITE_END(); @@ -45,6 +46,7 @@ public: void test_extraction_immersible_zone(); void test_extraction_channel_refs_611(); + void test_presentation(); }; CPPUNIT_TEST_SUITE_REGISTRATION(test_HYDROData_PolylineXY);