Salome HOME
#662: test for land cover map presentation
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_LandCoverMapPrs.cxx
index 0128a7a311d846db9a83011603ebd4ec165a0ab5..f74fb1a556cd0d349dc7d53e009cf50ebcfc6af6 100644 (file)
 #include <HYDROData_Tool.h>
 #include <AIS_DisplayMode.hxx>
 #include <Prs3d.hxx>
+#include <Prs3d_IsoAspect.hxx>
+#include <Prs3d_LineAspect.hxx>
+#include <Prs3d_ShadingAspect.hxx>
+#include <Graphic3d_AspectFillArea3d.hxx>
 #include <Select3D_SensitiveBox.hxx>
 #include <StdPrs_ShadedShape.hxx>
-#include <StdPrs_WFDeflectionShape.hxx>
+#include <StdPrs_WFShape.hxx>
 #include <StdSelect.hxx>
 #include <StdSelect_BRepOwner.hxx>
 #include <StdSelect_BRepSelectionTool.hxx>
 #include <QColor>
 #include <QString>
 
+IMPLEMENT_STANDARD_HANDLE( HYDROGUI_LandCoverMapPrs, AIS_Shape )
+IMPLEMENT_STANDARD_RTTIEXT( HYDROGUI_LandCoverMapPrs, AIS_Shape )
+
+HYDROGUI_LandCoverMapPrs::HYDROGUI_LandCoverMapPrs( const Handle(HYDROData_LandCoverMap)& theMap )
+  : AIS_Shape( TopoDS_Shape() )
+{
+  SetLandCoverMap( theMap );
+}
+
+HYDROGUI_LandCoverMapPrs::~HYDROGUI_LandCoverMapPrs()
+{
+}
+
 Handle(HYDROData_LandCoverMap) HYDROGUI_LandCoverMapPrs::GetLandCoverMap() const
 {
   return myLCMap;
@@ -39,6 +56,7 @@ Handle(HYDROData_LandCoverMap) HYDROGUI_LandCoverMapPrs::GetLandCoverMap() const
 void HYDROGUI_LandCoverMapPrs::SetLandCoverMap( const Handle(HYDROData_LandCoverMap)& theMap )
 {
   myLCMap = theMap;
+  Set( theMap->GetShape() );
 }
 
 Handle(Aspect_ColorScale) HYDROGUI_LandCoverMapPrs::GetColorScale() const
@@ -102,6 +120,16 @@ void HYDROGUI_LandCoverMapPrs::Compute( const Handle(PrsMgr_PresentationManager3
   if( myLCMap.IsNull() )
     return;
 
+  thePresentation->Clear();
+  SetMaterial( Graphic3d_NOM_PLASTIC );
+
+  Quantity_Color anEdgeColor = Quantity_NOC_WHITE;
+  myDrawer->LineAspect()->SetColor( anEdgeColor );
+  myDrawer->FaceBoundaryAspect()->SetColor( anEdgeColor );
+  myDrawer->FreeBoundaryAspect()->SetColor( anEdgeColor );
+  myDrawer->UIsoAspect()->SetNumber( 0 );
+  myDrawer->VIsoAspect()->SetNumber( 0 );
+
   switch( theMode )
   {
   case AIS_WireFrame:
@@ -112,14 +140,27 @@ void HYDROGUI_LandCoverMapPrs::Compute( const Handle(PrsMgr_PresentationManager3
       for( ; anIt.More(); anIt.Next() )
       {
         TopoDS_Face aFace = anIt.Face();
-        QString aStricklerType = anIt.StricklerType();
-        Quantity_Color aColor = GetColor( aStricklerType );
-        SetColor( aColor );
-
         if( isShaded )
+        {
+          QString aStricklerType = anIt.StricklerType();
+          Quantity_Color aColor = GetColor( aStricklerType );
+          Handle(Graphic3d_AspectFillArea3d) anAspect = new Graphic3d_AspectFillArea3d();
+          Graphic3d_MaterialAspect aMaterialAspect( Graphic3d_NOM_PLASTIC );
+          aMaterialAspect.SetColor( aColor );
+          anAspect->SetFrontMaterial( aMaterialAspect );
+          anAspect->SetBackMaterial( aMaterialAspect );
+
+          Handle(Graphic3d_AspectFillArea3d) aGlobalAspect = myDrawer->ShadingAspect()->Aspect();
+          myDrawer->ShadingAspect()->SetAspect( anAspect );
           StdPrs_ShadedShape::Add( thePresentation, aFace, myDrawer );
+          myDrawer->ShadingAspect()->SetAspect( aGlobalAspect );
+
+          StdPrs_WFShape::Add( thePresentation, aFace, myDrawer );
+        }
         else
-          StdPrs_WFDeflectionShape::Add( thePresentation, aFace, myDrawer );
+        {
+          StdPrs_WFShape::Add( thePresentation, aFace, myDrawer );
+        }
       }
     }
     break;