+ aPanel->setIsEdit( myIsEdit );
+
+ QString aRefImageName;
+
+ if( myIsEdit )
+ {
+ myEditedObject = Handle(HYDROData_Image)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) );
+ if( !myEditedObject.IsNull() )
+ {
+ QImage anImage = myEditedObject->Image();
+ bool anIsByTwoPoints = myEditedObject->IsByTwoPoints();
+
+ QPoint aLocalPointA, aLocalPointB, aLocalPointC;
+ myEditedObject->GetLocalPoints( aLocalPointA, aLocalPointB, aLocalPointC );
+
+ onCreatePreview( anImage );
+
+ if( myPreviewPrs )
+ {
+ HYDROGUI_PrsImage::TransformationPointMap aPointMap =
+ myPreviewPrs->getTransformationPointMap();
+ if( !aPointMap.isEmpty() )
+ {
+ aPointMap[ HYDROGUI_PrsImage::PointA ].Point = aLocalPointA;
+ aPointMap[ HYDROGUI_PrsImage::PointB ].Point = aLocalPointB;
+ if ( !anIsByTwoPoints )
+ aPointMap[ HYDROGUI_PrsImage::PointC ].Point = aLocalPointC;
+
+ myPreviewPrs->setTransformationPointMap( aPointMap );
+ }
+ }
+
+ HYDROData_Image::TransformationMode aTrsfMode;
+ QPointF aTrsfPointA, aTrsfPointB, aTrsfPointC;
+ myEditedObject->GetGlobalPoints( aTrsfMode,
+ aTrsfPointA, aTrsfPointB, aTrsfPointC );
+
+ HYDROGUI_ImportImageDlg::TransformationDataMap aDataMap;
+ aDataMap[ HYDROGUI_PrsImage::PointA ] =
+ HYDROGUI_ImportImageDlg::ComputeTrsfData( aTrsfMode, aLocalPointA, aTrsfPointA );
+ aDataMap[ HYDROGUI_PrsImage::PointB ] =
+ HYDROGUI_ImportImageDlg::ComputeTrsfData( aTrsfMode, aLocalPointB, aTrsfPointB );
+ if ( !anIsByTwoPoints )
+ aDataMap[ HYDROGUI_PrsImage::PointC ] =
+ HYDROGUI_ImportImageDlg::ComputeTrsfData( aTrsfMode, aLocalPointC, aTrsfPointC );
+
+ aPanel->setTransformationMode( aTrsfMode );
+ aPanel->setTransformationDataMap( aDataMap );
+ aPanel->setByTwoPoints( anIsByTwoPoints );
+
+ // Set points on reference image
+ if ( aTrsfMode = HYDROData_Image::ReferenceImage )
+ {
+ Handle(HYDROData_Image) aRefImage = myEditedObject->GetTrsfReferenceImage();
+ if ( !aRefImage.IsNull() )
+ {
+ aRefImageName = aRefImage->GetName();
+
+ onRefImageActivated( aRefImageName );
+ if( myRefPreviewPrs )
+ {
+ HYDROGUI_PrsImage::TransformationPointMap aRefPointMap =
+ myRefPreviewPrs->getTransformationPointMap();
+ if( !aRefPointMap.isEmpty() )
+ {
+ aRefPointMap[ HYDROGUI_PrsImage::PointA ].Point = aTrsfPointA.toPoint();
+ aRefPointMap[ HYDROGUI_PrsImage::PointB ].Point = aTrsfPointB.toPoint();
+ if ( !anIsByTwoPoints )
+ aRefPointMap[ HYDROGUI_PrsImage::PointC ].Point = aTrsfPointC.toPoint();
+
+ myRefPreviewPrs->setTransformationPointMap( aRefPointMap );
+ }
+ }
+
+ HYDROGUI_ImportImageDlg::TransformationDataMap aRefDataMap;
+ aRefDataMap[ HYDROGUI_PrsImage::PointA ] = HYDROGUI_ImportImageDlg::TransformationData( aTrsfPointA.toPoint() );
+ aRefDataMap[ HYDROGUI_PrsImage::PointB ] = HYDROGUI_ImportImageDlg::TransformationData( aTrsfPointB.toPoint() );
+ if ( !anIsByTwoPoints )
+ aRefDataMap[ HYDROGUI_PrsImage::PointC ] = HYDROGUI_ImportImageDlg::TransformationData( aTrsfPointC.toPoint() );
+
+ aPanel->setTransformationDataMap( aRefDataMap, true, true );
+ }
+ }
+ }
+ }
+
+ // collect information about existing images
+ HYDROGUI_ImportImageDlg::PrsPointDataList aPrsPointDataList;
+ HYDROData_Iterator anIterator( doc(), KIND_IMAGE );
+ for( ; anIterator.More(); anIterator.Next() )
+ {
+ Handle(HYDROData_Image) anImageObj = Handle(HYDROData_Image)::DownCast( anIterator.Current() );
+ if( !anImageObj.IsNull() )
+ {
+ if( myIsEdit && IsEqual( anImageObj, myEditedObject ) )
+ continue;
+
+ QPoint aLocalPointA, aLocalPointB, aLocalPointC;
+ anImageObj->GetLocalPoints( aLocalPointA, aLocalPointB, aLocalPointC );
+
+ HYDROData_Image::TransformationMode aImgTrsfMode;
+ QPointF aTrsfPointA, aTrsfPointB, aTrsfPointC;
+ anImageObj->GetGlobalPoints( aImgTrsfMode,
+ aTrsfPointA, aTrsfPointB, aTrsfPointC );
+
+ HYDROGUI_ImportImageDlg::TransformationDataMap aDataMap;
+ aDataMap[ HYDROGUI_PrsImage::PointA ] =
+ HYDROGUI_ImportImageDlg::ComputeTrsfData( aImgTrsfMode, aLocalPointA, aTrsfPointA );
+ aDataMap[ HYDROGUI_PrsImage::PointB ] =
+ HYDROGUI_ImportImageDlg::ComputeTrsfData( aImgTrsfMode, aLocalPointB, aTrsfPointB );
+ aDataMap[ HYDROGUI_PrsImage::PointC ] =
+ HYDROGUI_ImportImageDlg::ComputeTrsfData( aImgTrsfMode, aLocalPointC, aTrsfPointC );
+
+ HYDROGUI_ImportImageDlg::PrsPointData aPrsPointData( anImageObj->GetName(), aDataMap );
+ aPrsPointDataList.append( aPrsPointData );
+ }
+ }
+
+ aPanel->setPrsPointDataList( aPrsPointDataList );
+ aPanel->setRefImageName( aRefImageName );
+}
+
+void HYDROGUI_ImportImageOp::abortOperation()
+{
+ closePreview();
+
+ HYDROGUI_Operation::abortOperation();
+}
+
+void HYDROGUI_ImportImageOp::commitOperation()
+{
+ closePreview();
+
+ HYDROGUI_Operation::commitOperation();