1 // Copyright (C) 2014-2015 EDF-R&D
2 // This library is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU Lesser General Public
4 // License as published by the Free Software Foundation; either
5 // version 2.1 of the License, or (at your option) any later version.
7 // This library is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10 // Lesser General Public License for more details.
12 // You should have received a copy of the GNU Lesser General Public
13 // License along with this library; if not, write to the Free Software
14 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #include <HYDROGUI_BathymetryPrs.h>
20 #include <Prs3d_Presentation.hxx>
21 #include <Prs3d_Root.hxx>
22 #include <Prs3d_LineAspect.hxx>
23 #include <SelectMgr_EntityOwner.hxx>
24 #include <SelectMgr_Selection.hxx>
25 #include <Select3D_SensitiveBox.hxx>
26 #include <Graphic3d_Group.hxx>
27 #include <Graphic3d_ArrayOfPolylines.hxx>
28 #include <Graphic3d_ArrayOfPoints.hxx>
30 const int BATH_HIGHLIGHT_MODE = 10;
32 HYDROGUI_BathymetryPrs::HYDROGUI_BathymetryPrs()
34 SetHilightMode( BATH_HIGHLIGHT_MODE );
35 SetAutoHilight( Standard_True );
38 HYDROGUI_BathymetryPrs::~HYDROGUI_BathymetryPrs()
42 void HYDROGUI_BathymetryPrs::UpdateBound()
44 Handle(Graphic3d_ArrayOfPoints) points = GetPoints();
46 if( !points.IsNull() )
49 int anUpper = points->VertexNumber();
51 for( int i = aLower; i <= anUpper; i++ )
53 gp_Pnt p = points->Vertice( i );
57 myBound.Update( p.X(), p.Y(), p.Z() );
62 void HYDROGUI_BathymetryPrs::SetPoints( const Handle(TColgp_HArray1OfPnt)& theCoords,
63 const Handle(Quantity_HArray1OfColor)& theColors )
65 AIS_PointCloud::SetPoints( theCoords, theColors );
69 void HYDROGUI_BathymetryPrs::Compute( const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
70 const Handle(Prs3d_Presentation)& thePresentation,
71 const Standard_Integer theMode )
73 if( theMode==BATH_HIGHLIGHT_MODE )
75 thePresentation->Clear();
76 if( myBound.IsVoid() )
79 if( myBound.IsVoid() ||
80 myBound.IsOpenXmin() || myBound.IsOpenXmax() ||
81 myBound.IsOpenYmin() || myBound.IsOpenYmax() ||
82 myBound.IsOpenZmin() || myBound.IsOpenZmax() )
85 Standard_Real xmin, xmax, ymin, ymax, zmin, zmax;
86 myBound.Get( xmin, ymin, zmin, xmax, ymax, zmax );
88 Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup (thePresentation);
89 Handle(Prs3d_LineAspect) aWireAspect = new Prs3d_LineAspect( Quantity_NOC_RED, Aspect_TOL_SOLID, 1.0 );
90 aGroup->SetPrimitivesAspect( aWireAspect->Aspect() );
92 Handle(Graphic3d_ArrayOfPolylines) aLines = new Graphic3d_ArrayOfPolylines( 18, 6 );
94 aLines->AddBound( 5 );
95 aLines->AddVertex( xmin, ymin, zmin );
96 aLines->AddVertex( xmax, ymin, zmin );
97 aLines->AddVertex( xmax, ymax, zmin );
98 aLines->AddVertex( xmin, ymax, zmin );
99 aLines->AddVertex( xmin, ymin, zmin );
100 aLines->AddBound( 5 );
101 aLines->AddVertex( xmin, ymin, zmax );
102 aLines->AddVertex( xmax, ymin, zmax );
103 aLines->AddVertex( xmax, ymax, zmax );
104 aLines->AddVertex( xmin, ymax, zmax );
105 aLines->AddVertex( xmin, ymin, zmax );
106 aLines->AddBound( 2 );
107 aLines->AddVertex( xmin, ymin, zmin );
108 aLines->AddVertex( xmin, ymin, zmax );
109 aLines->AddBound( 2 );
110 aLines->AddVertex( xmax, ymin, zmin );
111 aLines->AddVertex( xmax, ymin, zmax );
112 aLines->AddBound( 2 );
113 aLines->AddVertex( xmax, ymax, zmin );
114 aLines->AddVertex( xmax, ymax, zmax );
115 aLines->AddBound( 2 );
116 aLines->AddVertex( xmin, ymax, zmin );
117 aLines->AddVertex( xmin, ymax, zmax );
118 aGroup->AddPrimitiveArray( aLines );
121 AIS_PointCloud::Compute( thePresentationManager, thePresentation, theMode );
124 void HYDROGUI_BathymetryPrs::ComputeSelection( const Handle(SelectMgr_Selection)& theSelection,
125 const Standard_Integer theMode )
129 if( myBound.IsVoid() )
132 if( myBound.IsVoid() ||
133 myBound.IsOpenXmin() || myBound.IsOpenXmax() ||
134 myBound.IsOpenYmin() || myBound.IsOpenYmax() ||
135 myBound.IsOpenZmin() || myBound.IsOpenZmax() )
138 Handle(SelectMgr_EntityOwner) anOwner = new SelectMgr_EntityOwner( this );
139 Handle(Select3D_SensitiveBox) aSensitiveBox = new Select3D_SensitiveBox( anOwner, myBound );
140 theSelection->Add( aSensitiveBox );