Salome HOME
Merge remote-tracking branch 'origin/BR_1321_ECW' into BR_DEMO
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_ImportImageOp.cxx
index a3d2c72e040aaed1a8d230cd4604687abf75e997..eef9bd9a7a4dc810fff8fbc9e7962e50ea98dd41 100644 (file)
@@ -23,7 +23,7 @@
 #include "HYDROGUI_ImportImageDlg.h"
 #include "HYDROGUI_Module.h"
 #include "HYDROGUI_PrsImage.h"
-#include "HYDROGUI_Tool.h"
+#include "HYDROGUI_Tool2.h"
 #include "HYDROGUI_UpdateFlags.h"
 
 #include <HYDROData_Iterator.h>
@@ -85,7 +85,7 @@ void HYDROGUI_ImportImageOp::startOperation()
       myEditedObject->GetLocalPoints( aLocalPointA, aLocalPointB, aLocalPointC );
 
       // Create the edited image preview presentation in the viewer
-      onCreatePreview( anImage );
+      onCreatePreview( anImage, NULL ); //TODO
 
       // Set transformation local points A,B,C to the image preview presentation
       setPresentationTrsfPoints( myPreviewPrs, anIsByTwoPoints, aLocalPointA, 
@@ -268,7 +268,8 @@ void HYDROGUI_ImportImageOp::commitOperation()
 HYDROGUI_InputPanel* HYDROGUI_ImportImageOp::createInputPanel() const
 {
   HYDROGUI_InputPanel* aPanel = new HYDROGUI_ImportImageDlg( module(), getName() );
-  connect( aPanel, SIGNAL( createPreview( QImage ) ), SLOT( onCreatePreview( QImage ) ) );
+  connect( aPanel, SIGNAL( createPreview( QImage, HYDROData_Image::ECW_FileInfo* ) ), 
+    SLOT( onCreatePreview( QImage, HYDROData_Image::ECW_FileInfo* ) ) );
   connect( aPanel, SIGNAL( activatePointSelection( int ) ), SLOT( onActivatePointSelection( int ) ) );
   connect( aPanel, SIGNAL( pointCoordChanged( bool, int, bool, int ) ), 
                      SLOT( onPointCoordChanged( bool, int, bool, int ) ) );
@@ -350,9 +351,22 @@ bool HYDROGUI_ImportImageOp::processApply( int& theUpdateFlags,
 {
   HYDROGUI_ImportImageDlg* aPanel = (HYDROGUI_ImportImageDlg*)inputPanel();
 
+  if( !myIsEdit )
+  {
+    QString aFilePath = aPanel->getFileName();
+    if( aFilePath.isEmpty() )
+    {
+      theErrorMsg = tr( "SELECT_IMAGE_FILE" ).arg( aFilePath );
+      return false;
+    }
+  }
+
   QString anImageName = aPanel->getImageName();
   if( anImageName.isEmpty() )
+  {
+    theErrorMsg = tr( "SELECT_IMAGE_NAME" ).arg( anImageName );
     return false;
+  }
 
   if( !myIsEdit || ( !myEditedObject.IsNull() && myEditedObject->GetName() != anImageName ) )
   {
@@ -509,14 +523,23 @@ bool HYDROGUI_ImportImageOp::processApply( int& theUpdateFlags,
   if ( isApplyAndClose() )
     theUpdateFlags |= UF_Viewer | UF_GV_Forced | UF_OCCViewer | UF_OCC_Forced;
 
+  if( isApplyAndClose() )
+  {
+    commitDocOperation(); // to save the modifications in the data model
+    return true;
+  }
 
   if( SetNextFile() )
   {
     theErrorMsg = "";
-    commitDocOperation(); // to save the modifications in the data model
+    module()->updateObjBrowser();
     return false;         // and to continue the operation
   }
 
+  /*if( myFiles.count() > 1 )
+  {
+    setIsApplyAndClose( true );
+  }*/
   return true;
 }
 
@@ -567,7 +590,7 @@ void HYDROGUI_ImportImageOp::apply()
   }
 }
 
-void HYDROGUI_ImportImageOp::onCreatePreview( QImage theImage )
+void HYDROGUI_ImportImageOp::onCreatePreview( QImage theImage, HYDROData_Image::ECW_FileInfo* theFileInfo )
 {
   HYDROGUI_ImportImageDlg* aPanel = (HYDROGUI_ImportImageDlg*)inputPanel();
 
@@ -666,7 +689,10 @@ void HYDROGUI_ImportImageOp::onCreatePreview( QImage theImage )
 
   aPanel->setImageSize( myImage.size() );
 
-  aPanel->initializePointSelection();
+  if (!theFileInfo)
+    aPanel->initializePointSelection();
+  else
+     aPanel->ECW_initializePointSelection(theFileInfo);
   onPointSelected( false );
   onSetCIsUsed( !aPanel->isByTwoPoints() );
 }