}
}
- 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 )
anImageObj->SetTrsfPoints( aPointA1, aPointB1, aPointC1,
aPointA2, aPointB2, aPointC2 );
+ if( !myIsEdit )
+ {
+ // Set imported file name for image
+ QString aFilePath = aPanel->getFileName();
+ anImageObj->SetFilePath( aFilePath );
+ }
+
// must be done after all checks and before calling SetVisible() method below
closePreview();
module()->setObjectVisible( HYDROGUI_Tool::GetActiveGraphicsViewId( module() ), anImageObj, true );
if( myIsEdit )
- if( HYDROOperations_Factory* aFactory = HYDROOperations_Factory::Factory() )
- aFactory->UpdateImage( doc(), anImageObj );
+ anImageObj->Update();
theUpdateFlags = UF_Model | UF_Viewer | UF_GV_Forced;
return true;
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;
}