From: asl Date: Thu, 22 Oct 2015 06:48:17 +0000 (+0300) Subject: #662: updated hilight/select presentations for land covers X-Git-Tag: v1.5~75^2~10 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=886031d285d687211e9fea939063582c75c50959;p=modules%2Fhydro.git #662: updated hilight/select presentations for land covers --- diff --git a/src/HYDROGUI/HYDROGUI_LandCoverMapPrs.cxx b/src/HYDROGUI/HYDROGUI_LandCoverMapPrs.cxx index 7a005c24..6f654a6d 100644 --- a/src/HYDROGUI/HYDROGUI_LandCoverMapPrs.cxx +++ b/src/HYDROGUI/HYDROGUI_LandCoverMapPrs.cxx @@ -21,11 +21,16 @@ #include #include #include +#include #include +#include #include #include #include +const Quantity_Color EDGES_COLOR = Quantity_NOC_WHITE; +const int HILIGHT_ISO_NB = 10; + IMPLEMENT_STANDARD_HANDLE( HYDROGUI_LandCoverMapPrs, AIS_ColoredShape ) IMPLEMENT_STANDARD_RTTIEXT( HYDROGUI_LandCoverMapPrs, AIS_ColoredShape ) @@ -33,6 +38,8 @@ HYDROGUI_LandCoverMapPrs::HYDROGUI_LandCoverMapPrs( const Handle(HYDROData_LandC : AIS_ColoredShape( theMap->GetShape() ) { SetLandCoverMap( theMap ); + SetAutoHilight( Standard_False ); + SetHilightAttributes( EDGES_COLOR ); } HYDROGUI_LandCoverMapPrs::~HYDROGUI_LandCoverMapPrs() @@ -135,13 +142,11 @@ void HYDROGUI_LandCoverMapPrs::Compute( const Handle(PrsMgr_PresentationManager3 { thePresentation->Clear(); - Quantity_Color anEdgeColor = Quantity_NOC_WHITE; - myDrawer->UIsoAspect()->SetNumber( 0 ); myDrawer->VIsoAspect()->SetNumber( 0 ); - myDrawer->LineAspect()->SetColor( anEdgeColor ); - myDrawer->FaceBoundaryAspect()->SetColor( anEdgeColor ); - myDrawer->FreeBoundaryAspect()->SetColor( anEdgeColor ); + myDrawer->LineAspect()->SetColor( EDGES_COLOR ); + myDrawer->FaceBoundaryAspect()->SetColor( EDGES_COLOR ); + myDrawer->FreeBoundaryAspect()->SetColor( EDGES_COLOR ); switch( theMode ) { @@ -155,3 +160,34 @@ void HYDROGUI_LandCoverMapPrs::Compute( const Handle(PrsMgr_PresentationManager3 StdPrs_WFDeflectionShape::Add( thePresentation, Shape(), myDrawer ); } +void HYDROGUI_LandCoverMapPrs::HilightSelected( const Handle(PrsMgr_PresentationManager3d)& thePresentationManager, + const SelectMgr_SequenceOfOwner& theOwners ) +{ + Handle(Prs3d_Presentation) aSelectPrs = GetSelectPresentation( thePresentationManager ); + + SetHilightAttributes( EDGES_COLOR ); + + for( int i=1, n=theOwners.Length(); i<=n; i++ ) + { + Handle(StdSelect_BRepOwner) anOwner = Handle(StdSelect_BRepOwner)::DownCast( theOwners.Value( i ) ); + if( !anOwner.IsNull() ) + StdPrs_WFDeflectionShape::Add( aSelectPrs, anOwner->Shape(), HilightAttributes() ); + } + + HilightAttributes()->UIsoAspect()->SetNumber( 0 ); + HilightAttributes()->VIsoAspect()->SetNumber( 0 ); + + aSelectPrs->SetDisplayPriority( 9 ); + aSelectPrs->Display(); +} + +void HYDROGUI_LandCoverMapPrs::SetHilightAttributes( const Quantity_Color& theEdgesColor ) +{ + HilightAttributes()->UIsoAspect()->SetNumber( HILIGHT_ISO_NB ); + HilightAttributes()->UIsoAspect()->SetColor( theEdgesColor ); + HilightAttributes()->VIsoAspect()->SetNumber( HILIGHT_ISO_NB ); + HilightAttributes()->VIsoAspect()->SetColor( theEdgesColor ); + HilightAttributes()->LineAspect()->SetColor( theEdgesColor ); + HilightAttributes()->FaceBoundaryAspect()->SetColor( theEdgesColor ); + HilightAttributes()->FreeBoundaryAspect()->SetColor( theEdgesColor ); +} diff --git a/src/HYDROGUI/HYDROGUI_LandCoverMapPrs.h b/src/HYDROGUI/HYDROGUI_LandCoverMapPrs.h index 0e9888a1..e1acc832 100644 --- a/src/HYDROGUI/HYDROGUI_LandCoverMapPrs.h +++ b/src/HYDROGUI/HYDROGUI_LandCoverMapPrs.h @@ -47,10 +47,14 @@ public: const Handle(Prs3d_Presentation)& thePresentation, const Standard_Integer theMode ); + virtual void HilightSelected( const Handle(PrsMgr_PresentationManager3d)& thePresentationManager, + const SelectMgr_SequenceOfOwner& theOwners ); + Quantity_Color GetColor( const QString& theStricklerType ) const; protected: void UpdateColors(); + void SetHilightAttributes( const Quantity_Color& theEdgesColor ); private: Handle(HYDROData_LandCoverMap) myLCMap; diff --git a/src/HYDRO_tests/TestViewer.cxx b/src/HYDRO_tests/TestViewer.cxx index 44e3fc2c..1fef8ca1 100644 --- a/src/HYDRO_tests/TestViewer.cxx +++ b/src/HYDRO_tests/TestViewer.cxx @@ -243,3 +243,10 @@ Handle_Aspect_ColorScale TestViewer::showColorScale( bool isShow ) } return aColorScale; } + +void TestViewer::select( int theViewX, int theViewY ) +{ + Handle(V3d_View) aView = myViewWindow->getViewPort()->getView(); + context()->MoveTo( theViewX, theViewY, aView ); + context()->Select(); +} diff --git a/src/HYDRO_tests/TestViewer.h b/src/HYDRO_tests/TestViewer.h index 61f0d6bb..d5bd15d6 100644 --- a/src/HYDRO_tests/TestViewer.h +++ b/src/HYDRO_tests/TestViewer.h @@ -26,6 +26,8 @@ public: static Handle_Aspect_ColorScale showColorScale( bool ); + static void select( int theViewX, int theViewY ); + private: static OCCViewer_ViewManager* myViewManager; static OCCViewer_ViewWindow* myViewWindow; diff --git a/src/HYDRO_tests/reference_data/LandCoverMap_PrsByTypes.png b/src/HYDRO_tests/reference_data/LandCoverMap_PrsByTypes.png index 218a6216..2d7da92e 100644 Binary files a/src/HYDRO_tests/reference_data/LandCoverMap_PrsByTypes.png and b/src/HYDRO_tests/reference_data/LandCoverMap_PrsByTypes.png differ diff --git a/src/HYDRO_tests/test_HYDROData_LandCoverMap.cxx b/src/HYDRO_tests/test_HYDROData_LandCoverMap.cxx index 5e7e8fca..e1f52ed7 100644 --- a/src/HYDRO_tests/test_HYDROData_LandCoverMap.cxx +++ b/src/HYDRO_tests/test_HYDROData_LandCoverMap.cxx @@ -478,9 +478,13 @@ void test_HYDROData_LandCoverMap::test_land_cover_prs_by_types() 127 << 42 << 145 << 43 << 148 << 60 << 90 << 65 ); CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC3, "Zones de champs, prairies, sans cultures" ) ); + // build presentation object Handle(HYDROGUI_LandCoverMapPrs) aPrs = new HYDROGUI_LandCoverMapPrs( aMap ); aPrs->SetTable( aTable ); + // show presentation in viewer TestViewer::show( aPrs, AIS_Shaded, 4, true, "LandCoverMap_PrsByTypes" ); + // select one of faces (first) + TestViewer::select( 200, 300 ); CPPUNIT_ASSERT_IMAGES aDoc->Close();