Salome HOME
Dump Image data to python script (Feature #13).
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_ImportImageOp.cxx
index 15da4b459e780e10c3ade6a37252da601254a676..30ce138871e709defa5e5c9b735e0620d5740f9b 100644 (file)
@@ -31,6 +31,8 @@
 
 #include <HYDROData_Iterator.h>
 
+#include <HYDROOperations_Factory.h>
+
 #include <GraphicsView_ViewManager.h>
 #include <GraphicsView_ViewPort.h>
 #include <GraphicsView_Viewer.h>
@@ -298,10 +300,22 @@ bool HYDROGUI_ImportImageOp::processApply( int& theUpdateFlags,
   anImageObj->SetTrsfPoints( aPointA1, aPointB1, aPointC1,
                              aPointA2, aPointB2, aPointC2 );
 
+  if( !myIsEdit )
+  {
+    // Set imported file name for image
+    QString aFilePath = aPanel->getFileName();
+    anImageObj->SetFilePath( aFilePath );
+  }
+   
   // must be done after all checks and before calling SetVisible() method below
   closePreview();
 
-  anImageObj->SetVisible( HYDROGUI_Tool::GetActiveGraphicsViewId( module() ), true );
+  if( !myIsEdit )
+    module()->setObjectVisible( HYDROGUI_Tool::GetActiveGraphicsViewId( module() ), anImageObj, true );
+
+  if( myIsEdit )
+    if( HYDROOperations_Factory* aFactory = HYDROOperations_Factory::Factory() )
+      aFactory->UpdateImage( doc(), anImageObj );
 
   theUpdateFlags = UF_Model | UF_Viewer | UF_GV_Forced;
   return true;
@@ -387,10 +401,17 @@ void HYDROGUI_ImportImageOp::onRefImageActivated( const QString& theName )
   if( !aViewPort )
     return;
 
-  aViewPort->removeItem( myRefPreviewPrs );
+  if( myPreviewPrs )
+    myPreviewPrs->setCaption( QString() );
 
-  delete myRefPreviewPrs;
-  myRefPreviewPrs = 0;
+  if( myRefPreviewPrs )
+  {
+    myRefPreviewPrs->setCaption( QString() );
+    aViewPort->removeItem( myRefPreviewPrs );
+
+    delete myRefPreviewPrs;
+    myRefPreviewPrs = 0;
+  }
 
   QImage anImage;
   Handle(HYDROData_Image) anImageObj = Handle(HYDROData_Image)::DownCast(
@@ -409,8 +430,11 @@ void HYDROGUI_ImportImageOp::onRefImageActivated( const QString& theName )
     // vertically shift the reference prs relatively to the main prs
     if( myPreviewPrs )
     {
+      myPreviewPrs->setCaption( tr( "IMPORTED_IMAGE" ) );
+
       QImage anImage = myPreviewPrs->getImage();
-      myRefPreviewPrs->moveBy( 0, anImage.height() + 20 );
+      myRefPreviewPrs->moveBy( 0, anImage.height() + 60 );
+      myRefPreviewPrs->setCaption( tr( "REFERENCE_IMAGE" ) );
     }
 
     aViewPort->addItem( myRefPreviewPrs );