]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
customization of the bathymetry presentation in HYDRO
authorasl <asl@opencascade.com>
Tue, 2 Sep 2014 06:12:41 +0000 (06:12 +0000)
committerasl <asl@opencascade.com>
Tue, 2 Sep 2014 06:12:41 +0000 (06:12 +0000)
src/HYDROGUI/CMakeLists.txt
src/HYDROGUI/HYDROGUI_BathymetryPrs.cxx [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_BathymetryPrs.h [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_ShapeBathymetry.cxx

index 9b00fb983470a5f78414cbce528f95b1e49106d0..4c7579db143dc2b4f58db0b5b909a31875c368a2 100644 (file)
@@ -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 (file)
index 0000000..057cdcf
--- /dev/null
@@ -0,0 +1,113 @@
+
+#include <HYDROGUI_BathymetryPrs.h>
+#include <Prs3d_Presentation.hxx>
+#include <Prs3d_Root.hxx>
+#include <Prs3d_LineAspect.hxx>
+#include <SelectMgr_EntityOwner.hxx>
+#include <SelectMgr_Selection.hxx>
+#include <Select3D_SensitiveBox.hxx>
+#include <Graphic3d_Group.hxx>
+#include <Graphic3d_ArrayOfPolylines.hxx>
+
+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 (file)
index 0000000..5ea3fd2
--- /dev/null
@@ -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 <AIS_PointCloud.hxx>
+#include <Bnd_Box.hxx>
+
+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
+
index 2abb2879632f8d0ad5276e1458cfc88a5af9d0c7..5763843592c37e8823c1693ced4aa78d6eac9354 100644 (file)
 
 #include <HYDROGUI_ShapeBathymetry.h>
 #include <HYDROGUI_OCCDisplayer.h>
+#include <HYDROGUI_BathymetryPrs.h>
 #include <HYDROData_Bathymetry.h>
 
 #include <AIS_InteractiveContext.hxx>
-#include <AIS_PointCloud.hxx>
 #include <AIS_Drawer.hxx>
 #include <Aspect_ColorScale.hxx>
 #include <Prs3d_PointAspect.hxx>
@@ -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();