1 // Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #include <HYDROGUI_BathymetryPrs.h>
24 #include <Prs3d_Presentation.hxx>
25 #include <Prs3d_Root.hxx>
26 #include <Prs3d_LineAspect.hxx>
27 #include <SelectMgr_EntityOwner.hxx>
28 #include <SelectMgr_Selection.hxx>
29 #include <Select3D_SensitiveBox.hxx>
30 #include <Graphic3d_Group.hxx>
31 #include <Graphic3d_ArrayOfPolylines.hxx>
33 const int BATH_HIGHLIGHT_MODE = 10;
35 HYDROGUI_BathymetryPrs::HYDROGUI_BathymetryPrs()
37 SetHilightMode( BATH_HIGHLIGHT_MODE );
40 HYDROGUI_BathymetryPrs::~HYDROGUI_BathymetryPrs()
44 void HYDROGUI_BathymetryPrs::SetPoints( const Handle(TColgp_HArray1OfPnt)& theCoords,
45 const Handle(Quantity_HArray1OfColor)& theColors )
48 if( !theCoords.IsNull() )
50 int aLower = theCoords->Lower();
51 int anUpper = theCoords->Upper();
53 for( int i = aLower; i <= anUpper; i++ )
56 myBound.Set( theCoords->Value( i ) );
59 gp_Pnt aPnt = theCoords->Value( i );
60 myBound.Update( aPnt.X(), aPnt.Y(), aPnt.Z() );
64 AIS_PointCloud::SetPoints( theCoords, theColors );
67 void HYDROGUI_BathymetryPrs::Compute( const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
68 const Handle(Prs3d_Presentation)& thePresentation,
69 const Standard_Integer theMode )
71 if( theMode==BATH_HIGHLIGHT_MODE )
73 thePresentation->Clear();
74 if( myBound.IsVoid() ||
75 myBound.IsOpenXmin() || myBound.IsOpenXmax() ||
76 myBound.IsOpenYmin() || myBound.IsOpenYmax() ||
77 myBound.IsOpenZmin() || myBound.IsOpenZmax() )
80 Standard_Real xmin, xmax, ymin, ymax, zmin, zmax;
81 myBound.Get( xmin, ymin, zmin, xmax, ymax, zmax );
83 Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup (thePresentation);
84 Handle(Prs3d_LineAspect) aWireAspect = new Prs3d_LineAspect( Quantity_NOC_RED, Aspect_TOL_SOLID, 1.0 );
85 aGroup->SetPrimitivesAspect( aWireAspect->Aspect() );
87 Handle(Graphic3d_ArrayOfPolylines) aLines = new Graphic3d_ArrayOfPolylines( 18, 6 );
89 aLines->AddBound( 5 );
90 aLines->AddVertex( xmin, ymin, zmin );
91 aLines->AddVertex( xmax, ymin, zmin );
92 aLines->AddVertex( xmax, ymax, zmin );
93 aLines->AddVertex( xmin, ymax, zmin );
94 aLines->AddVertex( xmin, ymin, zmin );
95 aLines->AddBound( 5 );
96 aLines->AddVertex( xmin, ymin, zmax );
97 aLines->AddVertex( xmax, ymin, zmax );
98 aLines->AddVertex( xmax, ymax, zmax );
99 aLines->AddVertex( xmin, ymax, zmax );
100 aLines->AddVertex( xmin, ymin, zmax );
101 aLines->AddBound( 2 );
102 aLines->AddVertex( xmin, ymin, zmin );
103 aLines->AddVertex( xmin, ymin, zmax );
104 aLines->AddBound( 2 );
105 aLines->AddVertex( xmax, ymin, zmin );
106 aLines->AddVertex( xmax, ymin, zmax );
107 aLines->AddBound( 2 );
108 aLines->AddVertex( xmax, ymax, zmin );
109 aLines->AddVertex( xmax, ymax, zmax );
110 aLines->AddBound( 2 );
111 aLines->AddVertex( xmin, ymax, zmin );
112 aLines->AddVertex( xmin, ymax, zmax );
113 aGroup->AddPrimitiveArray( aLines );
116 AIS_PointCloud::Compute( thePresentationManager, thePresentation, theMode );
119 void HYDROGUI_BathymetryPrs::ComputeSelection( const Handle(SelectMgr_Selection)& theSelection,
120 const Standard_Integer theMode )
124 if( myBound.IsVoid() ||
125 myBound.IsOpenXmin() || myBound.IsOpenXmax() ||
126 myBound.IsOpenYmin() || myBound.IsOpenYmax() ||
127 myBound.IsOpenZmin() || myBound.IsOpenZmax() )
130 Handle(SelectMgr_EntityOwner) anOwner = new SelectMgr_EntityOwner( this );
131 Handle(Select3D_SensitiveBox) aSensitiveBox = new Select3D_SensitiveBox( anOwner, myBound );
132 theSelection->Add( aSensitiveBox );