#include "HYDROGUI_Tool.h"
#include <AIS_Drawer.hxx>
+#include <AIS_TexturedShape.hxx>
#include <BRepBuilderAPI_MakeEdge.hxx>
#include <BRepBuilderAPI_MakeWire.hxx>
#include <HYDROData_Polyline.h>
#include <HYDROData_Region.h>
#include <HYDROData_Zone.h>
+#include <HYDROData_Obstacle.h>
#include <TopoDS.hxx>
#include <TopoDS_Wire.hxx>
#include <TopoDS_Face.hxx>
+#include <TopExp_Explorer.hxx>
+
+#include <BRep_Builder.hxx>
+
#include <Precision.hxx>
#include <Prs3d_ShadingAspect.hxx>
Handle(HYDROData_ImmersibleZone) aZoneObj =
Handle(HYDROData_ImmersibleZone)::DownCast( myObject );
+ TopoDS_Shape aZoneShape = aZoneObj->GetTopShape();
+ if ( !aZoneShape.IsNull() ) {
+ if ( aZoneShape.ShapeType() == TopAbs_FACE ) {
+ TopoDS_Face aZoneFace = TopoDS::Face( aZoneShape );
+ setFace( aZoneFace, false, false );
+ } else {
+ myTopoShape = aZoneShape;
+ myDisplayMode = myTextureFileName.isEmpty() ? AIS_Shaded : AIS_Shaded+2;
+
+ buildShape();
+ updateShape( false, false );
+ }
+ }
+
QColor aFillingColor = aZoneObj->GetFillingColor();
QColor aBorderColor = aZoneObj->GetBorderColor();
- TopoDS_Face aZoneFace = TopoDS::Face( aZoneObj->GetTopShape() );
setFillingColor( aFillingColor, false, false );
setBorderColor( aBorderColor, false, false );
- setFace( aZoneFace, false, false );
}
else if ( myObject->IsKind( STANDARD_TYPE(HYDROData_Polyline) ) )
{
Handle(HYDROData_Polyline) aPolyline =
Handle(HYDROData_Polyline)::DownCast( myObject );
- TopoDS_Wire aPolylineWire = TopoDS::Wire( aPolyline->GetTopShape() );
+ TopoDS_Shape aPolylineShape = aPolyline->GetTopShape();
- setWire( aPolylineWire, false, false );
- }
- else if ( myObject->IsKind( STANDARD_TYPE(HYDROData_Region) ) )
- {
- Handle(HYDROData_Region) aRegion =
- Handle(HYDROData_Region)::DownCast( myObject );
+ if ( !aPolylineShape.IsNull() ) {
+ if ( aPolylineShape.ShapeType() == TopAbs_WIRE ) {
+ TopoDS_Wire aPolylineWire = TopoDS::Wire( aPolylineShape );
+ setWire( aPolylineWire, false, false );
+ } else {
+ myTopoShape = aPolylineShape;
+ myDisplayMode = AIS_WireFrame;
+
+ buildShape();
+ updateShape( false, false );
+ }
+ }
}
else if ( myObject->IsKind( STANDARD_TYPE(HYDROData_Zone) ) )
{
}
setFace( aZoneFace, false, false );
- setFillingColor( HYDROGUI_Tool::GenerateFillingColor( aDocument, aGeomObjectsNames ) );
+ if (aZone->IsMergingNeed() && aZone->GetMergeType() == HYDROData_Zone::Merge_UNKNOWN )
+ {
+ // Red color for a zone with bathymetry conflict
+ setFillingColor( Qt::red );
+ }
+ else
+ {
+ setFillingColor( HYDROGUI_Tool::GenerateFillingColor( aDocument, aGeomObjectsNames ) );
+ }
}
else if ( myObject->IsKind( STANDARD_TYPE(HYDROData_Image) ) )
{
setTextureFileName( aTextureFileName, false, false );
setFace( aWire, false, false );
}
- }
+ else if ( myObject->IsKind( STANDARD_TYPE(HYDROData_Obstacle) ) )
+ {
+ Handle(HYDROData_Obstacle) anObstacle =
+ Handle(HYDROData_Obstacle)::DownCast( myObject );
+
+ //TODO BEGIN of the block of code to be reimplemented
+ //TODO GetTopShape() to be used in future
+ myTopoShape = anObstacle->GetShape3D();
+ myDisplayMode = AIS_Shaded;
+
+ QColor aFillingColor = anObstacle->GetFillingColor();
+ QColor aBorderColor = anObstacle->GetBorderColor();
+
+ setFillingColor( aFillingColor, false, false );
+ setBorderColor( aBorderColor, false, false );
+ buildShape();
+ updateShape( false, false );
+ //TODO END of the block of code to be reimplemented
+ }
+ }
+
if ( myShape.IsNull() || !isVisible() )
return;
updateShape( theToDisplay, theIsUpdateViewer );
}
+void HYDROGUI_Shape::setFaces( const TopoDS_Compound& theWires,
+ const bool theToDisplay,
+ const bool theIsUpdateViewer )
+{
+ TopExp_Explorer anExp( theWires, TopAbs_WIRE );
+ TopoDS_Compound aCompound;
+ BRep_Builder aBuilder;
+ aBuilder.MakeCompound( aCompound );
+
+ for ( ; anExp.More(); anExp.Next() ) {
+ TopoDS_Wire aWire = TopoDS::Wire( anExp.Current() );
+ if ( aWire.IsNull() ) {
+ continue;
+ }
+
+ BRepBuilderAPI_MakeFace aMakeFace( aWire, Standard_True );
+ aMakeFace.Build();
+ if( aMakeFace.IsDone() ) {
+ aBuilder.Add( aCompound, aMakeFace.Face() );
+ }
+ }
+
+ myTopoShape = aCompound;
+ myDisplayMode = AIS_Shaded;
+
+ buildShape();
+ updateShape( theToDisplay, theIsUpdateViewer );
+}
+
void HYDROGUI_Shape::setFace( const TopoDS_Wire& theWire,
const bool theToDisplay,
const bool theIsUpdateViewer )
const bool theIsUpdateViewer )
{
myTopoShape = theFace;
- myDisplayMode = myTextureFileName.isEmpty() ? AIS_Shaded : AIS_ExactHLR;
+ myDisplayMode = myTextureFileName.isEmpty() ? AIS_Shaded : AIS_Shaded+2;
+ //Note: AIS_Shaded+2 is the same as AIS_ExactHLR
+ //TODO: it would be more suitable to use TexturedShape mode from GEOM_AISShape
+
+ buildShape();
+ updateShape( theToDisplay, theIsUpdateViewer );
+}
+
+void HYDROGUI_Shape::setShape( const TopoDS_Shape& theShape,
+ const bool theToDisplay,
+ const bool theIsUpdateViewer )
+{
+ myTopoShape = theShape;
+ myDisplayMode = AIS_Shaded;
buildShape();
updateShape( theToDisplay, theIsUpdateViewer );
if ( myTopoShape.IsNull() )
return;
- myShape = new AIS_TexturedShape( myTopoShape );
+ QString aTextureFileName = getTextureFileName();
+ bool anIsTexture = !aTextureFileName.isEmpty();
+
+ if ( anIsTexture )
+ {
+ myShape = new AIS_TexturedShape( myTopoShape );
+ }
+ else
+ {
+ myShape = new AIS_Shape( myTopoShape );
+ }
if ( !myObject.IsNull() )
myShape->SetOwner( myObject );
myShape->SetTransparency( 0 );
myShape->SetDisplayMode( (AIS_DisplayMode)myDisplayMode );
- QString aTextureFileName = getTextureFileName();
- if( !aTextureFileName.isEmpty() )
+ if( anIsTexture )
{
- myShape->SetTextureFileName( HYDROGUI_Tool::ToAsciiString( aTextureFileName ) );
- myShape->SetTextureMapOn();
- myShape->DisableTextureModulate();
+ Handle(AIS_TexturedShape) aTexturedShape =
+ Handle(AIS_TexturedShape)::DownCast( myShape );
+
+ aTexturedShape->SetTextureFileName( HYDROGUI_Tool::ToAsciiString( aTextureFileName ) );
+ aTexturedShape->SetTextureMapOn();
+ aTexturedShape->DisableTextureModulate();
}
// Init default params for shape