Salome HOME
refs #1330: draft preferences implementation for polyline arrow
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_BathymetryPrs.cxx
index 057cdcfaee2fda1866d7fd58bf02a051e94a18c2..e6e427b44aad5f8f438b55adf586c5c8699466f3 100644 (file)
@@ -1,3 +1,20 @@
+// Copyright (C) 2014-2015  EDF-R&D
+// 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, or (at your option) any later version.
+//
+// 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
+//
 
 #include <HYDROGUI_BathymetryPrs.h>
 #include <Prs3d_Presentation.hxx>
 #include <Select3D_SensitiveBox.hxx>
 #include <Graphic3d_Group.hxx>
 #include <Graphic3d_ArrayOfPolylines.hxx>
+#include <Graphic3d_ArrayOfPoints.hxx>
 
 const int BATH_HIGHLIGHT_MODE = 10;
 
 HYDROGUI_BathymetryPrs::HYDROGUI_BathymetryPrs()
 {
   SetHilightMode( BATH_HIGHLIGHT_MODE );
+  SetAutoHilight( Standard_True );
 }
 
 HYDROGUI_BathymetryPrs::~HYDROGUI_BathymetryPrs()
 {
 }
 
-void HYDROGUI_BathymetryPrs::SetPoints( const Handle(TColgp_HArray1OfPnt)&     theCoords,
-                                        const Handle(Quantity_HArray1OfColor)& theColors )
+void HYDROGUI_BathymetryPrs::UpdateBound()
 {
+  Handle(Graphic3d_ArrayOfPoints) points = GetPoints();
   myBound.SetVoid();
-  if( !theCoords.IsNull() )
+  if( !points.IsNull() )
   {
-    int aLower = theCoords->Lower();
-    int anUpper = theCoords->Upper();
+    int aLower = 1;
+    int anUpper = points->VertexNumber();
 
     for( int i = aLower; i <= anUpper; i++ )
     {
+      gp_Pnt p = points->Vertice( i );
       if( i==aLower )
-        myBound.Set( theCoords->Value( i ) );
+        myBound.Set( p );
       else
-      {
-        gp_Pnt aPnt = theCoords->Value( i );
-        myBound.Update( aPnt.X(), aPnt.Y(), aPnt.Z() );
-      }
+        myBound.Update( p.X(), p.Y(), p.Z() );
     }
   }
+}
+
+void HYDROGUI_BathymetryPrs::SetPoints( const Handle(TColgp_HArray1OfPnt)&     theCoords,
+                                        const Handle(Quantity_HArray1OfColor)& theColors )
+{
   AIS_PointCloud::SetPoints( theCoords, theColors );
+  UpdateBound();
 }
 
 void HYDROGUI_BathymetryPrs::Compute( const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
@@ -50,6 +73,9 @@ void HYDROGUI_BathymetryPrs::Compute( const Handle(PrsMgr_PresentationManager3d)
   if( theMode==BATH_HIGHLIGHT_MODE )
   {
     thePresentation->Clear();
+    if( myBound.IsVoid() )
+      UpdateBound();
+
     if( myBound.IsVoid() || 
         myBound.IsOpenXmin() || myBound.IsOpenXmax() ||
         myBound.IsOpenYmin() || myBound.IsOpenYmax() ||
@@ -100,6 +126,9 @@ void HYDROGUI_BathymetryPrs::ComputeSelection( const Handle(SelectMgr_Selection)
 {
   if( theMode == 0 )
   {
+    if( myBound.IsVoid() )
+      UpdateBound();
+
     if( myBound.IsVoid() || 
         myBound.IsOpenXmin() || myBound.IsOpenXmax() ||
         myBound.IsOpenYmin() || myBound.IsOpenYmax() ||