From: asl Date: Tue, 20 Oct 2015 10:12:22 +0000 (+0300) Subject: Merge remote-tracking branch 'origin/BR_LAND_COVER_MAP' into BR_LAND_COVER_REMOVING X-Git-Tag: v1.5~78^2~1^2~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=dcc909ad422bdc89b0fdcf7fb21df1db6271c88d;p=modules%2Fhydro.git Merge remote-tracking branch 'origin/BR_LAND_COVER_MAP' into BR_LAND_COVER_REMOVING Conflicts: src/HYDRO_tests/TestViewer.cxx src/HYDRO_tests/test_HYDROData_LandCoverMap.cxx src/HYDRO_tests/test_HYDROData_LandCoverMap.h --- dcc909ad422bdc89b0fdcf7fb21df1db6271c88d diff --cc src/HYDRO_tests/TestViewer.cxx index 6cf7242f,7dcec1aa..fd8c5f86 --- a/src/HYDRO_tests/TestViewer.cxx +++ b/src/HYDRO_tests/TestViewer.cxx @@@ -1,9 -1,7 +1,8 @@@ #include -//#include +#include - #include #include +#include #ifdef WIN32 #pragma warning ( disable: 4251 ) #endif @@@ -68,35 -65,28 +67,39 @@@ Handle(AIS_InteractiveContext) context( return TestViewer::viewer()->getAISContext(); } - QColor randomColor() + QColor TestViewer::GetColor(int i) { - int r = test_rand(); - int aHue = r%255; - //std::cout << "hue: " << aHue << std::endl; - QColor aColor = QColor::fromHsl( aHue, 255, 128 ); - return aColor; + QVector aCV; + aCV << QColor(0,0,255) + << QColor(0,255,0) + << QColor(255,0,0) + << QColor(255,255,20) + << QColor(20,255,255) + << QColor(100,100,20) + << QColor(10,100,150); + return aCV[i]; } -void TestViewer::show( const TopoDS_Shape& theShape, int theMode, bool isFitAll, const QColor& theColor ) +void TestViewer::show( const Handle(AIS_InteractiveObject)& theObject, + int theMode, int theSelectionMode, bool isFitAll, const char* theKey ) { - double r = theColor.red() / 255.0; - double g = theColor.green() / 255.0; - double b = theColor.blue() / 255.0; + context()->EraseAll( Standard_False ); + context()->Display( theObject, theMode, theSelectionMode ); + + myKey = theKey; + if( isFitAll ) + { + viewWindow()->onTopView(); + viewWindow()->onFitAll(); + } +} + +void TestViewer::show( const TopoDS_Shape& theShape, int theMode, bool isFitAll, const QColor& theColor ) +{ Handle(AIS_Shape) aShape = new AIS_Shape( theShape ); aShape->SetMaterial( Graphic3d_NOM_PLASTIC ); - aShape->SetColor( Quantity_Color( r, g, b, Quantity_TOC_RGB ) ); + aShape->SetColor( HYDROData_Tool::toOccColor( theColor ) ); context()->Display( aShape, theMode, 0, Standard_False ); if( isFitAll ) @@@ -108,18 -98,18 +111,18 @@@ void TestViewer::show( const TopoDS_Shape& theShape, int theMode, bool isFitAll, const char* theKey ) { - context()->EraseAll(); + context()->EraseAll( Standard_False ); myKey = theKey; - test_srand( 0 ); - if( theShape.ShapeType()==TopAbs_COMPOUND ) + int i = 0; + if( theShape.ShapeType()==TopAbs_SHELL ) { TopoDS_Iterator anIt( theShape ); - for( ; anIt.More(); anIt.Next() ) - show( anIt.Value(), theMode, false, randomColor() ); + for( ; anIt.More(); anIt.Next(), i++ ) + show( anIt.Value(), theMode, false, GetColor(i) ); } else - show( theShape, theMode, false, randomColor() ); + show( theShape, theMode, false, GetColor(0) ); if( isFitAll ) { diff --cc src/HYDRO_tests/TestViewer.h index 73e50b59,64438b6c..4f6ee550 --- a/src/HYDRO_tests/TestViewer.h +++ b/src/HYDRO_tests/TestViewer.h @@@ -22,9 -18,8 +22,10 @@@ public static void show( const TopoDS_Shape& theShape, int theMode, bool isFitAll, const QColor& theColor ); static void show( const TopoDS_Shape& theShape, int theMode, bool isFitAll, const char* theKey ); static bool AssertImages( QString& theMessage ); + static QColor GetColor(int i); + static Handle_Aspect_ColorScale showColorScale(); + private: static OCCViewer_ViewManager* myViewManager; static OCCViewer_ViewWindow* myViewWindow; diff --cc src/HYDRO_tests/test_HYDROData_LandCoverMap.cxx index e05a4cd2,a2219f24..ce19c750 --- a/src/HYDRO_tests/test_HYDROData_LandCoverMap.cxx +++ b/src/HYDRO_tests/test_HYDROData_LandCoverMap.cxx @@@ -34,10 -32,9 +34,10 @@@ #include #include #include +#include #include #include - + #include #include #include @@@ -448,69 -444,46 +448,112 @@@ void test_HYDROData_LandCoverMap::test_ CPPUNIT_ASSERT_IMAGES CPPUNIT_ASSERT(aMergedFace.ShapeType() == TopAbs_SHELL); } + + } + + void test_HYDROData_LandCoverMap::test_import_dbf() + { + Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1); + + Handle(HYDROData_LandCoverMap) aMap = + Handle(HYDROData_LandCoverMap)::DownCast( aDoc->CreateObject( KIND_LAND_COVER_MAP ) ); + + CPPUNIT_ASSERT_EQUAL( KIND_LAND_COVER_MAP, aMap->GetKind() ); + QString aFileName = REF_DATA_PATH + "/t1.dbf"; + QStringList aDBFV; + QStringList aST; + aDBFV.append("100"); + aDBFV.append("200"); + aDBFV.append("300"); + aST.append("water"); + aST.append("forest"); + aST.append("road"); + // aST.size() == aDBFV.size()!! + Handle(HYDROData_PolylineXY) aPolyline = + Handle(HYDROData_PolylineXY)::DownCast( aDoc->CreateObject( KIND_POLYLINEXY ) ); + TopoDS_Wire aWire = BRepBuilderAPI_MakeWire( Spline( QList() << 10 << 40 << 30 << 10 << 40 << 10 << 60 << 10 ) ).Wire(); + aPolyline->SetShape( aWire ); + for (int i = 0; i < 3; i++) + aMap->Add(aPolyline, ""); + TopoDS_Face aLC1 = LandCover( QList() << 10 << 10 << 50 << 20 << 30 << 50 << 15 << 30 ); + CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC1, "test1" ) ); + + CPPUNIT_ASSERT_EQUAL( true, aMap->Split( aPolyline ) ); + QMap Inds; + Inds.insert(1, 1); + Inds.insert(2, 2); + Inds.insert(3, 3); + aMap->ImportDBF(aFileName, "TESTFIELD1", aDBFV, aST, Inds); + HYDROData_LandCoverMap::Iterator anIt( aMap ); + + CPPUNIT_ASSERT_EQUAL(true, "water" == anIt.StricklerType()); + anIt.Next(); + CPPUNIT_ASSERT_EQUAL(true, "forest" == anIt.StricklerType()); + -} +} + +void test_HYDROData_LandCoverMap::test_land_cover_prs_by_types() +{ + Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1); + + Handle(HYDROData_StricklerTable) aTable = + Handle(HYDROData_StricklerTable)::DownCast( aDoc->CreateObject( KIND_STRICKLER_TABLE ) ); + CPPUNIT_ASSERT_EQUAL( true, aTable->Import( DEF_STR_PATH ) ); + + Handle(HYDROData_LandCoverMap) aMap = + Handle(HYDROData_LandCoverMap)::DownCast( aDoc->CreateObject( KIND_LAND_COVER_MAP ) ); + + TopoDS_Face aLC1 = LandCover( QList() << 12 << 19 << 82 << 9 << 126 << 53 << 107 << 80 << 29 << 75 ); + CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC1, "Zones de champs cultivé à végétation basse" ) ); + + TopoDS_Face aLC2 = LandCover( QList() << 21 << 34 << 24 << 25 << 37 << 37 << 40 << 61 << + 44 << 95 << 85 << 100 << 104 << 66 << 107 << 33 << + 128 << 18 << 140 << 50 << 131 << 89 << 104 << 111 << + 31 << 114 ); + CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC2, "Zones de champs cultivé à végétation haute" ) ); + + TopoDS_Face aLC3 = LandCover( QList() << 4 << 54 << 1 << 47 << 51 << 45 << + 127 << 42 << 145 << 43 << 148 << 60 << 90 << 65 ); + CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC3, "Zones de champs, prairies, sans cultures" ) ); + + Handle(HYDROGUI_LandCoverMapPrs) aPrs = new HYDROGUI_LandCoverMapPrs( aMap ); + aPrs->SetTable( aTable ); + TestViewer::show( aPrs, AIS_Shaded, 1, true, "LandCoverMap_PrsByTypes" ); + CPPUNIT_ASSERT_IMAGES + + aDoc->Close(); +} + +void test_HYDROData_LandCoverMap::test_land_cover_prs_by_coeff() +{ + Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1); + + Handle(HYDROData_StricklerTable) aTable = + Handle(HYDROData_StricklerTable)::DownCast( aDoc->CreateObject( KIND_STRICKLER_TABLE ) ); + CPPUNIT_ASSERT_EQUAL( true, aTable->Import( DEF_STR_PATH ) ); + + Handle(HYDROData_LandCoverMap) aMap = + Handle(HYDROData_LandCoverMap)::DownCast( aDoc->CreateObject( KIND_LAND_COVER_MAP ) ); + + TopoDS_Face aLC1 = LandCover( QList() << 12 << 19 << 82 << 9 << 126 << 53 << 107 << 80 << 29 << 75 ); + CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC1, "Zones de champs cultivé à végétation basse" ) ); + + TopoDS_Face aLC2 = LandCover( QList() << 21 << 34 << 24 << 25 << 37 << 37 << 40 << 61 << + 44 << 95 << 85 << 100 << 104 << 66 << 107 << 33 << + 128 << 18 << 140 << 50 << 131 << 89 << 104 << 111 << + 31 << 114 ); + CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC2, "Zones de champs cultivé à végétation haute" ) ); + + TopoDS_Face aLC3 = LandCover( QList() << 4 << 54 << 1 << 47 << 51 << 45 << + 127 << 42 << 145 << 43 << 148 << 60 << 90 << 65 ); + CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC3, "Zones de champs, prairies, sans cultures" ) ); + + Handle(HYDROGUI_LandCoverMapPrs) aPrs = new HYDROGUI_LandCoverMapPrs( aMap ); + aPrs->SetTable( aTable ); + aPrs->SetColorScale( TestViewer::showColorScale() ); + TestViewer::show( aPrs, AIS_Shaded, 1, true, "LandCoverMap_PrsByCoeff" ); + CPPUNIT_ASSERT_IMAGES + + aDoc->Close(); +} ++ diff --cc src/HYDRO_tests/test_HYDROData_LandCoverMap.h index cbe08770,4f10b1ed..95ea4d4b --- a/src/HYDRO_tests/test_HYDROData_LandCoverMap.h +++ b/src/HYDRO_tests/test_HYDROData_LandCoverMap.h @@@ -32,8 -32,7 +32,9 @@@ class test_HYDROData_LandCoverMap : pub CPPUNIT_TEST( test_remove ); CPPUNIT_TEST( test_merge_faces_boxes ); CPPUNIT_TEST( test_merge_faces_circles ); + CPPUNIT_TEST( test_import_dbf ); + CPPUNIT_TEST( test_land_cover_prs_by_types ); + CPPUNIT_TEST( test_land_cover_prs_by_coeff ); CPPUNIT_TEST_SUITE_END(); public: @@@ -44,8 -43,7 +45,9 @@@ void test_remove(); void test_merge_faces_boxes(); void test_merge_faces_circles(); + void test_import_dbf(); + void test_land_cover_prs_by_types(); + void test_land_cover_prs_by_coeff(); }; CPPUNIT_TEST_SUITE_REGISTRATION( test_HYDROData_LandCoverMap );