Salome HOME
Merge branch 'BR_1328' into BR_DEMO
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_BathymetrySelectionOp.cxx
index aa3e0f4b09de36e72580098fc429fc4f7869bec3..2aeb9daaf93de8e957904b54328a748e1b51fd45 100644 (file)
@@ -20,6 +20,8 @@
 #include <HYDROGUI_BathymetrySelectionOp.h>
 #include <HYDROGUI_Module.h>
 #include <HYDROGUI_BathymetryPrs.h>
+#include <HYDROGUI_BathymetryOp.h>
+#include <HYDROGUI_ShapeBathymetry.h>
 #include <OCCViewer_ViewManager.h>
 #include <LightApp_Application.h>
 
@@ -42,28 +44,29 @@ void HYDROGUI_BathymetrySelectionOp::abortOperation()
   activateSelection( false );
 }
 
-void HYDROGUI_BathymetrySelectionOp::commitOperation()
+bool HYDROGUI_BathymetrySelectionOp::isValid( SUIT_Operation* theOtherOp ) const
 {
-  activateSelection( false );
-}
-
-void HYDROGUI_BathymetrySelectionOp::stopOperation()
-{
-  activateSelection( false );
+  HYDROGUI_BathymetryOp* aBathOp = dynamic_cast<HYDROGUI_BathymetryOp*>( theOtherOp );
+  return ( aBathOp != 0 );
 }
 
-void HYDROGUI_BathymetrySelectionOp::activateSelection( bool isActive )
+OCCViewer_Viewer* getViewer( HYDROGUI_Module* theModule )
 {
-  if( myIsActive==isActive )
-    return;
-
-  LightApp_Application* app = module()->getApp();
+  LightApp_Application* app = theModule->getApp();
   OCCViewer_ViewManager* mgr = dynamic_cast<OCCViewer_ViewManager*>
     ( app->getViewManager( OCCViewer_Viewer::Type(), true ) );
-  Handle(AIS_InteractiveContext) ctx = mgr->getOCCViewer()->getAISContext();
+  return mgr->getOCCViewer();
+}
 
+Handle(AIS_InteractiveContext) getContext( HYDROGUI_Module* theModule )
+{
+  return getViewer( theModule )->getAISContext();
+}
 
+QList<Handle(HYDROGUI_BathymetryPrs)> getShownBathymetries( HYDROGUI_Module* theModule )
+{
   QList<Handle(HYDROGUI_BathymetryPrs)> baths;
+  Handle(AIS_InteractiveContext) ctx = getContext( theModule );
 
   AIS_ListOfInteractive objs;
   ctx->DisplayedObjects( objs );
@@ -74,19 +77,36 @@ void HYDROGUI_BathymetrySelectionOp::activateSelection( bool isActive )
     if( !bath.IsNull() )
       baths.append( bath );
   }
+  return baths;
+}
+
+void HYDROGUI_BathymetrySelectionOp::activateSelection( bool isActive )
+{
+  if( myIsActive==isActive )
+    return;
 
+  Handle(AIS_InteractiveContext) ctx = getContext( module() );
+  QList<Handle(HYDROGUI_BathymetryPrs)> baths = getShownBathymetries( module() );
   if( isActive )
   {
     const int aSelectionMode = 1;
     ctx->OpenLocalContext( Standard_True );
     foreach( Handle(HYDROGUI_BathymetryPrs) bath, baths )
+    {
       ctx->Activate( bath, aSelectionMode, Standard_True );
+      bath->SetAutoHilight( Standard_False );
+    }
     ctx->UpdateCurrentViewer();
   }
   else
   {
     foreach( Handle(HYDROGUI_BathymetryPrs) bath, baths )
+    {
+      bath->ClearSelected();
+      bath->SetAutoHilight( Standard_True );
+      bath->GetShape()->TextLabels( false );
       ctx->Deactivate( bath );
+    }
     ctx->CloseLocalContext( -1, Standard_True );
   }