}
}
- 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;
QTransform aTransform;
if( anIsRefImage )
- aTransform = aTransform1Inverted * aTransform3 * aRefTransform;
+ aTransform = aTransform1Inverted * aTransform3 * myRefTransform;
else
aTransform = aTransform1Inverted * aTransform2;
anImageObj->SetName( anImageName );
- anImageObj->SetImage( anImage );
+ anImageObj->SetImage( myImage );
anImageObj->SetTrsf( aTransform );
if( anIsRefImage )
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<GraphicsView_ViewManager*>( 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() )
anImageName = HYDROGUI_Tool::GenerateObjectName( module(), "Image" );
aPanel->setImageName( anImageName );
- aPanel->setImageSize( theImage.size() );
+ aPanel->setImageSize( myImage.size() );
aPanel->initializePointSelection();
onPointSelected( false );
void HYDROGUI_ImportImageOp::onRefImageActivated( const QString& theName )
{
+ myRefTransform.reset();
+
GraphicsView_ViewPort* aViewPort = 0;
if( myPreviewViewManager )
if( GraphicsView_Viewer* aViewer = myPreviewViewManager->getViewer() )
if( !anImageObj.IsNull() )
{
anImage = anImageObj->Image();
+ myRefTransform = anImageObj->Trsf();
myRefPreviewPrs = new HYDROGUI_PrsImage( anImageObj );
myRefPreviewPrs->setImage( anImage );
onPointSelected( true );
}
+void HYDROGUI_ImportImageOp::onLastViewClosed( SUIT_ViewManager* theViewManager )
+{
+ closePreview();
+}
+
void HYDROGUI_ImportImageOp::onPointSelected()
{
onPointSelected( myRefPreviewPrs && myRefPreviewPrs->isSelected() );
if( myPreviewViewManager )
{
+ disconnect( myPreviewViewManager, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
+ this, SLOT( onLastViewClosed( SUIT_ViewManager* ) ) );
+
module()->getApp()->removeViewManager( myPreviewViewManager ); // myPreviewViewManager is deleted here
myPreviewViewManager = 0;
}