2 #include <HYDROGUI_BathymetryPrs.h>
3 #include <Prs3d_Presentation.hxx>
4 #include <Prs3d_Root.hxx>
5 #include <Prs3d_LineAspect.hxx>
6 #include <SelectMgr_EntityOwner.hxx>
7 #include <SelectMgr_Selection.hxx>
8 #include <Select3D_SensitiveBox.hxx>
9 #include <Graphic3d_Group.hxx>
10 #include <Graphic3d_ArrayOfPolylines.hxx>
12 const int BATH_HIGHLIGHT_MODE = 10;
14 HYDROGUI_BathymetryPrs::HYDROGUI_BathymetryPrs()
16 SetHilightMode( BATH_HIGHLIGHT_MODE );
19 HYDROGUI_BathymetryPrs::~HYDROGUI_BathymetryPrs()
23 void HYDROGUI_BathymetryPrs::SetPoints( const Handle(TColgp_HArray1OfPnt)& theCoords,
24 const Handle(Quantity_HArray1OfColor)& theColors )
27 if( !theCoords.IsNull() )
29 int aLower = theCoords->Lower();
30 int anUpper = theCoords->Upper();
32 for( int i = aLower; i <= anUpper; i++ )
35 myBound.Set( theCoords->Value( i ) );
38 gp_Pnt aPnt = theCoords->Value( i );
39 myBound.Update( aPnt.X(), aPnt.Y(), aPnt.Z() );
43 AIS_PointCloud::SetPoints( theCoords, theColors );
46 void HYDROGUI_BathymetryPrs::Compute( const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
47 const Handle(Prs3d_Presentation)& thePresentation,
48 const Standard_Integer theMode )
50 if( theMode==BATH_HIGHLIGHT_MODE )
52 thePresentation->Clear();
53 if( myBound.IsVoid() ||
54 myBound.IsOpenXmin() || myBound.IsOpenXmax() ||
55 myBound.IsOpenYmin() || myBound.IsOpenYmax() ||
56 myBound.IsOpenZmin() || myBound.IsOpenZmax() )
59 Standard_Real xmin, xmax, ymin, ymax, zmin, zmax;
60 myBound.Get( xmin, ymin, zmin, xmax, ymax, zmax );
62 Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup (thePresentation);
63 Handle(Prs3d_LineAspect) aWireAspect = new Prs3d_LineAspect( Quantity_NOC_RED, Aspect_TOL_SOLID, 1.0 );
64 aGroup->SetPrimitivesAspect( aWireAspect->Aspect() );
66 Handle(Graphic3d_ArrayOfPolylines) aLines = new Graphic3d_ArrayOfPolylines( 18, 6 );
68 aLines->AddBound( 5 );
69 aLines->AddVertex( xmin, ymin, zmin );
70 aLines->AddVertex( xmax, ymin, zmin );
71 aLines->AddVertex( xmax, ymax, zmin );
72 aLines->AddVertex( xmin, ymax, zmin );
73 aLines->AddVertex( xmin, ymin, zmin );
74 aLines->AddBound( 5 );
75 aLines->AddVertex( xmin, ymin, zmax );
76 aLines->AddVertex( xmax, ymin, zmax );
77 aLines->AddVertex( xmax, ymax, zmax );
78 aLines->AddVertex( xmin, ymax, zmax );
79 aLines->AddVertex( xmin, ymin, zmax );
80 aLines->AddBound( 2 );
81 aLines->AddVertex( xmin, ymin, zmin );
82 aLines->AddVertex( xmin, ymin, zmax );
83 aLines->AddBound( 2 );
84 aLines->AddVertex( xmax, ymin, zmin );
85 aLines->AddVertex( xmax, ymin, zmax );
86 aLines->AddBound( 2 );
87 aLines->AddVertex( xmax, ymax, zmin );
88 aLines->AddVertex( xmax, ymax, zmax );
89 aLines->AddBound( 2 );
90 aLines->AddVertex( xmin, ymax, zmin );
91 aLines->AddVertex( xmin, ymax, zmax );
92 aGroup->AddPrimitiveArray( aLines );
95 AIS_PointCloud::Compute( thePresentationManager, thePresentation, theMode );
98 void HYDROGUI_BathymetryPrs::ComputeSelection( const Handle(SelectMgr_Selection)& theSelection,
99 const Standard_Integer theMode )
103 if( myBound.IsVoid() ||
104 myBound.IsOpenXmin() || myBound.IsOpenXmax() ||
105 myBound.IsOpenYmin() || myBound.IsOpenYmax() ||
106 myBound.IsOpenZmin() || myBound.IsOpenZmax() )
109 Handle(SelectMgr_EntityOwner) anOwner = new SelectMgr_EntityOwner( this );
110 Handle(Select3D_SensitiveBox) aSensitiveBox = new Select3D_SensitiveBox( anOwner, myBound );
111 theSelection->Add( aSensitiveBox );