Salome HOME
Minor fix.
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_DeleteOp.cxx
index 83372230525666d4519d3f2fb188997e1ff0568a..0e57e37266721a3c221e8627a2c0ec8cf1940b1e 100644 (file)
 
 #include "HYDROGUI_DeleteOp.h"
 
-#include "HYDROGUI_DataModel.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 <LightApp_Application.h>
-#include <LightApp_DataOwner.h>
 
 #include <SUIT_Desktop.h>
 #include <SUIT_MessageBox.h>
-#include <SUIT_SelectionMgr.h>
 
 HYDROGUI_DeleteOp::HYDROGUI_DeleteOp( HYDROGUI_Module* theModule )
 : HYDROGUI_Operation( theModule )
@@ -51,13 +47,8 @@ void HYDROGUI_DeleteOp::startOperation()
 {
   HYDROGUI_Operation::startOperation();
 
-  HYDROGUI_DataModel* aModel = module()->getDataModel();
-
-  SUIT_SelectionMgr* aSelectionMgr = selectionMgr();
-  SUIT_DataOwnerPtrList anOwners;
-  aSelectionMgr->selected( anOwners );
-
-  if( !anOwners.isEmpty() )
+  HYDROData_SequenceOfObjects aSeq = HYDROGUI_Tool::GetSelectedObjects( module() );
+  if( !aSeq.IsEmpty() )
   {
     int anAnswer = SUIT_MessageBox::question( module()->getApp()->desktop(),
                                               tr( "DELETE_OBJECTS" ),
@@ -71,14 +62,11 @@ void HYDROGUI_DeleteOp::startOperation()
     }
   }
 
-  foreach( SUIT_DataOwner* aSUITOwner, anOwners )
+  for( Standard_Integer anIndex = 1, aLength = aSeq.Length(); anIndex <= aLength; anIndex++ )
   {
-    if( LightApp_DataOwner* anOwner = dynamic_cast<LightApp_DataOwner*>( aSUITOwner ) )
-    {
-      Handle(HYDROData_Object) anObject = aModel->objectByEntry( anOwner->entry() );
-      if( !anObject.IsNull() )
-        anObject->Remove();
-    }
+    Handle(HYDROData_Object) anObject = aSeq.Value( anIndex );
+    if( !anObject.IsNull() )
+      anObject->Remove();
   }
 
   module()->update( UF_Model | UF_Viewer );