From: asl Date: Tue, 20 Oct 2015 10:30:31 +0000 (+0300) Subject: correct selection mode activation X-Git-Tag: v1.5~78^2~1^2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b8370bb9832dcba454e5ed622db8afa0de34652b;p=modules%2Fhydro.git correct selection mode activation --- diff --git a/src/HYDRO_tests/TestViewer.cxx b/src/HYDRO_tests/TestViewer.cxx index fd8c5f86..f54fdfc0 100644 --- a/src/HYDRO_tests/TestViewer.cxx +++ b/src/HYDRO_tests/TestViewer.cxx @@ -2,6 +2,9 @@ #include #include #include +#ifdef WIN32 + #pragma warning ( disable: 4251 ) +#endif #include #ifdef WIN32 #pragma warning ( disable: 4251 ) @@ -18,7 +21,6 @@ #include #include #include - #include #include #include @@ -69,22 +71,31 @@ Handle(AIS_InteractiveContext) context() QColor TestViewer::GetColor(int i) { - 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); + static QVector aCV; + if( aCV.isEmpty() ) + { + 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 Handle(AIS_InteractiveObject)& theObject, int theMode, int theSelectionMode, bool isFitAll, const char* theKey ) { + 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; @@ -185,7 +196,7 @@ bool TestViewer::AssertImages( QString& theMessage ) return false; } -Handle_Aspect_ColorScale TestViewer::showColorScale() +Handle_Aspect_ColorScale TestViewer::showColorScale( bool isShow ) { Handle(V3d_View) aView = myViewWindow->getViewPort()->getView(); if( aView.IsNull() ) @@ -212,8 +223,15 @@ Handle_Aspect_ColorScale TestViewer::showColorScale() aColorScale->SetTitle( "test" ); aColorScale->SetRange( 0, 1 ); - if( !aView->ColorScaleIsDisplayed() ) - aView->ColorScaleDisplay(); - + if( isShow ) + { + if( !aView->ColorScaleIsDisplayed() ) + aView->ColorScaleDisplay(); + } + else + { + if( aView->ColorScaleIsDisplayed() ) + aView->ColorScaleErase(); + } return aColorScale; } diff --git a/src/HYDRO_tests/TestViewer.h b/src/HYDRO_tests/TestViewer.h index 4f6ee550..61f0d6bb 100644 --- a/src/HYDRO_tests/TestViewer.h +++ b/src/HYDRO_tests/TestViewer.h @@ -24,7 +24,7 @@ public: static bool AssertImages( QString& theMessage ); static QColor GetColor(int i); - static Handle_Aspect_ColorScale showColorScale(); + static Handle_Aspect_ColorScale showColorScale( bool ); private: static OCCViewer_ViewManager* myViewManager; diff --git a/src/HYDRO_tests/test_HYDROData_LandCoverMap.cxx b/src/HYDRO_tests/test_HYDROData_LandCoverMap.cxx index ce19c750..aa7f4d2b 100644 --- a/src/HYDRO_tests/test_HYDROData_LandCoverMap.cxx +++ b/src/HYDRO_tests/test_HYDROData_LandCoverMap.cxx @@ -518,7 +518,7 @@ void test_HYDROData_LandCoverMap::test_land_cover_prs_by_types() Handle(HYDROGUI_LandCoverMapPrs) aPrs = new HYDROGUI_LandCoverMapPrs( aMap ); aPrs->SetTable( aTable ); - TestViewer::show( aPrs, AIS_Shaded, 1, true, "LandCoverMap_PrsByTypes" ); + TestViewer::show( aPrs, AIS_Shaded, 4, true, "LandCoverMap_PrsByTypes" ); CPPUNIT_ASSERT_IMAGES aDoc->Close(); @@ -550,10 +550,11 @@ void test_HYDROData_LandCoverMap::test_land_cover_prs_by_coeff() Handle(HYDROGUI_LandCoverMapPrs) aPrs = new HYDROGUI_LandCoverMapPrs( aMap ); aPrs->SetTable( aTable ); - aPrs->SetColorScale( TestViewer::showColorScale() ); - TestViewer::show( aPrs, AIS_Shaded, 1, true, "LandCoverMap_PrsByCoeff" ); + aPrs->SetColorScale( TestViewer::showColorScale( true ) ); + TestViewer::show( aPrs, AIS_Shaded, 4, true, "LandCoverMap_PrsByCoeff" ); CPPUNIT_ASSERT_IMAGES + TestViewer::showColorScale( false ); aDoc->Close(); }