Salome HOME
lot 10 - warnings for DTM - untested
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_ShapeBathymetry.cxx
index dfc3a62cf055cb508153a1561e1ac9aa06ea9b22..b3d390141093fd35b134e305d1bd9d1d8c234022 100644 (file)
@@ -27,6 +27,8 @@
 #include <OCCViewer_ViewWindow.h>
 #include <OCCViewer_ViewPort3d.h>
 #include <V3d_View.hxx>
+#include <QTime>
+#include <utilities.h>
 
 HYDROGUI_ShapeBathymetry::HYDROGUI_ShapeBathymetry( HYDROGUI_OCCDisplayer*                theDisplayer,
                                                     const Handle(AIS_InteractiveContext)& theContext,
@@ -183,7 +185,7 @@ void HYDROGUI_ShapeBathymetry::GetRange( double& theMin, double& theMax ) const
 
 void HYDROGUI_ShapeBathymetry::RescaleByVisible( OCCViewer_ViewWindow* theWindow )
 {
-  QList<int> visible;
+  QVector<int> visible;
   visible.reserve( myCoords->Size() );
 
   OCCViewer_ViewPort3d* vp = theWindow->getViewPort();
@@ -192,8 +194,16 @@ void HYDROGUI_ShapeBathymetry::RescaleByVisible( OCCViewer_ViewWindow* theWindow
   int xp, yp;
   int w = vp->width();
   int h = vp->height();
+  int n = myCoords->Upper();
   bool isVisible;
-  for( int i=myCoords->Lower(), n=myCoords->Upper(); i<=n; i++ )
+
+#ifdef _DEBUG
+  MESSAGE("RescaleByVisible: " << n);
+  QTime t1;
+  t1.start();
+#endif
+
+  for( int i=myCoords->Lower(); i<=n; i++ )
   {
     gp_Pnt p = myCoords->Value( i );
     v->Convert( p.X(), p.Y(), p.Z(), xp, yp );
@@ -202,16 +212,26 @@ void HYDROGUI_ShapeBathymetry::RescaleByVisible( OCCViewer_ViewWindow* theWindow
       visible.append( i );
   }
 
+#ifdef _DEBUG
+  MESSAGE("Time after visibles search:" << t1.elapsed());
+#endif
+
   //TODO: question: empty visible part produce empty bathymetry or complete bathymetry?
   // For now "complete" is implemented
   Rescale( visible, visible.isEmpty() );
+
+#ifdef _DEBUG
+  MESSAGE("Time after rescale:" << t1.elapsed());
+#endif
 }
 
-QList<int> HYDROGUI_ShapeBathymetry::selected() const
+QVector<int> HYDROGUI_ShapeBathymetry::selected() const
 {
-  QList<int> selected;
+  QVector<int> selected;
   selected.reserve( myCoords->Size() );
 
+  Handle(AIS_InteractiveObject) obj = getAISObjects().first();
+
   Handle(AIS_InteractiveContext) c = getContext();
   if( !c.IsNull() )
   {
@@ -222,7 +242,7 @@ QList<int> HYDROGUI_ShapeBathymetry::selected() const
       {
         Handle(HYDROGUI_BathymetryPointOwner) anOwner = 
           Handle(HYDROGUI_BathymetryPointOwner)::DownCast( lc->SelectedOwner() );
-        if( anOwner )
+        if( !anOwner.IsNull() && anOwner->Selectable()==obj )
           selected.append( anOwner->GetIndex() );
       }
     }
@@ -232,7 +252,7 @@ QList<int> HYDROGUI_ShapeBathymetry::selected() const
 
 void HYDROGUI_ShapeBathymetry::RescaleBySelection()
 {
-  QList<int> selection = selected();
+  QVector<int> selection = selected();
 
   //TODO: question: empty selection produce empty bathymetry or complete bathymetry?
   // For now "complete" is implemented
@@ -241,21 +261,24 @@ void HYDROGUI_ShapeBathymetry::RescaleBySelection()
 
 void HYDROGUI_ShapeBathymetry::Rescale( double theMin, double theMax )
 {
-  getContext()->ClearSelected();
+  getContext()->ClearSelected(true);
   myMin = qMin( theMin, theMax );
   myMax = qMax( theMin, theMax );
   setToUpdateColorScale( true );
 
   if( !getAISObjects().isEmpty() )
-    getAISObjects()[0]->Redisplay();
+  {
+    getContext()->RecomputePrsOnly( getAISObjects()[0], true );
+    //getAISObjects()[0]->Redisplay();
+}
 }
 
 void HYDROGUI_ShapeBathymetry::RescaleDefault()
 {
-  Rescale( QList<int>(), true );
+  Rescale( QVector<int>(), true );
 }
 
-void HYDROGUI_ShapeBathymetry::Rescale( const QList<int>& theIndices, bool isForcedAll )
+void HYDROGUI_ShapeBathymetry::Rescale( const QVector<int>& theIndices, bool isForcedAll )
 {
   double aMin = 0, aMax = 0;
   if( !myCoords.IsNull() )
@@ -282,7 +305,7 @@ void HYDROGUI_ShapeBathymetry::Build()
   buildShape();
 }
 
-void HYDROGUI_ShapeBathymetry::TextLabels( bool isOn )
+void HYDROGUI_ShapeBathymetry::TextLabels( bool isOn, bool isUpdateCurrentViewer )
 {
   if( getAISObjects().isEmpty() )
     return;
@@ -291,12 +314,15 @@ void HYDROGUI_ShapeBathymetry::TextLabels( bool isOn )
   if( prs.IsNull() )
     return;
 
-  QList<int> selection;
+  QVector<int> selection;
   if( isOn )
     selection = selected();
 
-  getContext()->ClearSelected();
+
+  //getContext()->ClearSelected(true);
   prs->SetTextLabels( selection );
-  prs->Redisplay();
+  getContext()->RecomputePrsOnly( prs, Standard_False, Standard_False );
+  //prs->Redisplay();
+  if( isUpdateCurrentViewer )
   getContext()->UpdateCurrentViewer();
 }