From 597c8ff37c820d683af565f5d7507de002e489e0 Mon Sep 17 00:00:00 2001 From: asl Date: Tue, 2 Sep 2014 06:12:41 +0000 Subject: [PATCH] customization of the bathymetry presentation in HYDRO --- src/HYDROGUI/CMakeLists.txt | 2 + src/HYDROGUI/HYDROGUI_BathymetryPrs.cxx | 113 ++++++++++++++++++++++ src/HYDROGUI/HYDROGUI_BathymetryPrs.h | 50 ++++++++++ src/HYDROGUI/HYDROGUI_ShapeBathymetry.cxx | 4 +- 4 files changed, 167 insertions(+), 2 deletions(-) create mode 100644 src/HYDROGUI/HYDROGUI_BathymetryPrs.cxx create mode 100644 src/HYDROGUI/HYDROGUI_BathymetryPrs.h diff --git a/src/HYDROGUI/CMakeLists.txt b/src/HYDROGUI/CMakeLists.txt index 9b00fb98..4c7579db 100644 --- a/src/HYDROGUI/CMakeLists.txt +++ b/src/HYDROGUI/CMakeLists.txt @@ -5,6 +5,7 @@ set(PROJECT_HEADERS HYDROGUI.h HYDROGUI_AbstractDisplayer.h HYDROGUI_AISTrihedron.h + HYDROGUI_BathymetryPrs.h HYDROGUI_CalculationDlg.h HYDROGUI_CalculationOp.h HYDROGUI_ChannelDlg.h @@ -104,6 +105,7 @@ QT4_WRAP_CPP(PROJECT_HEADERS_MOC ${PROJECT_HEADERS}) set(PROJECT_SOURCES HYDROGUI_AbstractDisplayer.cxx HYDROGUI_AISTrihedron.cxx + HYDROGUI_BathymetryPrs.cxx HYDROGUI_CalculationDlg.cxx HYDROGUI_CalculationOp.cxx HYDROGUI_ChannelDlg.cxx diff --git a/src/HYDROGUI/HYDROGUI_BathymetryPrs.cxx b/src/HYDROGUI/HYDROGUI_BathymetryPrs.cxx new file mode 100644 index 00000000..057cdcfa --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_BathymetryPrs.cxx @@ -0,0 +1,113 @@ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +const int BATH_HIGHLIGHT_MODE = 10; + +HYDROGUI_BathymetryPrs::HYDROGUI_BathymetryPrs() +{ + SetHilightMode( BATH_HIGHLIGHT_MODE ); +} + +HYDROGUI_BathymetryPrs::~HYDROGUI_BathymetryPrs() +{ +} + +void HYDROGUI_BathymetryPrs::SetPoints( const Handle(TColgp_HArray1OfPnt)& theCoords, + const Handle(Quantity_HArray1OfColor)& theColors ) +{ + myBound.SetVoid(); + if( !theCoords.IsNull() ) + { + int aLower = theCoords->Lower(); + int anUpper = theCoords->Upper(); + + for( int i = aLower; i <= anUpper; i++ ) + { + if( i==aLower ) + myBound.Set( theCoords->Value( i ) ); + else + { + gp_Pnt aPnt = theCoords->Value( i ); + myBound.Update( aPnt.X(), aPnt.Y(), aPnt.Z() ); + } + } + } + AIS_PointCloud::SetPoints( theCoords, theColors ); +} + +void HYDROGUI_BathymetryPrs::Compute( const Handle(PrsMgr_PresentationManager3d)& thePresentationManager, + const Handle(Prs3d_Presentation)& thePresentation, + const Standard_Integer theMode ) +{ + if( theMode==BATH_HIGHLIGHT_MODE ) + { + thePresentation->Clear(); + if( myBound.IsVoid() || + myBound.IsOpenXmin() || myBound.IsOpenXmax() || + myBound.IsOpenYmin() || myBound.IsOpenYmax() || + myBound.IsOpenZmin() || myBound.IsOpenZmax() ) + return; + + Standard_Real xmin, xmax, ymin, ymax, zmin, zmax; + myBound.Get( xmin, ymin, zmin, xmax, ymax, zmax ); + + Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup (thePresentation); + Handle(Prs3d_LineAspect) aWireAspect = new Prs3d_LineAspect( Quantity_NOC_RED, Aspect_TOL_SOLID, 1.0 ); + aGroup->SetPrimitivesAspect( aWireAspect->Aspect() ); + + Handle(Graphic3d_ArrayOfPolylines) aLines = new Graphic3d_ArrayOfPolylines( 18, 6 ); + + aLines->AddBound( 5 ); + aLines->AddVertex( xmin, ymin, zmin ); + aLines->AddVertex( xmax, ymin, zmin ); + aLines->AddVertex( xmax, ymax, zmin ); + aLines->AddVertex( xmin, ymax, zmin ); + aLines->AddVertex( xmin, ymin, zmin ); + aLines->AddBound( 5 ); + aLines->AddVertex( xmin, ymin, zmax ); + aLines->AddVertex( xmax, ymin, zmax ); + aLines->AddVertex( xmax, ymax, zmax ); + aLines->AddVertex( xmin, ymax, zmax ); + aLines->AddVertex( xmin, ymin, zmax ); + aLines->AddBound( 2 ); + aLines->AddVertex( xmin, ymin, zmin ); + aLines->AddVertex( xmin, ymin, zmax ); + aLines->AddBound( 2 ); + aLines->AddVertex( xmax, ymin, zmin ); + aLines->AddVertex( xmax, ymin, zmax ); + aLines->AddBound( 2 ); + aLines->AddVertex( xmax, ymax, zmin ); + aLines->AddVertex( xmax, ymax, zmax ); + aLines->AddBound( 2 ); + aLines->AddVertex( xmin, ymax, zmin ); + aLines->AddVertex( xmin, ymax, zmax ); + aGroup->AddPrimitiveArray( aLines ); + } + else + AIS_PointCloud::Compute( thePresentationManager, thePresentation, theMode ); +} + +void HYDROGUI_BathymetryPrs::ComputeSelection( const Handle(SelectMgr_Selection)& theSelection, + const Standard_Integer theMode ) +{ + if( theMode == 0 ) + { + if( myBound.IsVoid() || + myBound.IsOpenXmin() || myBound.IsOpenXmax() || + myBound.IsOpenYmin() || myBound.IsOpenYmax() || + myBound.IsOpenZmin() || myBound.IsOpenZmax() ) + return; + + Handle(SelectMgr_EntityOwner) anOwner = new SelectMgr_EntityOwner( this ); + Handle(Select3D_SensitiveBox) aSensitiveBox = new Select3D_SensitiveBox( anOwner, myBound ); + theSelection->Add( aSensitiveBox ); + } +} diff --git a/src/HYDROGUI/HYDROGUI_BathymetryPrs.h b/src/HYDROGUI/HYDROGUI_BathymetryPrs.h new file mode 100644 index 00000000..5ea3fd24 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_BathymetryPrs.h @@ -0,0 +1,50 @@ +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef HYDROGUI_BATHYMETRY_PRS_H +#define HYDROGUI_BATHYMETRY_PRS_H + +#include +#include + +class HYDROGUI_BathymetryPrs : public AIS_PointCloud +{ +public: + HYDROGUI_BathymetryPrs(); + virtual ~HYDROGUI_BathymetryPrs(); + + virtual void SetPoints( const Handle(TColgp_HArray1OfPnt)& theCoords, + const Handle(Quantity_HArray1OfColor)& theColors = NULL ); + +protected: + virtual void Compute( const Handle(PrsMgr_PresentationManager3d)& thePresentationManager, + const Handle(Prs3d_Presentation)& thePresentation, + const Standard_Integer theMode = 0 ); + virtual void ComputeSelection( const Handle(SelectMgr_Selection)& theSelection, + const Standard_Integer theMode ); + +private: + Bnd_Box myBound; +}; + +#endif + diff --git a/src/HYDROGUI/HYDROGUI_ShapeBathymetry.cxx b/src/HYDROGUI/HYDROGUI_ShapeBathymetry.cxx index 2abb2879..57638435 100644 --- a/src/HYDROGUI/HYDROGUI_ShapeBathymetry.cxx +++ b/src/HYDROGUI/HYDROGUI_ShapeBathymetry.cxx @@ -22,10 +22,10 @@ #include #include +#include #include #include -#include #include #include #include @@ -67,7 +67,7 @@ Handle_AIS_InteractiveObject HYDROGUI_ShapeBathymetry::createShape() const Handle_HYDROData_Bathymetry aBath = Handle_HYDROData_Bathymetry::DownCast( getObject() ); if( !aBath.IsNull() ) { - Handle_AIS_PointCloud aPntCloud = new AIS_PointCloud(); + Handle_AIS_PointCloud aPntCloud = new HYDROGUI_BathymetryPrs(); aPntCloud->Attributes()->SetPointAspect (new Prs3d_PointAspect (Aspect_TOM_POINT, Quantity_NOC_WHITE, 1.0)); const HYDROData_Bathymetry::AltitudePoints& aBathPoints = aBath->GetAltitudePoints(); -- 2.39.2