Salome HOME
Dump Image data to python script (Feature #13).
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_ObjSelector.cxx
index 737b19f3702e83acd49d40a45126fd30efc8ff42..04bd20f0c0c4d67f5386a436cfe388b0278763d3 100644 (file)
 
 #include "HYDROGUI_DataModel.h"
 #include "HYDROGUI_Module.h"
+#include "HYDROGUI_Tool.h"
 
 #include <GraphicsView_Object.h>
 
 #include <LightApp_Application.h>
-#include <LightApp_DataOwner.h>
 #include <LightApp_GVSelector.h>
 #include <LightApp_SelectionMgr.h>
 
@@ -94,28 +94,17 @@ void HYDROGUI_ObjSelector::OnSelectionChanged()
   if( !myBtn->isChecked() )
     return;
 
-  SUIT_SelectionMgr* aSelMgr = myModule->getApp()->selectionMgr();
-  SUIT_DataOwnerPtrList anOwners;
-  aSelMgr->selected( anOwners );
+  QString anObjName;
+  Handle(HYDROData_Object) anObject = HYDROGUI_Tool::GetSelectedObject( myModule );
+  if( !anObject.IsNull() )
+    anObjName = anObject->GetName();
 
-  HYDROGUI_DataModel* aModel = myModule->getDataModel();
+  SetName( anObjName );
+}
 
-  QString anObjName;
-  foreach( SUIT_DataOwner* anOwner, anOwners )
-  {
-    LightApp_DataOwner* aGrDOwner = dynamic_cast<LightApp_DataOwner*>( anOwner );
-    if( aGrDOwner )
-    {
-      QString anEntry = aGrDOwner->entry();
-      Handle(HYDROData_Object) anObject = aModel->objectByEntry( anEntry, KIND_IMAGE );
-      if( !anObject.IsNull() )
-      {
-        anObjName = anObject->GetName();
-        break;
-      }
-    }
-  }
-  myObjName->setText( anObjName );
+void HYDROGUI_ObjSelector::SetName( const QString& theName )
+{
+  myObjName->setText( theName );
 }
 
 QString HYDROGUI_ObjSelector::GetName() const