Salome HOME
Image composing.
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_ImportImageOp.cxx
index 3d844bc1e70cd2a2632a13b295070090375a268e..14c081255003be9a86e6ba8439faed75c4d14714 100644 (file)
@@ -29,8 +29,6 @@
 #include "HYDROGUI_Tool.h"
 #include "HYDROGUI_UpdateFlags.h"
 
-#include <HYDROData_Document.h>
-
 #include <GraphicsView_ViewManager.h>
 #include <GraphicsView_ViewPort.h>
 #include <GraphicsView_Viewer.h>
@@ -138,7 +136,7 @@ bool HYDROGUI_ImportImageOp::processApply( int& theUpdateFlags,
   if( !myIsEdit || ( !myEditedObject.IsNull() && myEditedObject->GetName() != anImageName ) )
   {
     // check that there are no other objects with the same name in the document
-    Handle(HYDROData_Object) anObject = findObjectByName( anImageName, KIND_UNKNOWN );
+    Handle(HYDROData_Object) anObject = HYDROGUI_Tool::FindObjectByName( module(), anImageName );
     if( !anObject.IsNull() )
     {
       theErrorMsg = tr( "OBJECT_EXISTS_IN_DOCUMENT" ).arg( anImageName );
@@ -257,18 +255,7 @@ void HYDROGUI_ImportImageOp::onCreatePreview( QImage theImage )
       anImageName = myEditedObject->GetName();
   }
   else
-  {
-    int anImageId = 1;
-    while( anImageId < 100 )
-    {
-      anImageName = QString( "Image_%1" ).arg( QString::number( anImageId++ ) );
-
-      // check that there are no other objects with the same name in the document
-      Handle(HYDROData_Object) anObject = findObjectByName( anImageName, KIND_UNKNOWN );
-      if( anObject.IsNull() )
-        break;
-    }
-  }
+    anImageName = HYDROGUI_Tool::GenerateObjectName( module(), "Image" );
   aPanel->setImageName( anImageName );
 
   aPanel->initializePointSelection();