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>
29 const int BATH_HIGHLIGHT_MODE = 10;
31 HYDROGUI_BathymetryPrs::HYDROGUI_BathymetryPrs()
33 SetHilightMode( BATH_HIGHLIGHT_MODE );
36 HYDROGUI_BathymetryPrs::~HYDROGUI_BathymetryPrs()
40 void HYDROGUI_BathymetryPrs::SetPoints( const Handle(TColgp_HArray1OfPnt)& theCoords,
41 const Handle(Quantity_HArray1OfColor)& theColors )
44 if( !theCoords.IsNull() )
46 int aLower = theCoords->Lower();
47 int anUpper = theCoords->Upper();
49 for( int i = aLower; i <= anUpper; i++ )
52 myBound.Set( theCoords->Value( i ) );
55 gp_Pnt aPnt = theCoords->Value( i );
56 myBound.Update( aPnt.X(), aPnt.Y(), aPnt.Z() );
60 AIS_PointCloud::SetPoints( theCoords, theColors );
63 void HYDROGUI_BathymetryPrs::Compute( const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
64 const Handle(Prs3d_Presentation)& thePresentation,
65 const Standard_Integer theMode )
67 if( theMode==BATH_HIGHLIGHT_MODE )
69 thePresentation->Clear();
70 if( myBound.IsVoid() ||
71 myBound.IsOpenXmin() || myBound.IsOpenXmax() ||
72 myBound.IsOpenYmin() || myBound.IsOpenYmax() ||
73 myBound.IsOpenZmin() || myBound.IsOpenZmax() )
76 Standard_Real xmin, xmax, ymin, ymax, zmin, zmax;
77 myBound.Get( xmin, ymin, zmin, xmax, ymax, zmax );
79 Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup (thePresentation);
80 Handle(Prs3d_LineAspect) aWireAspect = new Prs3d_LineAspect( Quantity_NOC_RED, Aspect_TOL_SOLID, 1.0 );
81 aGroup->SetPrimitivesAspect( aWireAspect->Aspect() );
83 Handle(Graphic3d_ArrayOfPolylines) aLines = new Graphic3d_ArrayOfPolylines( 18, 6 );
85 aLines->AddBound( 5 );
86 aLines->AddVertex( xmin, ymin, zmin );
87 aLines->AddVertex( xmax, ymin, zmin );
88 aLines->AddVertex( xmax, ymax, zmin );
89 aLines->AddVertex( xmin, ymax, zmin );
90 aLines->AddVertex( xmin, ymin, zmin );
91 aLines->AddBound( 5 );
92 aLines->AddVertex( xmin, ymin, zmax );
93 aLines->AddVertex( xmax, ymin, zmax );
94 aLines->AddVertex( xmax, ymax, zmax );
95 aLines->AddVertex( xmin, ymax, zmax );
96 aLines->AddVertex( xmin, ymin, zmax );
97 aLines->AddBound( 2 );
98 aLines->AddVertex( xmin, ymin, zmin );
99 aLines->AddVertex( xmin, ymin, zmax );
100 aLines->AddBound( 2 );
101 aLines->AddVertex( xmax, ymin, zmin );
102 aLines->AddVertex( xmax, ymin, zmax );
103 aLines->AddBound( 2 );
104 aLines->AddVertex( xmax, ymax, zmin );
105 aLines->AddVertex( xmax, ymax, zmax );
106 aLines->AddBound( 2 );
107 aLines->AddVertex( xmin, ymax, zmin );
108 aLines->AddVertex( xmin, ymax, zmax );
109 aGroup->AddPrimitiveArray( aLines );
112 AIS_PointCloud::Compute( thePresentationManager, thePresentation, theMode );
115 void HYDROGUI_BathymetryPrs::ComputeSelection( const Handle(SelectMgr_Selection)& theSelection,
116 const Standard_Integer theMode )
120 if( myBound.IsVoid() ||
121 myBound.IsOpenXmin() || myBound.IsOpenXmax() ||
122 myBound.IsOpenYmin() || myBound.IsOpenYmax() ||
123 myBound.IsOpenZmin() || myBound.IsOpenZmax() )
126 Handle(SelectMgr_EntityOwner) anOwner = new SelectMgr_EntityOwner( this );
127 Handle(Select3D_SensitiveBox) aSensitiveBox = new Select3D_SensitiveBox( anOwner, myBound );
128 theSelection->Add( aSensitiveBox );