+ myPreviewPrs->setTransformationPointType( thePointType );
+ if( myRefPreviewPrs )
+ myRefPreviewPrs->setTransformationPointType( thePointType );
+}
+
+void HYDROGUI_ImportImageOp::onPointCoordChanged( bool theIsRef,
+ int thePointType,
+ bool theIsY,
+ int theValue )
+{
+ if( !theIsRef && myPreviewPrs )
+ myPreviewPrs->updateTransformationPoint( thePointType, theIsY, theValue );
+ else if( theIsRef && myRefPreviewPrs )
+ myRefPreviewPrs->updateTransformationPoint( thePointType, theIsY, theValue );
+}
+
+void HYDROGUI_ImportImageOp::onModeActivated( int theMode )
+{
+ HYDROGUI_ImportImageDlg* aPanel = (HYDROGUI_ImportImageDlg*)inputPanel();
+
+ QString aRefImageName;
+ if( theMode == HYDROData_Image::ReferenceImage )
+ {
+ aRefImageName = aPanel->getRefImageName();
+ if( aRefImageName.isEmpty() )
+ return; // do nothing in this case to avoid visual moving of preview prs
+ onRefImageActivated( aRefImageName );
+ }
+ else
+ {
+ if( myRefViewManager )
+ {
+ closeView( myRefViewManager );
+ }
+ }
+}
+
+void HYDROGUI_ImportImageOp::onRefImageActivated( const QString& theName )
+{
+ if( theName.isEmpty() ) {
+ if( myRefViewManager )
+ closeView( myRefViewManager );
+ return;
+ }
+
+ GraphicsView_ViewPort* aViewPort = 0;
+
+ LightApp_Application* anApp = module()->getApp();
+ ///// Get a view port for the reference image preview
+ if( myRefViewManager )
+ {
+ if( GraphicsView_Viewer* aViewer = myRefViewManager->getViewer() )
+ {
+ aViewPort = aViewer->getActiveViewPort();
+ }
+ }
+ else
+ {
+ anApp = module()->getApp();
+ // Init reference image preview
+ myRefViewManager =
+ dynamic_cast<GraphicsView_ViewManager*>( anApp->createViewManager( GraphicsView_Viewer::Type() ) );
+ if( myRefViewManager )
+ {
+ connect( myRefViewManager, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
+ this, SLOT( onLastViewClosed( SUIT_ViewManager* ) ) );
+
+ module()->setViewManagerRole( myRefViewManager, HYDROGUI_Module::VMR_ReferenceImage );
+ myRefViewManager->setTitle( tr( "REFERENCE_IMAGE" ) );
+ if( GraphicsView_Viewer* aViewer = myRefViewManager->getViewer() )
+ {
+ aViewPort = aViewer->getActiveViewPort();
+ connect( aViewer, SIGNAL( selectionChanged( GV_SelectionChangeStatus ) ),
+ this, SLOT( onRefPointSelected() ) );
+ }
+ }
+ }
+
+ if( !aViewPort )
+ return;
+
+ size_t aViewId = (size_t)myRefViewManager->getViewer();
+
+ // Remove the old presentation of the reference image if any
+ if( myRefPreviewPrs )
+ {
+ module()->setObjectVisible( aViewId, myRefPreviewPrs->getObject(), false );
+
+ myRefPreviewPrs->setCaption( QString() );
+ aViewPort->removeItem( myRefPreviewPrs );
+
+ delete myRefPreviewPrs;
+ myRefPreviewPrs = 0;
+ }
+
+ // Create a new reference image presentation
+ QImage anImage;
+ Handle(HYDROData_Image) anImageObj = Handle(HYDROData_Image)::DownCast(
+ HYDROGUI_Tool::FindObjectByName( module(), theName, KIND_IMAGE ) );
+ HYDROGUI_ImportImageDlg* aPanel = (HYDROGUI_ImportImageDlg*)inputPanel();
+ if( !anImageObj.IsNull() )
+ {
+ anImage = anImageObj->Image();
+
+ myRefPreviewPrs = new HYDROGUI_PrsImage( anImageObj );
+ myRefPreviewPrs->setImage( anImage, true );
+
+ myRefPreviewPrs->setIsTransformationPointPreview( true );
+ myRefPreviewPrs->setTransformationPointType( myPointType );
+
+ myRefPreviewPrs->setIsByTwoPoints( aPanel->isByTwoPoints() );
+
+ myRefPreviewPrs->setTransformationPointCursorShape( module()->getPrefEditCursor().shape() );
+
+ // Add the new reference image presentation to the appropriate view
+ aViewPort->addItem( myRefPreviewPrs );
+
+ module()->setObjectVisible( aViewId, anImageObj, true );
+ }
+
+ aViewPort->fitAll();
+
+ // Split views horizontally
+ if( anApp->desktop()->inherits( "STD_TabDesktop" ) )
+ {
+ qApp->processEvents();
+ QtxWorkstack* aWorkstack = ( (STD_TabDesktop*)anApp->desktop() )->workstack();
+ aViewPort->activateWindow();
+ aViewPort->show();
+ aViewPort->setFocus(Qt::ActiveWindowFocusReason);
+ aWorkstack->splitHorizontal();
+ }
+
+ // Initialize the dialog
+ aPanel->setImageSize( anImage.size(), true );
+ aPanel->initializePointSelection();
+ onPointSelected( true );
+}
+
+void HYDROGUI_ImportImageOp::onLastViewClosed( SUIT_ViewManager* theViewManager )
+{
+ closePreview();