Salome HOME
cleaning some comments
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_ShapeBathymetry.cxx
index 156e76c48f45df748833f62a8501fc4d1d058469..a6de2d915509941d23825af2618fac74c0cf06e5 100644 (file)
@@ -20,6 +20,7 @@
 #include <HYDROGUI_OCCDisplayer.h>
 #include <HYDROGUI_BathymetryPrs.h>
 #include <HYDROData_Bathymetry.h>
+#include <HYDROGUI_Tool.h>
 
 #include <AIS_InteractiveContext.hxx>
 #include <AIS_ColorScale.hxx>
@@ -30,6 +31,9 @@
 #include <QTime>
 #include <utilities.h>
 
+//#define _DEVDEBUG_
+#include "HYDRO_trace.hxx"
+
 HYDROGUI_ShapeBathymetry::HYDROGUI_ShapeBathymetry( HYDROGUI_OCCDisplayer*                theDisplayer,
                                                     const Handle(AIS_InteractiveContext)& theContext,
                                                     const Handle(HYDROData_Bathymetry)&   theBathymetry,
@@ -67,6 +71,7 @@ void HYDROGUI_ShapeBathymetry::update( bool theIsUpdateViewer, bool isDeactivate
 
 QList<Handle(AIS_InteractiveObject)> HYDROGUI_ShapeBathymetry::createShape() const
 {
+  DEBTRACE("createShape");
   QList<Handle(AIS_InteractiveObject)> shapes;
 
   Handle(AIS_InteractiveObject) aPntCloud;
@@ -96,6 +101,7 @@ QList<Handle(AIS_InteractiveObject)> HYDROGUI_ShapeBathymetry::createShape() con
 
 void HYDROGUI_ShapeBathymetry::UpdateWithColorScale( const Handle(AIS_ColorScale)& theColorScale )
 {
+  DEBTRACE("UpdateWithColorScale");
   if (!myCoords || getAISObjects().isEmpty())
     return;
 
@@ -173,7 +179,7 @@ void HYDROGUI_ShapeBathymetry::GetRange( double& theMin, double& theMax ) const
 {
   if( !myRangeInitialized )
   {
-    HYDROGUI_ShapeBathymetry* that = 
+    HYDROGUI_ShapeBathymetry* that =
       const_cast<HYDROGUI_ShapeBathymetry*>( this );
     that->RescaleDefault();
     that->myRangeInitialized = true;
@@ -227,26 +233,15 @@ void HYDROGUI_ShapeBathymetry::RescaleByVisible( OCCViewer_ViewWindow* theWindow
 
 QVector<int> HYDROGUI_ShapeBathymetry::selected() const
 {
+  DEBTRACE("selected");
   QVector<int> selected;
-  selected.reserve( myCoords->Size() );
 
-  Handle(AIS_InteractiveObject) obj = getAISObjects().first();
+  // HYDROGUI_BathymetryPrs::ClearSelected() called before: Nothing left...
 
-  Handle(AIS_InteractiveContext) c = getContext();
-  if( !c.IsNull() )
-  {
-    Handle(AIS_LocalContext) lc = c->LocalContext();
-    if( !lc.IsNull() )
-    {
-      for( lc->InitSelected(); lc->MoreSelected(); lc->NextSelected() )
-      {
-        Handle(HYDROGUI_BathymetryPointOwner) anOwner = 
-          Handle(HYDROGUI_BathymetryPointOwner)::DownCast( lc->SelectedOwner() );
-        if( !anOwner.IsNull() && anOwner->Selectable()==obj )
-          selected.append( anOwner->GetIndex() );
-      }
-    }
-  }
+  Handle(HYDROGUI_BathymetryPrs) aPntCloud = Handle(HYDROGUI_BathymetryPrs)::DownCast( getAISObjects()[0] );
+  if (!aPntCloud.IsNull())
+    selected = aPntCloud->getSelectedPoints();
+  DEBTRACE("selected " << selected.size());
   return selected;
 }
 
@@ -261,15 +256,14 @@ 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() )
   {
-    getContext()->RecomputePrsOnly( getAISObjects()[0] );
-    //getAISObjects()[0]->Redisplay();
+    getContext()->RecomputePrsOnly( getAISObjects()[0], true );
   }
 }
 
@@ -307,6 +301,7 @@ void HYDROGUI_ShapeBathymetry::Build()
 
 void HYDROGUI_ShapeBathymetry::TextLabels( bool isOn, bool isUpdateCurrentViewer )
 {
+  DEBTRACE("TextLabels " << isOn << " " << isUpdateCurrentViewer);
   if( getAISObjects().isEmpty() )
     return;
 
@@ -318,10 +313,9 @@ void HYDROGUI_ShapeBathymetry::TextLabels( bool isOn, bool isUpdateCurrentViewer
   if( isOn )
     selection = selected();
 
-  //getContext()->ClearSelected();
+
   prs->SetTextLabels( selection );
   getContext()->RecomputePrsOnly( prs, Standard_False, Standard_False );
-  //prs->Redisplay();
   if( isUpdateCurrentViewer )
-    getContext()->UpdateCurrentViewer();
+  getContext()->UpdateCurrentViewer();
 }