#include <HYDROData_Iterator.h>
#include <HYDROData_Tool.h>
#include <AIS_DisplayMode.hxx>
-#include <Prs3d.hxx>
-#include <Select3D_SensitiveBox.hxx>
-#include <StdPrs_ShadedShape.hxx>
+#include <Prs3d_IsoAspect.hxx>
#include <StdPrs_WFDeflectionShape.hxx>
-#include <StdSelect.hxx>
-#include <StdSelect_BRepOwner.hxx>
-#include <StdSelect_BRepSelectionTool.hxx>
#include <TopoDS_Face.hxx>
#include <QColor>
#include <QString>
+IMPLEMENT_STANDARD_HANDLE( HYDROGUI_LandCoverMapPrs, AIS_ColoredShape )
+IMPLEMENT_STANDARD_RTTIEXT( HYDROGUI_LandCoverMapPrs, AIS_ColoredShape )
+
+HYDROGUI_LandCoverMapPrs::HYDROGUI_LandCoverMapPrs( const Handle(HYDROData_LandCoverMap)& theMap )
+ : AIS_ColoredShape( theMap->GetShape() )
+{
+ SetLandCoverMap( theMap );
+}
+
+HYDROGUI_LandCoverMapPrs::~HYDROGUI_LandCoverMapPrs()
+{
+}
+
Handle(HYDROData_LandCoverMap) HYDROGUI_LandCoverMapPrs::GetLandCoverMap() const
{
return myLCMap;
void HYDROGUI_LandCoverMapPrs::SetLandCoverMap( const Handle(HYDROData_LandCoverMap)& theMap )
{
myLCMap = theMap;
+ UpdateColors();
+}
+
+void HYDROGUI_LandCoverMapPrs::UpdateColors()
+{
+ Set( myLCMap->GetShape() );
+ SetMaterial( Graphic3d_NOM_PLASTIC );
+ HYDROData_LandCoverMap::Iterator anIt( myLCMap );
+ for( ; anIt.More(); anIt.Next() )
+ {
+ TopoDS_Face aFace = anIt.Face();
+ QString aStricklerType = anIt.StricklerType();
+ Quantity_Color aColor = GetColor( aStricklerType );
+ SetCustomColor( aFace, aColor );
+ SetCustomWidth( aFace, 1.0 );
+ }
}
Handle(Aspect_ColorScale) HYDROGUI_LandCoverMapPrs::GetColorScale() const
void HYDROGUI_LandCoverMapPrs::SetColorScale( const Handle(Aspect_ColorScale)& theColorScale )
{
myColorScale = theColorScale;
+ double aMin = 0, aMax = 0;
+ if( myTable.IsNull() )
+ {
+ //TODO: go through all Strickler tables in the document to get the global range
+ }
+ else
+ myTable->GetCoefficientRange( aMin, aMax );
+
+ myColorScale->SetRange( aMin, aMax );
+ UpdateColors();
}
Handle(HYDROData_StricklerTable) HYDROGUI_LandCoverMapPrs::GetTable() const
Handle(HYDROData_StricklerTable) aTable = Handle(HYDROData_StricklerTable)::DownCast( anIt.Current() );
if( aTable->HasType( theStricklerType ) )
{
- QColor aColor = myTable->GetColor( theStricklerType );
+ QColor aColor = aTable->GetColor( theStricklerType );
return HYDROData_Tool::toOccColor( aColor );
}
}
const Handle(Prs3d_Presentation)& thePresentation,
const Standard_Integer theMode )
{
- if( myLCMap.IsNull() )
- return;
+ 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 );
switch( theMode )
{
case AIS_WireFrame:
case AIS_Shaded:
- {
- bool isShaded = theMode==AIS_Shaded;
- HYDROData_LandCoverMap::Iterator anIt( myLCMap );
- for( ; anIt.More(); anIt.Next() )
- {
- TopoDS_Face aFace = anIt.Face();
- QString aStricklerType = anIt.StricklerType();
- Quantity_Color aColor = GetColor( aStricklerType );
- SetColor( aColor );
-
- if( isShaded )
- StdPrs_ShadedShape::Add( thePresentation, aFace, myDrawer );
- else
- StdPrs_WFDeflectionShape::Add( thePresentation, aFace, myDrawer );
- }
- }
- break;
- default:
+ AIS_ColoredShape::Compute( thePresentationManager, thePresentation, theMode );
break;
}
-}
-
-void HYDROGUI_LandCoverMapPrs::ComputeSelection( const Handle(SelectMgr_Selection)& theSelection,
- const Standard_Integer theMode )
-{
- if( myLCMap.IsNull() )
- return;
- if( theMode==0 )
- {
- theSelection->Clear();
- Bnd_Box B = BoundingBox();
- Handle(StdSelect_BRepOwner) anOwner = new StdSelect_BRepOwner( myLCMap->GetShape(), this );
- Handle(Select3D_SensitiveBox) aSensitiveBox = new Select3D_SensitiveBox( anOwner, B );
- theSelection->Add( aSensitiveBox );
- }
- else
- {
- Standard_Real aDeflection = Prs3d::GetDeflection( myLCMap->GetShape(), myDrawer );
- HYDROData_LandCoverMap::Iterator anIt( myLCMap );
- for( ; anIt.More(); anIt.Next() )
- {
- StdSelect_BRepSelectionTool::Load( theSelection,
- this,
- anIt.Face(),
- TopAbs_FACE,
- aDeflection,
- myDrawer->HLRAngle(),
- myDrawer->IsAutoTriangulation());
- }
- StdSelect::SetDrawerForBRepOwner( theSelection, myDrawer );
- }
+ if( theMode==AIS_Shaded )
+ StdPrs_WFDeflectionShape::Add( thePresentation, Shape(), myDrawer );
}
+