Salome HOME
refs #1278: by default objects in study are not expanded
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_BathymetryPrs.cxx
index 2bcc235db51e1122cf10b639a2c62d34b3c66ed7..e6e427b44aad5f8f438b55adf586c5c8699466f3 100644 (file)
 #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,
@@ -67,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() ||
@@ -117,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() ||