Salome HOME
HYDROGUI_Wizard has been refactored and now uses QStackedWidget instead of QWizard.
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_ShowHideOp.cxx
index 47e0a2b6e2362b06018c3b06ca51e5eeed6f6ced..0fefdfae2fc3ba43046a7cf061cb8b22f856eb7b 100644 (file)
 
 #include "HYDROGUI_ShowHideOp.h"
 
-#include "HYDROGUI_DataModel.h"
+#include <GraphicsView_Viewer.h>
+
 #include "HYDROGUI_Module.h"
 #include "HYDROGUI_Operations.h"
+#include "HYDROGUI_Tool.h"
 #include "HYDROGUI_UpdateFlags.h"
 
 #include <HYDROData_Iterator.h>
-#include <HYDROData_Object.h>
+#include <HYDROData_Entity.h>
+
+#include <LightApp_Application.h>
 
-#include <LightApp_DataOwner.h>
+#include <OCCViewer_ViewModel.h>
 
-#include <SUIT_SelectionMgr.h>
+#include <SUIT_ViewManager.h>
 
 HYDROGUI_ShowHideOp::HYDROGUI_ShowHideOp( HYDROGUI_Module* theModule, int theId )
 : HYDROGUI_Operation( theModule ),
@@ -59,7 +63,7 @@ void HYDROGUI_ShowHideOp::startOperation()
 {
   HYDROGUI_Operation::startOperation();
 
-  HYDROGUI_DataModel* aModel = module()->getDataModel();
+  size_t aViewId = HYDROGUI_Tool::GetActiveViewId( module() );
 
   // for all objects
   if( myId == ShowOnlyId || myId == ShowAllId || myId == HideAllId )
@@ -68,31 +72,41 @@ void HYDROGUI_ShowHideOp::startOperation()
     HYDROData_Iterator anIterator( doc() );
     for( ; anIterator.More(); anIterator.Next() )
     {
-      Handle(HYDROData_Object) anObject = anIterator.Current();
+      Handle(HYDROData_Entity) anObject = anIterator.Current();
       if( !anObject.IsNull() )
-        anObject->SetVisibility( aVisibility );
+        module()->setObjectVisible( aViewId, anObject, aVisibility );
     }
   }
 
   // for selected objects
   if( myId == ShowId || myId == ShowOnlyId || myId == HideId )
   {
-    SUIT_SelectionMgr* aSelectionMgr = selectionMgr();
-    SUIT_DataOwnerPtrList anOwners;
-    aSelectionMgr->selected( anOwners );
+    HYDROData_SequenceOfObjects aSeq = HYDROGUI_Tool::GetSelectedObjects( module() );
 
     bool aVisibility = myId == ShowId || myId == ShowOnlyId;
-    foreach( SUIT_DataOwner* aSUITOwner, anOwners )
+    for( Standard_Integer anIndex = 1, aLength = aSeq.Length(); anIndex <= aLength; anIndex++ )
+    {
+      Handle(HYDROData_Entity) anObject = aSeq.Value( anIndex );
+      if( !anObject.IsNull() )
+        module()->setObjectVisible( aViewId, anObject, aVisibility );
+    }
+  }
+
+  int anUpdateFlags = 0;
+
+  SUIT_ViewManager* aViewMgr = module()->getApp()->activeViewManager();
+  if ( aViewMgr )
+  {
+    if ( aViewMgr->getType() == GraphicsView_Viewer::Type() )
+    {
+      anUpdateFlags |= UF_Viewer;
+    }
+    else if ( aViewMgr->getType() == OCCViewer_Viewer::Type() )
     {
-      if( LightApp_DataOwner* anOwner = dynamic_cast<LightApp_DataOwner*>( aSUITOwner ) )
-      {
-        Handle(HYDROData_Object) anObject = aModel->objectByEntry( anOwner->entry() );
-        if( !anObject.IsNull() )
-          anObject->SetVisibility( aVisibility ? true : false );
-      }
+      anUpdateFlags |= UF_OCCViewer;
     }
   }
 
-  module()->update( UF_Viewer );
+  module()->update( anUpdateFlags );
   commit();
 }