]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
refs #661: support of transparency in LCM
authorasl <asl@opencascade.com>
Fri, 13 Nov 2015 09:23:30 +0000 (12:23 +0300)
committerasl <asl@opencascade.com>
Fri, 13 Nov 2015 09:23:30 +0000 (12:23 +0300)
src/HYDROData/HYDROData_LandCoverMap.cxx
src/HYDROData/HYDROData_LandCoverMap.h
src/HYDROGUI/HYDROGUI_LandCoverMapPrs.cxx
src/HYDRO_tests/test_HYDROData_LandCoverMap.cxx

index d33d90de40047b6a2053e075817cdea06352a0af..02098d3e00e941542113394779624cb9c23a9b40 100644 (file)
@@ -43,6 +43,7 @@
 #include <BRepTools.hxx>
 #include <TopExp_Explorer.hxx>
 #include <ShapeUpgrade_UnifySameDomain.hxx>
+#include <TDataStd_Real.hxx>
 
 #include <QFile>
 #include <QString>
@@ -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();
+}
index 9ce1613ef125614fd2d7ba5101b750f179af351b..5c632ebb5c7b1dd6e96ff81a44d56417553c8437 100644 (file)
@@ -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& );
 
index 5e8a17f696910f1d83e181a2a12360e4faae775a..0afe0e31f9f880e7c544f5985d5390c2945f7388 100644 (file)
@@ -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 );
index 2f9896cf45f3ff9ba3065e286768014dc25389bc..7190418acc215d4842041e20be272ff38905d6c7 100644 (file)
@@ -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