]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
Fixed bug for the case when the imported image is changed by choosing another file.
authorouv <ouv@opencascade.com>
Wed, 18 Sep 2013 12:51:35 +0000 (12:51 +0000)
committerouv <ouv@opencascade.com>
Wed, 18 Sep 2013 12:51:35 +0000 (12:51 +0000)
src/HYDROGUI/HYDROGUI_ImportImageOp.cxx

index 37fd753f8f3225ba81f3cbec8e00fffc1568b000..13fc3a7923b1513fedc9cfc0f64d2cce22f9db49 100644 (file)
@@ -308,52 +308,72 @@ bool HYDROGUI_ImportImageOp::processApply( int& theUpdateFlags,
 
 void HYDROGUI_ImportImageOp::onCreatePreview( QImage theImage )
 {
+  HYDROGUI_ImportImageDlg* aPanel = (HYDROGUI_ImportImageDlg*)inputPanel();
+
   myImage = theImage;
 
-  LightApp_Application* anApp = module()->getApp();
+  if( myPreviewPrs ) // if the image is changed by choosing another file
+  {
+    myPreviewPrs->setImage( myImage );
+    myPreviewPrs->compute();
 
-  myActiveViewManager = anApp->activeViewManager();
+    if( myPreviewViewManager )
+    {
+      if( GraphicsView_Viewer* aViewer = myPreviewViewManager->getViewer() )
+      {
+        if( GraphicsView_ViewPort* aViewPort = aViewer->getActiveViewPort() )
+        {
+          aViewPort->onBoundingRectChanged();
+          aViewPort->fitAll();
+        }
+      }
+    }
+  }
+  else
+  {
+    LightApp_Application* anApp = module()->getApp();
 
-  myPreviewPrs = new HYDROGUI_PrsImage( myIsEdit ? myEditedObject : 0 );
-  myPreviewPrs->setImage( myImage );
-  myPreviewPrs->compute();
+    myActiveViewManager = anApp->activeViewManager();
 
-  myPreviewViewManager =
-    dynamic_cast<GraphicsView_ViewManager*>( anApp->createViewManager( GraphicsView_Viewer::Type() ) );
-  if( myPreviewViewManager )
-  {
-    connect( myPreviewViewManager, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
-             this, SLOT( onLastViewClosed( SUIT_ViewManager* ) ) );
+    myPreviewPrs = new HYDROGUI_PrsImage( myIsEdit ? myEditedObject : 0 );
+    myPreviewPrs->setImage( myImage );
+    myPreviewPrs->compute();
 
-    module()->setViewManagerRole( myPreviewViewManager, HYDROGUI_Module::VMR_TransformImage );
-    myPreviewViewManager->setTitle( tr( "TRANSFORM_IMAGE" ) );
-    if( GraphicsView_Viewer* aViewer = myPreviewViewManager->getViewer() )
+    myPreviewViewManager =
+      dynamic_cast<GraphicsView_ViewManager*>( anApp->createViewManager( GraphicsView_Viewer::Type() ) );
+    if( myPreviewViewManager )
     {
-      if( GraphicsView_ViewPort* aViewPort = aViewer->getActiveViewPort() )
+      connect( myPreviewViewManager, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
+               this, SLOT( onLastViewClosed( SUIT_ViewManager* ) ) );
+
+      module()->setViewManagerRole( myPreviewViewManager, HYDROGUI_Module::VMR_TransformImage );
+      myPreviewViewManager->setTitle( tr( "TRANSFORM_IMAGE" ) );
+      if( GraphicsView_Viewer* aViewer = myPreviewViewManager->getViewer() )
       {
-        //aViewPort->setMousePositionEnabled( true ); //ouv: temporarily commented
+        if( GraphicsView_ViewPort* aViewPort = aViewer->getActiveViewPort() )
+        {
+          //aViewPort->setMousePositionEnabled( true ); //ouv: temporarily commented
 
-        aViewPort->addItem( myPreviewPrs );
-        aViewPort->fitAll();
+          aViewPort->addItem( myPreviewPrs );
+          aViewPort->fitAll();
 
-        myPreviewPrs->setIsTransformationPointPreview( true );
+          myPreviewPrs->setIsTransformationPointPreview( true );
+        }
+        connect( aViewer, SIGNAL( selectionChanged( GV_SelectionChangeStatus ) ),
+                 this, SLOT( onPointSelected() ) );
       }
-      connect( aViewer, SIGNAL( selectionChanged( GV_SelectionChangeStatus ) ),
-               this, SLOT( onPointSelected() ) );
     }
-  }
-
-  HYDROGUI_ImportImageDlg* aPanel = (HYDROGUI_ImportImageDlg*)inputPanel();
 
-  QString anImageName;
-  if( myIsEdit )
-  {
-    if( !myEditedObject.IsNull() )
-      anImageName = myEditedObject->GetName();
+    QString anImageName;
+    if( myIsEdit )
+    {
+      if( !myEditedObject.IsNull() )
+        anImageName = myEditedObject->GetName();
+    }
+    else
+      anImageName = HYDROGUI_Tool::GenerateObjectName( module(), "Image" );
+    aPanel->setImageName( anImageName );
   }
-  else
-    anImageName = HYDROGUI_Tool::GenerateObjectName( module(), "Image" );
-  aPanel->setImageName( anImageName );
 
   aPanel->setImageSize( myImage.size() );