1 // Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #include "HYDROGUI_ImportImageOp.h"
25 #include "HYDROGUI_DataModel.h"
26 #include "HYDROGUI_ImportImageDlg.h"
27 #include "HYDROGUI_Module.h"
28 #include "HYDROGUI_PrsImage.h"
29 #include "HYDROGUI_Tool.h"
30 #include "HYDROGUI_UpdateFlags.h"
32 #include <HYDROData_Iterator.h>
33 #include <HYDROData_Lambert93.h>
34 #include <HYDROData_OperationsFactory.h>
35 #include <HYDROData_Tool.h>
37 #include <GraphicsView_ViewManager.h>
38 #include <GraphicsView_ViewPort.h>
39 #include <GraphicsView_Viewer.h>
41 #include <LightApp_Application.h>
42 #include <LightApp_UpdateFlags.h>
44 #include <STD_TabDesktop.h>
45 #include <SUIT_Desktop.h>
46 #include <QtxWorkstack.h>
47 #include <QApplication>
49 HYDROGUI_ImportImageOp::HYDROGUI_ImportImageOp( HYDROGUI_Module* theModule,
50 const bool theIsEdit )
51 : HYDROGUI_Operation( theModule ),
52 myIsEdit( theIsEdit ),
54 myActiveViewManager( 0 ),
55 myPreviewViewManager( 0 ),
56 myRefViewManager( 0 ),
59 myPointType( HYDROGUI_PrsImage::None )
61 setName( theIsEdit ? tr( "EDIT_IMPORTED_IMAGE" ) : tr( "IMPORT_IMAGE" ) );
64 HYDROGUI_ImportImageOp::~HYDROGUI_ImportImageOp()
68 void HYDROGUI_ImportImageOp::startOperation()
70 HYDROGUI_Operation::startOperation();
72 HYDROGUI_ImportImageDlg* aPanel = (HYDROGUI_ImportImageDlg*)inputPanel();
74 aPanel->setIsEdit( myIsEdit );
76 QString aRefImageName;
80 myEditedObject = Handle(HYDROData_Image)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) );
81 if( !myEditedObject.IsNull() )
83 QImage anImage = myEditedObject->Image();
84 bool anIsByTwoPoints = myEditedObject->IsByTwoPoints();
86 QPoint aLocalPointA, aLocalPointB, aLocalPointC;
87 myEditedObject->GetLocalPoints( aLocalPointA, aLocalPointB, aLocalPointC );
89 onCreatePreview( anImage );
93 HYDROGUI_PrsImage::TransformationPointMap aPointMap =
94 myPreviewPrs->getTransformationPointMap();
95 if( !aPointMap.isEmpty() )
97 aPointMap[ HYDROGUI_PrsImage::PointA ].Point = aLocalPointA;
98 aPointMap[ HYDROGUI_PrsImage::PointB ].Point = aLocalPointB;
99 if ( !anIsByTwoPoints )
100 aPointMap[ HYDROGUI_PrsImage::PointC ].Point = aLocalPointC;
102 myPreviewPrs->setTransformationPointMap( aPointMap );
106 HYDROData_Image::TransformationMode aTrsfMode;
107 QPointF aTrsfPointA, aTrsfPointB, aTrsfPointC;
108 myEditedObject->GetGlobalPoints( aTrsfMode,
109 aTrsfPointA, aTrsfPointB, aTrsfPointC );
111 HYDROGUI_ImportImageDlg::TransformationDataMap aDataMap;
112 aDataMap[ HYDROGUI_PrsImage::PointA ] =
113 HYDROGUI_ImportImageDlg::ComputeTrsfData( aTrsfMode, aLocalPointA, aTrsfPointA );
114 aDataMap[ HYDROGUI_PrsImage::PointB ] =
115 HYDROGUI_ImportImageDlg::ComputeTrsfData( aTrsfMode, aLocalPointB, aTrsfPointB );
116 if ( !anIsByTwoPoints )
117 aDataMap[ HYDROGUI_PrsImage::PointC ] =
118 HYDROGUI_ImportImageDlg::ComputeTrsfData( aTrsfMode, aLocalPointC, aTrsfPointC );
120 aPanel->setTransformationMode( aTrsfMode );
121 aPanel->setTransformationDataMap( aDataMap );
122 aPanel->setByTwoPoints( anIsByTwoPoints );
124 // Set points on reference image
125 if ( aTrsfMode = HYDROData_Image::ReferenceImage )
127 Handle(HYDROData_Image) aRefImage = myEditedObject->GetTrsfReferenceImage();
128 if ( !aRefImage.IsNull() )
130 aRefImageName = aRefImage->GetName();
132 onRefImageActivated( aRefImageName );
133 if( myRefPreviewPrs )
135 HYDROGUI_PrsImage::TransformationPointMap aRefPointMap =
136 myRefPreviewPrs->getTransformationPointMap();
137 if( !aRefPointMap.isEmpty() )
139 aRefPointMap[ HYDROGUI_PrsImage::PointA ].Point = aTrsfPointA.toPoint();
140 aRefPointMap[ HYDROGUI_PrsImage::PointB ].Point = aTrsfPointB.toPoint();
141 if ( !anIsByTwoPoints )
142 aRefPointMap[ HYDROGUI_PrsImage::PointC ].Point = aTrsfPointC.toPoint();
144 myRefPreviewPrs->setTransformationPointMap( aRefPointMap );
148 HYDROGUI_ImportImageDlg::TransformationDataMap aRefDataMap;
149 aRefDataMap[ HYDROGUI_PrsImage::PointA ] = HYDROGUI_ImportImageDlg::TransformationData( aTrsfPointA.toPoint() );
150 aRefDataMap[ HYDROGUI_PrsImage::PointB ] = HYDROGUI_ImportImageDlg::TransformationData( aTrsfPointB.toPoint() );
151 if ( !anIsByTwoPoints )
152 aRefDataMap[ HYDROGUI_PrsImage::PointC ] = HYDROGUI_ImportImageDlg::TransformationData( aTrsfPointC.toPoint() );
154 aPanel->setTransformationDataMap( aRefDataMap, true, true );
160 // collect information about existing images
161 HYDROGUI_ImportImageDlg::PrsPointDataList aPrsPointDataList;
162 HYDROData_Iterator anIterator( doc(), KIND_IMAGE );
163 for( ; anIterator.More(); anIterator.Next() )
165 Handle(HYDROData_Image) anImageObj = Handle(HYDROData_Image)::DownCast( anIterator.Current() );
166 if( !anImageObj.IsNull() )
168 if( myIsEdit && IsEqual( anImageObj, myEditedObject ) )
171 QPoint aLocalPointA, aLocalPointB, aLocalPointC;
172 anImageObj->GetLocalPoints( aLocalPointA, aLocalPointB, aLocalPointC );
174 HYDROData_Image::TransformationMode aImgTrsfMode;
175 QPointF aTrsfPointA, aTrsfPointB, aTrsfPointC;
176 anImageObj->GetGlobalPoints( aImgTrsfMode,
177 aTrsfPointA, aTrsfPointB, aTrsfPointC );
179 HYDROGUI_ImportImageDlg::TransformationDataMap aDataMap;
180 aDataMap[ HYDROGUI_PrsImage::PointA ] =
181 HYDROGUI_ImportImageDlg::ComputeTrsfData( aImgTrsfMode, aLocalPointA, aTrsfPointA );
182 aDataMap[ HYDROGUI_PrsImage::PointB ] =
183 HYDROGUI_ImportImageDlg::ComputeTrsfData( aImgTrsfMode, aLocalPointB, aTrsfPointB );
184 aDataMap[ HYDROGUI_PrsImage::PointC ] =
185 HYDROGUI_ImportImageDlg::ComputeTrsfData( aImgTrsfMode, aLocalPointC, aTrsfPointC );
187 HYDROGUI_ImportImageDlg::PrsPointData aPrsPointData( anImageObj->GetName(), aDataMap );
188 aPrsPointDataList.append( aPrsPointData );
192 aPanel->setPrsPointDataList( aPrsPointDataList );
193 aPanel->setRefImageName( aRefImageName );
196 void HYDROGUI_ImportImageOp::abortOperation()
200 HYDROGUI_Operation::abortOperation();
203 void HYDROGUI_ImportImageOp::commitOperation()
207 HYDROGUI_Operation::commitOperation();
210 HYDROGUI_InputPanel* HYDROGUI_ImportImageOp::createInputPanel() const
212 HYDROGUI_InputPanel* aPanel = new HYDROGUI_ImportImageDlg( module(), getName() );
213 connect( aPanel, SIGNAL( createPreview( QImage ) ),
214 this, SLOT( onCreatePreview( QImage ) ) );
215 connect( aPanel, SIGNAL( activatePointSelection( int ) ),
216 this, SLOT( onActivatePointSelection( int ) ) );
217 connect( aPanel, SIGNAL( pointCoordChanged( bool, int, bool, int ) ),
218 this, SLOT( onPointCoordChanged( bool, int, bool, int ) ) );
219 connect( aPanel, SIGNAL( modeActivated( int ) ),
220 this, SLOT( onModeActivated( int ) ) );
221 connect( aPanel, SIGNAL( refImageActivated( const QString& ) ),
222 this, SLOT( onRefImageActivated( const QString& ) ) );
226 bool HYDROGUI_ImportImageOp::checkPoints( const QPointF& thePointA,
227 const QPointF& thePointB,
228 const QPointF& thePointC,
229 const bool theIsByTwoPoints,
230 const QString& theLineErrMsg,
231 const QString& thePoinErrMsg,
232 QString& theErrorMsg,
233 const bool theIsToCheckInvertibles ) const
235 double xa = thePointA.x();
236 double ya = thePointA.y();
237 double xb = thePointB.x();
238 double yb = thePointB.y();
239 double xc = thePointC.x();
240 double yc = thePointC.y();
242 if ( !theIsByTwoPoints )
244 // check that three input points don't belong to a single line
245 if ( ValuesEquals( ( yb - ya ) * ( xc - xa ), ( yc - ya ) * ( xb - xa ) ) )
247 theErrorMsg = theLineErrMsg;
253 // check that two points are not identical
254 if ( ValuesEquals( xa, ya ) && ValuesEquals( xb, yb ) )
256 theErrorMsg = thePoinErrMsg;
261 if ( theIsToCheckInvertibles )
263 QTransform aTransform1( xa, ya, 1, xb, yb, 1, xc, yc, 1 );
265 bool anIsInvertible = false;
266 QTransform aTransform1Inverted = aTransform1.inverted( &anIsInvertible );
267 if( !anIsInvertible )
269 theErrorMsg = tr( "TRANSFORMATION_MATRIX_CANNOT_BE_COMPUTED" );
277 bool HYDROGUI_ImportImageOp::processApply( int& theUpdateFlags,
278 QString& theErrorMsg )
280 HYDROGUI_ImportImageDlg* aPanel = (HYDROGUI_ImportImageDlg*)inputPanel();
282 QString anImageName = aPanel->getImageName();
283 if( anImageName.isEmpty() )
286 if( !myIsEdit || ( !myEditedObject.IsNull() && myEditedObject->GetName() != anImageName ) )
288 // check that there are no other objects with the same name in the document
289 Handle(HYDROData_Entity) anObject = HYDROGUI_Tool::FindObjectByName( module(), anImageName );
290 if( !anObject.IsNull() )
292 theErrorMsg = tr( "OBJECT_EXISTS_IN_DOCUMENT" ).arg( anImageName );
297 HYDROGUI_ImportImageDlg::TransformationDataMap aMap;
298 if( !aPanel->getTransformationDataMap( aMap ) )
301 bool anIsByTwoPoints = aPanel->isByTwoPoints();
303 QPoint aPointA = aMap[ HYDROGUI_PrsImage::PointA ].ImagePoint;
304 QPoint aPointB = aMap[ HYDROGUI_PrsImage::PointB ].ImagePoint;
305 QPoint aPointC = anIsByTwoPoints ? QPoint( INT_MIN, INT_MIN ) :
306 aMap[ HYDROGUI_PrsImage::PointC ].ImagePoint;
308 // first, we check correctness of image points
309 if ( !checkPoints( aPointA, aPointB, aPointC, anIsByTwoPoints,
310 tr( "POINTS_A_B_C_BELONG_TO_SINGLE_LINE" ),
311 tr( "POINTS_A_B_ARE_IDENTICAL" ),
312 theErrorMsg, true ) )
315 Handle(HYDROData_Image) aRefImageObj;
316 QPointF aTrsfPointA, aTrsfPointB, aTrsfPointC( INT_MIN, INT_MIN );
318 HYDROData_Image::TransformationMode aTransformationMode =
319 (HYDROData_Image::TransformationMode)aPanel->getTransformationMode();
320 if ( aTransformationMode == HYDROData_Image::ReferenceImage )
322 QString aRefImageName = aPanel->getRefImageName();
323 if( aRefImageName.isEmpty() )
325 theErrorMsg = tr( "REFERENCE_IMAGE_IS_NOT_SELECTED" );
329 HYDROGUI_ImportImageDlg::TransformationDataMap aRefMap;
330 if( !aPanel->getTransformationDataMap( aRefMap, true ) )
333 aRefImageObj = Handle(HYDROData_Image)::DownCast(
334 HYDROGUI_Tool::FindObjectByName( module(), aRefImageName, KIND_IMAGE ) );
335 if( aRefImageObj.IsNull() )
338 aTrsfPointA = aRefMap[ HYDROGUI_PrsImage::PointA ].ImagePoint;
339 aTrsfPointB = aRefMap[ HYDROGUI_PrsImage::PointB ].ImagePoint;
340 if ( !anIsByTwoPoints )
341 aTrsfPointC = aRefMap[ HYDROGUI_PrsImage::PointC ].ImagePoint;
343 // the same check of correctness for the reference points
344 if ( !checkPoints( aTrsfPointA, aTrsfPointB, aTrsfPointC, anIsByTwoPoints,
345 tr( "REFERENCE_POINTS_A_B_C_BELONG_TO_SINGLE_LINE" ),
346 tr( "REFERENCE_POINTS_A_B_ARE_IDENTICAL" ),
347 theErrorMsg, false ) )
352 if ( aTransformationMode == HYDROData_Image::ManualLambert )
354 aTrsfPointA = aMap[ HYDROGUI_PrsImage::PointA ].LambertPoint;
355 aTrsfPointB = aMap[ HYDROGUI_PrsImage::PointB ].LambertPoint;
356 if ( !anIsByTwoPoints )
357 aTrsfPointC = aMap[ HYDROGUI_PrsImage::PointC ].LambertPoint;
361 aTrsfPointA = aMap[ HYDROGUI_PrsImage::PointA ].CartesianPoint;
362 aTrsfPointB = aMap[ HYDROGUI_PrsImage::PointB ].CartesianPoint;
363 if ( !anIsByTwoPoints )
364 aTrsfPointC = aMap[ HYDROGUI_PrsImage::PointC ].CartesianPoint;
368 Handle(HYDROData_Image) anImageObj;
370 anImageObj = myEditedObject;
372 anImageObj = Handle(HYDROData_Image)::DownCast( doc()->CreateObject( KIND_IMAGE ) );
374 if( anImageObj.IsNull() )
377 anImageObj->SetName( anImageName );
378 anImageObj->SetImage( myImage );
379 anImageObj->SetLocalPoints( aPointA, aPointB, aPointC, false );
381 if ( aTransformationMode == HYDROData_Image::ReferenceImage )
383 anImageObj->SetReferencePoints( aRefImageObj,
384 aTrsfPointA, aTrsfPointB, aTrsfPointC );
388 anImageObj->SetGlobalPoints( aTransformationMode,
389 aTrsfPointA, aTrsfPointB, aTrsfPointC );
394 // Set imported file name for image
395 QString aFilePath = aPanel->getFileName();
396 anImageObj->SetFilePath( aFilePath );
399 // must be done after all checks and before calling SetVisible() method below
403 module()->setObjectVisible( HYDROGUI_Tool::GetActiveGraphicsViewId( module() ), anImageObj, true );
406 anImageObj->Update();
408 theUpdateFlags = UF_Model | UF_Viewer | UF_GV_Forced | UF_OCCViewer | UF_OCC_Forced;
412 void HYDROGUI_ImportImageOp::onCreatePreview( QImage theImage )
414 HYDROGUI_ImportImageDlg* aPanel = (HYDROGUI_ImportImageDlg*)inputPanel();
418 if( myPreviewPrs ) // if the image is changed by choosing another file
420 myPreviewPrs->setImage( myImage );
421 myPreviewPrs->compute();
423 if( myPreviewViewManager )
425 if( GraphicsView_Viewer* aViewer = myPreviewViewManager->getViewer() )
427 if( GraphicsView_ViewPort* aViewPort = aViewer->getActiveViewPort() )
429 aViewPort->onBoundingRectChanged();
437 LightApp_Application* anApp = module()->getApp();
439 myActiveViewManager = anApp->activeViewManager();
441 myPreviewPrs = new HYDROGUI_PrsImage( myIsEdit ? myEditedObject : 0 );
442 myPreviewPrs->setImage( myImage );
443 myPreviewPrs->compute();
445 myPreviewViewManager =
446 dynamic_cast<GraphicsView_ViewManager*>( anApp->createViewManager( GraphicsView_Viewer::Type() ) );
447 if( myPreviewViewManager )
449 connect( myPreviewViewManager, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
450 this, SLOT( onLastViewClosed( SUIT_ViewManager* ) ) );
452 module()->setViewManagerRole( myPreviewViewManager, HYDROGUI_Module::VMR_TransformImage );
453 myPreviewViewManager->setTitle( tr( "TRANSFORM_IMAGE" ) );
454 if( GraphicsView_Viewer* aViewer = myPreviewViewManager->getViewer() )
456 if( GraphicsView_ViewPort* aViewPort = aViewer->getActiveViewPort() )
458 //aViewPort->setMousePositionEnabled( true ); //ouv: temporarily commented
460 aViewPort->addItem( myPreviewPrs );
463 myPreviewPrs->setIsTransformationPointPreview( true );
465 connect( aViewer, SIGNAL( selectionChanged( GV_SelectionChangeStatus ) ),
466 this, SLOT( onPointSelected() ) );
473 if( !myEditedObject.IsNull() )
474 anImageName = myEditedObject->GetName();
477 anImageName = HYDROGUI_Tool::GenerateObjectName( module(), "Image" );
478 aPanel->setImageName( anImageName );
481 aPanel->setImageSize( myImage.size() );
483 aPanel->initializePointSelection();
484 onPointSelected( false );
487 void HYDROGUI_ImportImageOp::onActivatePointSelection( int thePointType )
489 myPointType = thePointType;
491 myPreviewPrs->setTransformationPointType( thePointType );
492 if( myRefPreviewPrs )
493 myRefPreviewPrs->setTransformationPointType( thePointType );
496 void HYDROGUI_ImportImageOp::onPointCoordChanged( bool theIsRef,
501 if( !theIsRef && myPreviewPrs )
502 myPreviewPrs->updateTransformationPoint( thePointType, theIsY, theValue );
503 else if( theIsRef && myRefPreviewPrs )
504 myRefPreviewPrs->updateTransformationPoint( thePointType, theIsY, theValue );
507 void HYDROGUI_ImportImageOp::onModeActivated( int theMode )
509 HYDROGUI_ImportImageDlg* aPanel = (HYDROGUI_ImportImageDlg*)inputPanel();
511 QString aRefImageName;
512 if( theMode == HYDROData_Image::ReferenceImage )
514 aRefImageName = aPanel->getRefImageName();
515 if( aRefImageName.isEmpty() )
516 return; // do nothing in this case to avoid visual moving of preview prs
517 onRefImageActivated( aRefImageName );
521 if( myRefViewManager )
523 closeView( myRefViewManager );
528 void HYDROGUI_ImportImageOp::onRefImageActivated( const QString& theName )
530 GraphicsView_ViewPort* aViewPort = 0;
532 LightApp_Application* anApp = module()->getApp();
533 ///// Get a view port for the reference image preview
534 if( myRefViewManager )
536 if( GraphicsView_Viewer* aViewer = myRefViewManager->getViewer() )
538 aViewPort = aViewer->getActiveViewPort();
543 anApp = module()->getApp();
544 // Init reference image preview
546 dynamic_cast<GraphicsView_ViewManager*>( anApp->createViewManager( GraphicsView_Viewer::Type() ) );
547 if( myRefViewManager )
549 connect( myRefViewManager, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
550 this, SLOT( onLastViewClosed( SUIT_ViewManager* ) ) );
552 module()->setViewManagerRole( myRefViewManager, HYDROGUI_Module::VMR_ReferenceImage );
553 myRefViewManager->setTitle( tr( "REFERENCE_IMAGE" ) );
554 if( GraphicsView_Viewer* aViewer = myRefViewManager->getViewer() )
556 aViewPort = aViewer->getActiveViewPort();
557 connect( aViewer, SIGNAL( selectionChanged( GV_SelectionChangeStatus ) ),
558 this, SLOT( onRefPointSelected() ) );
562 qApp->processEvents();
567 // Remove the old presentation of the reference image if any
568 if( myRefPreviewPrs )
570 myRefPreviewPrs->setCaption( QString() );
571 aViewPort->removeItem( myRefPreviewPrs );
573 delete myRefPreviewPrs;
577 // Create a new reference image presentation
579 Handle(HYDROData_Image) anImageObj = Handle(HYDROData_Image)::DownCast(
580 HYDROGUI_Tool::FindObjectByName( module(), theName, KIND_IMAGE ) );
581 if( !anImageObj.IsNull() )
583 anImage = anImageObj->Image();
585 myRefPreviewPrs = new HYDROGUI_PrsImage( anImageObj );
586 myRefPreviewPrs->setImage( anImage );
587 myRefPreviewPrs->compute();
589 myRefPreviewPrs->setIsTransformationPointPreview( true );
590 myRefPreviewPrs->setTransformationPointType( myPointType );
592 // Add the new reference image presentation to the appropriate view
593 aViewPort->addItem( myRefPreviewPrs );
598 // Split views horizontally
599 if( anApp->desktop()->inherits( "STD_TabDesktop" ) )
601 QtxWorkstack* aWorkstack = ( (STD_TabDesktop*)anApp->desktop() )->workstack();
602 aViewPort->activateWindow();
604 aViewPort->setFocus(Qt::ActiveWindowFocusReason);
605 aWorkstack->splitHorizontal();
608 // Initialize the dialog
609 HYDROGUI_ImportImageDlg* aPanel = (HYDROGUI_ImportImageDlg*)inputPanel();
610 aPanel->setImageSize( anImage.size(), true );
611 aPanel->initializePointSelection();
612 onPointSelected( true );
615 void HYDROGUI_ImportImageOp::onLastViewClosed( SUIT_ViewManager* theViewManager )
620 void HYDROGUI_ImportImageOp::onPointSelected()
622 onPointSelected( myRefPreviewPrs && myRefPreviewPrs->isSelected() );
625 void HYDROGUI_ImportImageOp::onRefPointSelected()
627 onPointSelected( true );
630 void HYDROGUI_ImportImageOp::onPointSelected( bool theIsRefImage )
632 HYDROGUI_PrsImage* aPrs = theIsRefImage ? myRefPreviewPrs : myPreviewPrs;
636 HYDROGUI_ImportImageDlg::TransformationDataMap aDataMap;
638 const HYDROGUI_PrsImage::TransformationPointMap& aPointMap =
639 aPrs->getTransformationPointMap();
640 HYDROGUI_PrsImage::TransformationPointMapIterator anIter( aPointMap );
641 while( anIter.hasNext() )
643 int aPointType = anIter.next().key();
644 const HYDROGUI_PrsImage::TransformationPoint& aTransformationPoint = anIter.value();
645 const QPoint& aPoint = aTransformationPoint.Point;
647 HYDROGUI_ImportImageDlg::TransformationData aData( aPoint, QPointF(), QPointF() );
648 aDataMap[ aPointType ] = aData;
651 ( (HYDROGUI_ImportImageDlg*)inputPanel() )->setTransformationDataMap( aDataMap, true, theIsRefImage );
654 void HYDROGUI_ImportImageOp::closePreview()
656 closeView( myPreviewViewManager );
657 closeView( myRefViewManager );
659 if( myActiveViewManager )
660 HYDROGUI_Tool::SetActiveViewManager( module(), myActiveViewManager );
663 void HYDROGUI_ImportImageOp::closeView( GraphicsView_ViewManager* &aViewMgr )
667 GraphicsView_ViewPort* aViewPort = 0;
668 if( GraphicsView_Viewer* aViewer = aViewMgr->getViewer() )
670 aViewPort = aViewer->getActiveViewPort();
672 disconnect( aViewMgr, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
673 this, SLOT( onLastViewClosed( SUIT_ViewManager* ) ) );
675 // Nullify appropriate presentation pointer
676 HYDROGUI_PrsImage* aPrs = 0;
677 switch ( module()->getViewManagerRole( aViewMgr ) )
679 case HYDROGUI_Module::VMR_ReferenceImage:
680 aPrs = myRefPreviewPrs;
683 case HYDROGUI_Module::VMR_TransformImage:
688 // Remove the appropriate presentation from the view
689 if( aPrs && aViewPort )
691 aViewPort->removeItem( aPrs );
696 module()->getApp()->removeViewManager( aViewMgr ); // aViewMgr is deleted here