From: asl Date: Tue, 2 Jul 2013 08:11:40 +0000 (+0000) Subject: draft implementation of the fuse operation X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=edc1484a3eb1a9065a87e402eb4f126dd03736c6;p=modules%2Fgui.git draft implementation of the fuse operation --- diff --git a/src/GraphicsView/GraphicsView_PrsImage.cxx b/src/GraphicsView/GraphicsView_PrsImage.cxx index 86c3a3171..8a61d0959 100644 --- a/src/GraphicsView/GraphicsView_PrsImage.cxx +++ b/src/GraphicsView/GraphicsView_PrsImage.cxx @@ -116,10 +116,14 @@ QTransform GraphicsView_PrsImage::getTransform() const getScaling( aScaleX, aScaleY ); getRotationAngle( aRotationAngle ); + QPointF aCenter = myPixmapItem->pixmap().rect().center(); + QTransform aTransform; - aTransform.translate( aPosX, aPosY ); - aTransform.scale( aScaleX, aScaleY ); + aTransform.translate( aCenter.x(), aCenter.y() ); aTransform.rotate( aRotationAngle ); + aTransform.scale( aScaleX, aScaleY ); + aTransform.translate( -aCenter.x() * aScaleX, -aCenter.y() * aScaleY ); + aTransform.translate( aPosX, aPosY ); return aTransform; } diff --git a/src/GraphicsView/GraphicsView_Viewer.cxx b/src/GraphicsView/GraphicsView_Viewer.cxx index df19f1b75..d627e919c 100644 --- a/src/GraphicsView/GraphicsView_Viewer.cxx +++ b/src/GraphicsView/GraphicsView_Viewer.cxx @@ -31,6 +31,8 @@ #include +#include + #include #include #include @@ -544,6 +546,26 @@ void GraphicsView_Viewer::onSelectionCancel() //================================================================ void GraphicsView_Viewer::onAddImage() { + /*GraphicsView_ViewFrame* aViewFrame = getActiveView(); + GraphicsView_ViewPort* aViewPort = getActiveViewPort(); + + GraphicsView_PrsImage* aPrs1 = new GraphicsView_PrsImage(); + QImage anImage1( "D:\\asl\\hydro\\dev\\HYDRO_SRC\\examples\\example1.png" ); + aPrs1->setImage( anImage1 ); + aPrs1->compute(); + aViewPort->addItem( aPrs1 ); + + GraphicsView_PrsImage* aPrs2 = new GraphicsView_PrsImage(); + QImage anImage2( "D:\\asl\\hydro\\dev\\HYDRO_SRC\\examples\\example2.png" ); + aPrs2->setImage( anImage2 ); + aPrs2->setRotationAngle( 30 ); + aPrs2->setPosition( 200, 50 ); + aPrs2->compute(); + aViewPort->addItem( aPrs2 ); + + aViewPort->fitAll(); + return;*/ + if( GraphicsView_ViewPort* aViewPort = getActiveViewPort() ) { QString aFileName = QFileDialog::getOpenFileName(); @@ -758,18 +780,26 @@ void GraphicsView_Viewer::onTestImageComposition() if( GraphicsView_ViewPort* aViewPort = getActiveViewPort() ) { GraphicsView_ObjectList aList = aViewPort->getObjects(); - GraphicsView_ObjectListIterator anIter( aList ); - while( anIter.hasNext() ) - { - if( GraphicsView_Object* anObject = anIter.next() ) - { - if( GraphicsView_PrsImage* aPrs = dynamic_cast( anObject ) ) - { - QImage anImage = aPrs->getImage(); - QTransform aTransform = aPrs->getTransform(); - // ... - } - } - } + int aCount = aList.count(); + GraphicsView_PrsImage* anObj1 = dynamic_cast( aList[0] ); + GraphicsView_PrsImage* anObj2 = dynamic_cast( aList[2] ); + + ImageComposer_Image anImage1; + anImage1 = anObj1->getImage(); + anImage1.setTransform( anObj1->getTransform() ); + + ImageComposer_Image anImage2; + anImage2 = anObj2->getImage(); + anImage2.setTransform( anObj2->getTransform() ); + + ImageComposer_Image aResult = anImage1 | anImage2; + GraphicsView_PrsImage* aResPrs = new GraphicsView_PrsImage(); + aResPrs->setImage( aResult ); + aResPrs->setTransform( aResult.transform() ); + aResPrs->compute(); + + aViewPort->addItem( aResPrs ); + aViewPort->removeItem( anObj1 ); + aViewPort->removeItem( anObj2 ); } }