From: asl Date: Fri, 13 Nov 2015 09:23:30 +0000 (+0300) Subject: refs #661: support of transparency in LCM X-Git-Tag: v1.5~50^2^2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=92e298a35c83629de1bbb9e39aa32b84a7e820a2;p=modules%2Fhydro.git refs #661: support of transparency in LCM --- diff --git a/src/HYDROData/HYDROData_LandCoverMap.cxx b/src/HYDROData/HYDROData_LandCoverMap.cxx index d33d90de..02098d3e 100644 --- a/src/HYDROData/HYDROData_LandCoverMap.cxx +++ b/src/HYDROData/HYDROData_LandCoverMap.cxx @@ -43,6 +43,7 @@ #include #include #include +#include #include #include @@ -892,3 +893,22 @@ QStringList HYDROData_LandCoverMap::DumpToPython( MapOfTreatedObjects& theTreate return aResList; } + +void HYDROData_LandCoverMap::SetTransparency( double theTransparency ) +{ + Handle(TDataStd_Real) anAttr; + TDF_Label aLabel = myLab.FindChild( DataTag_Transparency ); + if( !aLabel.FindAttribute( TDataStd_Real::GetID(), anAttr ) ) + aLabel.AddAttribute( anAttr = new TDataStd_Real() ); + anAttr->Set( theTransparency ); +} + +double HYDROData_LandCoverMap::GetTransparency() const +{ + Handle(TDataStd_Real) anAttr; + TDF_Label aLabel = myLab.FindChild( DataTag_Transparency ); + if( !aLabel.FindAttribute( TDataStd_Real::GetID(), anAttr ) ) + return 0.5; + + return anAttr->Get(); +} diff --git a/src/HYDROData/HYDROData_LandCoverMap.h b/src/HYDROData/HYDROData_LandCoverMap.h index 9ce1613e..5c632ebb 100644 --- a/src/HYDROData/HYDROData_LandCoverMap.h +++ b/src/HYDROData/HYDROData_LandCoverMap.h @@ -47,6 +47,7 @@ protected: DataTag_First = HYDROData_Entity::DataTag_First + 100, ///< first tag, to reserve DataTag_Shape, ///< the shape presentation of the land cover map DataTag_Types, + DataTag_Transparency, }; public: @@ -124,6 +125,9 @@ public: HYDRODATA_EXPORT void StoreLandCovers( const HYDROData_MapOfFaceToStricklerType& ); + HYDRODATA_EXPORT void SetTransparency( double ); + HYDRODATA_EXPORT double GetTransparency() const; + protected: void SetShape( const TopoDS_Shape& ); diff --git a/src/HYDROGUI/HYDROGUI_LandCoverMapPrs.cxx b/src/HYDROGUI/HYDROGUI_LandCoverMapPrs.cxx index 5e8a17f6..0afe0e31 100644 --- a/src/HYDROGUI/HYDROGUI_LandCoverMapPrs.cxx +++ b/src/HYDROGUI/HYDROGUI_LandCoverMapPrs.cxx @@ -59,6 +59,9 @@ void HYDROGUI_LandCoverMapPrs::SetLandCoverMap( const Handle(HYDROData_LandCover void HYDROGUI_LandCoverMapPrs::UpdateColors() { + if( !myLCMap.IsNull() ) + SetTransparency( myLCMap->GetTransparency() ); + Set( myLCMap->GetShape() ); SetMaterial( Graphic3d_NOM_PLASTIC ); HYDROData_LandCoverMap::Iterator anIt( myLCMap ); diff --git a/src/HYDRO_tests/test_HYDROData_LandCoverMap.cxx b/src/HYDRO_tests/test_HYDROData_LandCoverMap.cxx index 2f9896cf..7190418a 100644 --- a/src/HYDRO_tests/test_HYDROData_LandCoverMap.cxx +++ b/src/HYDRO_tests/test_HYDROData_LandCoverMap.cxx @@ -588,9 +588,11 @@ void test_HYDROData_LandCoverMap::test_transparent_prs() TestViewer::show( aZone->GetTopShape(), AIS_Shaded, true, "LandCoverMap_TransparentPrs" ); + aMap->SetTransparency( 0.5 ); + CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5, aMap->GetTransparency(), 1E-6 ); + Handle(HYDROGUI_LandCoverMapPrs) aPrs = new HYDROGUI_LandCoverMapPrs( aMap ); aPrs->SetTable( aTable ); - aPrs->SetTransparency( 0.5 ); TestViewer::show( aPrs, AIS_Shaded, 0, true, "" ); CPPUNIT_ASSERT_IMAGES