From: ouv Date: Wed, 18 Sep 2013 12:51:35 +0000 (+0000) Subject: Fixed bug for the case when the imported image is changed by choosing another file. X-Git-Tag: BR_hydro_v_0_1~17 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=28bc5b3e735a9c5ea83cadad5bd6af0a65928ea6;p=modules%2Fhydro.git Fixed bug for the case when the imported image is changed by choosing another file. --- diff --git a/src/HYDROGUI/HYDROGUI_ImportImageOp.cxx b/src/HYDROGUI/HYDROGUI_ImportImageOp.cxx index 37fd753f..13fc3a79 100644 --- a/src/HYDROGUI/HYDROGUI_ImportImageOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ImportImageOp.cxx @@ -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( 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( 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() );