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() );