#include <HYDROData_Iterator.h>
+#include <HYDROOperations_Factory.h>
+
#include <GraphicsView_ViewManager.h>
#include <GraphicsView_ViewPort.h>
#include <GraphicsView_Viewer.h>
}
}
- 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();
- anImageObj->SetVisible( HYDROGUI_Tool::GetActiveGraphicsViewId( module() ), true );
+ if( !myIsEdit )
+ module()->setObjectVisible( HYDROGUI_Tool::GetActiveGraphicsViewId( module() ), anImageObj, true );
+
+ if( myIsEdit )
+ 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() )
{
if( GraphicsView_ViewPort* aViewPort = aViewer->getActiveViewPort() )
{
- aViewPort->setMousePositionEnabled( true );
+ //aViewPort->setMousePositionEnabled( true ); //ouv: temporarily commented
aViewPort->addItem( myPreviewPrs );
aViewPort->fitAll();
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( !aViewPort )
return;
- aViewPort->removeItem( myRefPreviewPrs );
+ if( myPreviewPrs )
+ myPreviewPrs->setCaption( QString() );
+
+ if( myRefPreviewPrs )
+ {
+ myRefPreviewPrs->setCaption( QString() );
+ aViewPort->removeItem( myRefPreviewPrs );
- delete myRefPreviewPrs;
- myRefPreviewPrs = 0;
+ delete myRefPreviewPrs;
+ myRefPreviewPrs = 0;
+ }
QImage anImage;
Handle(HYDROData_Image) anImageObj = Handle(HYDROData_Image)::DownCast(
if( !anImageObj.IsNull() )
{
anImage = anImageObj->Image();
+ myRefTransform = anImageObj->Trsf();
myRefPreviewPrs = new HYDROGUI_PrsImage( anImageObj );
myRefPreviewPrs->setImage( anImage );
// vertically shift the reference prs relatively to the main prs
if( myPreviewPrs )
{
+ myPreviewPrs->setCaption( tr( "IMPORTED_IMAGE" ) );
+
QImage anImage = myPreviewPrs->getImage();
- myRefPreviewPrs->moveBy( 0, anImage.height() + 20 );
+ myRefPreviewPrs->moveBy( 0, anImage.height() + 60 );
+ myRefPreviewPrs->setCaption( tr( "REFERENCE_IMAGE" ) );
}
aViewPort->addItem( myRefPreviewPrs );
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;
}