From: ouv Date: Wed, 11 Sep 2013 10:47:36 +0000 (+0000) Subject: HYDRO bug 28: crash when Import image. X-Git-Tag: BR_hydro_v_0_1~41 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=e621d05044c11066b12460ca748f67ab6ee7879f;p=modules%2Fhydro.git HYDRO bug 28: crash when Import image. --- diff --git a/src/HYDROGUI/HYDROGUI_ImportImageOp.cxx b/src/HYDROGUI/HYDROGUI_ImportImageOp.cxx index 30ce1388..86055e82 100644 --- a/src/HYDROGUI/HYDROGUI_ImportImageOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ImportImageOp.cxx @@ -183,22 +183,8 @@ bool HYDROGUI_ImportImageOp::processApply( int& theUpdateFlags, } } - if( !myPreviewPrs ) - return false; - - QImage anImage = myPreviewPrs->getImage(); - bool anIsRefImage = aPanel->getTransformationMode() == HYDROGUI_ImportImageDlg::RefImage; - QTransform aRefTransform; - if( anIsRefImage && myRefPreviewPrs ) - { - Handle(HYDROData_Image) aRefImageObj = - Handle(HYDROData_Image)::DownCast( myRefPreviewPrs->getObject() ); - if( !aRefImageObj.IsNull() ) - aRefTransform = aRefImageObj->Trsf(); - } - HYDROGUI_ImportImageDlg::TransformationDataMap aMap; if( !aPanel->getTransformationDataMap( aMap ) ) return false; @@ -272,7 +258,7 @@ bool HYDROGUI_ImportImageOp::processApply( int& theUpdateFlags, QTransform aTransform; if( anIsRefImage ) - aTransform = aTransform1Inverted * aTransform3 * aRefTransform; + aTransform = aTransform1Inverted * aTransform3 * myRefTransform; else aTransform = aTransform1Inverted * aTransform2; @@ -287,7 +273,7 @@ bool HYDROGUI_ImportImageOp::processApply( int& theUpdateFlags, anImageObj->SetName( anImageName ); - anImageObj->SetImage( anImage ); + anImageObj->SetImage( myImage ); anImageObj->SetTrsf( aTransform ); if( anIsRefImage ) @@ -323,18 +309,23 @@ bool HYDROGUI_ImportImageOp::processApply( int& theUpdateFlags, void HYDROGUI_ImportImageOp::onCreatePreview( QImage theImage ) { + myImage = theImage; + LightApp_Application* anApp = module()->getApp(); myActiveViewManager = anApp->activeViewManager(); myPreviewPrs = new HYDROGUI_PrsImage( myIsEdit ? myEditedObject : 0 ); - myPreviewPrs->setImage( theImage ); + myPreviewPrs->setImage( myImage ); myPreviewPrs->compute(); myPreviewViewManager = dynamic_cast( anApp->createViewManager( GraphicsView_Viewer::Type() ) ); if( myPreviewViewManager ) { + 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() ) @@ -365,7 +356,7 @@ void HYDROGUI_ImportImageOp::onCreatePreview( QImage theImage ) anImageName = HYDROGUI_Tool::GenerateObjectName( module(), "Image" ); aPanel->setImageName( anImageName ); - aPanel->setImageSize( theImage.size() ); + aPanel->setImageSize( myImage.size() ); aPanel->initializePointSelection(); onPointSelected( false ); @@ -393,6 +384,8 @@ void HYDROGUI_ImportImageOp::onPointCoordChanged( bool theIsRef, void HYDROGUI_ImportImageOp::onRefImageActivated( const QString& theName ) { + myRefTransform.reset(); + GraphicsView_ViewPort* aViewPort = 0; if( myPreviewViewManager ) if( GraphicsView_Viewer* aViewer = myPreviewViewManager->getViewer() ) @@ -419,6 +412,7 @@ void HYDROGUI_ImportImageOp::onRefImageActivated( const QString& theName ) if( !anImageObj.IsNull() ) { anImage = anImageObj->Image(); + myRefTransform = anImageObj->Trsf(); myRefPreviewPrs = new HYDROGUI_PrsImage( anImageObj ); myRefPreviewPrs->setImage( anImage ); @@ -450,6 +444,11 @@ void HYDROGUI_ImportImageOp::onRefImageActivated( const QString& theName ) onPointSelected( true ); } +void HYDROGUI_ImportImageOp::onLastViewClosed( SUIT_ViewManager* theViewManager ) +{ + closePreview(); +} + void HYDROGUI_ImportImageOp::onPointSelected() { onPointSelected( myRefPreviewPrs && myRefPreviewPrs->isSelected() ); @@ -495,6 +494,9 @@ void HYDROGUI_ImportImageOp::closePreview() if( myPreviewViewManager ) { + disconnect( myPreviewViewManager, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ), + this, SLOT( onLastViewClosed( SUIT_ViewManager* ) ) ); + module()->getApp()->removeViewManager( myPreviewViewManager ); // myPreviewViewManager is deleted here myPreviewViewManager = 0; } diff --git a/src/HYDROGUI/HYDROGUI_ImportImageOp.h b/src/HYDROGUI/HYDROGUI_ImportImageOp.h index 9dd9c050..67be1e10 100644 --- a/src/HYDROGUI/HYDROGUI_ImportImageOp.h +++ b/src/HYDROGUI/HYDROGUI_ImportImageOp.h @@ -58,6 +58,8 @@ protected slots: void onPointCoordChanged( bool, int, bool, int ); void onRefImageActivated( const QString& ); + void onLastViewClosed( SUIT_ViewManager* ); + void onPointSelected(); void onPointSelected( bool theIsRefImage ); @@ -74,6 +76,9 @@ private: HYDROGUI_PrsImage* myPreviewPrs; HYDROGUI_PrsImage* myRefPreviewPrs; + QImage myImage; + QTransform myRefTransform; + int myPointType; };