Salome HOME
cleaning some comments
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_BathymetrySelectionOp.cxx
index 2aeb9daaf93de8e957904b54328a748e1b51fd45..8f723525b11fc5676efb61d15b84b8d3d5597266 100644 (file)
 #include <HYDROGUI_BathymetryPrs.h>
 #include <HYDROGUI_BathymetryOp.h>
 #include <HYDROGUI_ShapeBathymetry.h>
+#include <HYDROGUI_Operations.h>
 #include <OCCViewer_ViewManager.h>
 #include <LightApp_Application.h>
+#include <SUIT_Selector.h>
+#include <QAction>
+#include <QApplication>
+#include <QString>
+#include <QList>
+#include <LightApp_SelectionMgr.h>
+
+//#define _DEVDEBUG_
+#include "HYDRO_trace.hxx"
 
 HYDROGUI_BathymetrySelectionOp::HYDROGUI_BathymetrySelectionOp( HYDROGUI_Module* theModule )
 : HYDROGUI_Operation( theModule ), myIsActive( false )
 {
+  DEBTRACE("HYDROGUI_BathymetrySelectionOp");
 }
 
 HYDROGUI_BathymetrySelectionOp::~HYDROGUI_BathymetrySelectionOp()
@@ -36,16 +47,22 @@ HYDROGUI_BathymetrySelectionOp::~HYDROGUI_BathymetrySelectionOp()
 
 void HYDROGUI_BathymetrySelectionOp::startOperation()
 {
+  DEBTRACE("startOperation");
   activateSelection( true );
 }
 
 void HYDROGUI_BathymetrySelectionOp::abortOperation()
 {
+  DEBTRACE("abortOperation");
   activateSelection( false );
+
+  module()->action( BathymetrySelectionId )->setChecked( false );
+  module()->action( BathymetryTextId )->setChecked( false );
 }
 
 bool HYDROGUI_BathymetrySelectionOp::isValid( SUIT_Operation* theOtherOp ) const
 {
+  DEBTRACE("isValid");
   HYDROGUI_BathymetryOp* aBathOp = dynamic_cast<HYDROGUI_BathymetryOp*>( theOtherOp );
   return ( aBathOp != 0 );
 }
@@ -82,19 +99,25 @@ QList<Handle(HYDROGUI_BathymetryPrs)> getShownBathymetries( HYDROGUI_Module* the
 
 void HYDROGUI_BathymetrySelectionOp::activateSelection( bool isActive )
 {
+  DEBTRACE("activateSelection " << isActive);
   if( myIsActive==isActive )
     return;
 
+  getContext( module() )->ClearSelected(true);
+  qApp->setOverrideCursor( Qt::WaitCursor );
+  getContext( module() )->ClearSelected(true);
   Handle(AIS_InteractiveContext) ctx = getContext( module() );
   QList<Handle(HYDROGUI_BathymetryPrs)> baths = getShownBathymetries( module() );
   if( isActive )
   {
-    const int aSelectionMode = 1;
-    ctx->OpenLocalContext( Standard_True );
+    const int aSelectionMode = 1;  // Cf. AIS_PointCloud 0=selection by points ?
     foreach( Handle(HYDROGUI_BathymetryPrs) bath, baths )
     {
-      ctx->Activate( bath, aSelectionMode, Standard_True );
-      bath->SetAutoHilight( Standard_False );
+      DEBTRACE("bathy name: " << bath->GetShape()->getObject()->GetName().toStdString());
+      ctx->Deactivate(bath);
+      ctx->RemoveFilters();
+      ctx->SetSelectionModeActive (bath, aSelectionMode, Standard_True, AIS_SelectionModesConcurrency_Multiple, Standard_False);
+      bath->SetAutoHilight( Standard_False ); // True bloque le passage dans hilightSelected...
     }
     ctx->UpdateCurrentViewer();
   }
@@ -103,12 +126,15 @@ void HYDROGUI_BathymetrySelectionOp::activateSelection( bool isActive )
     foreach( Handle(HYDROGUI_BathymetryPrs) bath, baths )
     {
       bath->ClearSelected();
+      bath->ClearSelectedPoints();
       bath->SetAutoHilight( Standard_True );
       bath->GetShape()->TextLabels( false );
       ctx->Deactivate( bath );
+      ctx->SetSelectionModeActive (bath, 2, Standard_True, AIS_SelectionModesConcurrency_Multiple, Standard_False);
     }
-    ctx->CloseLocalContext( -1, Standard_True );
   }
 
   myIsActive = isActive;
+
+  qApp->restoreOverrideCursor();
 }