]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
test for polyline presentation
authorasl <asl@opencascade.com>
Wed, 21 Oct 2015 14:25:31 +0000 (17:25 +0300)
committerasl <asl@opencascade.com>
Wed, 21 Oct 2015 14:25:31 +0000 (17:25 +0300)
src/HYDROData/HYDROData_BSplineOperation.cxx
src/HYDROGUI/HYDROGUI_Polyline.cxx
src/HYDRO_tests/CMakeLists.txt
src/HYDRO_tests/ExternalFiles.cmake
src/HYDRO_tests/TestViewer.cxx
src/HYDRO_tests/reference_data/Polyline_Presentation.png [new file with mode: 0644]
src/HYDRO_tests/test_HYDROData_PolylineXY.cxx
src/HYDRO_tests/test_HYDROData_PolylineXY.h

index 058005d9fdc62d228ad29fc929ecba8f07ac42c7..64ae37d4cb6ce8342354165aaafc3bf44e8d304b 100644 (file)
@@ -23,9 +23,7 @@
 #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,
@@ -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)();
 }
 
index 91e0a06ab5c10de7e1653de9b4776db9f950ce4c..4f070b47c634761832d79a24ef1b43df8269f823 100644 (file)
@@ -26,6 +26,7 @@
 #include <BRep_Tool.hxx>
 #include <GCPnts_AbscissaPoint.hxx>
 #include <GeomAdaptor_Curve.hxx>
+#include <Graphic3d_AspectLine3d.hxx>
 #include <gp_Pnt.hxx>
 #include <gp_Dir.hxx>
 #include <Prs3d_Arrow.hxx>
@@ -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 );
+    }
   }
 
    
index 7f1e99b18b9bf961c8536cb089bc81f5992f0405..14b5b4dcbc00134ae73fe1dc01711709dcb7c7aa 100644 (file)
@@ -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" )
index 663cd087710813dcf6c8417bff76ea16a1aae3c9..7ccb5c2661fec8db99807a35ca53e797de636b3e 100644 (file)
@@ -56,4 +56,5 @@ set( EXTERNAL_FILES
   ../HYDROGUI/HYDROGUI_ListModel.cxx
   ../HYDROGUI/HYDROGUI_DataObject.cxx
   ../HYDROGUI/HYDROGUI_LandCoverMapPrs.cxx
+  ../HYDROGUI/HYDROGUI_Polyline.cxx
 )
index d6ae86ff128f2186488e5a257d3f90398a96a13d..44e3fc2c94f869f4d78c2cd614ea5c6e6fae2274 100644 (file)
@@ -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 (file)
index 0000000..acbf866
Binary files /dev/null and b/src/HYDRO_tests/reference_data/Polyline_Presentation.png differ
index a311e48d3761a2533297ce4317f6b5998617ab58..e11b3a2366559564159ae82d72547512f3f98a01 100644 (file)
 #include <HYDROData_Iterator.h>
 #include <HYDROData_ImmersibleZone.h>
 #include <HYDROData_Tool.h>
+#include <HYDROGUI_Polyline.h>
 
 #include <AIS_DisplayMode.hxx>
+#include <AIS_PointCloud.hxx>
+#include <Prs3d_LineAspect.hxx>
+#include <Prs3d_PointAspect.hxx>
+#include <TColgp_HArray1OfPnt.hxx>
 #include <QColor>
 #include <QList>
 #include <QPointF>
@@ -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<gp_XY> aPoints = QList<gp_XY>() << 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();
+}
index cf58c980de2a663995b2d92e3f7fccb35e0475e1..dde745393231b13310496eaa718aa40b26156389 100644 (file)
@@ -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);