]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
draft implementation of the fuse operation
authorasl <asl@opencascade.com>
Tue, 2 Jul 2013 08:11:40 +0000 (08:11 +0000)
committerasl <asl@opencascade.com>
Tue, 2 Jul 2013 08:11:40 +0000 (08:11 +0000)
src/GraphicsView/GraphicsView_PrsImage.cxx
src/GraphicsView/GraphicsView_Viewer.cxx

index 86c3a317143e8aa9ad7b54ecbb18850a59142705..8a61d0959151cdb593dfdeb8604fbe9e8f510fc3 100644 (file)
@@ -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;
 }
 
index df19f1b75ea8a51f8e3a2faaee2cf1748a87f261..d627e919c2a47800a1baa1351b817a7a62556b77 100644 (file)
@@ -31,6 +31,8 @@
 
 #include <SUIT_ViewManager.h>
 
+#include <ImageComposer_Image.h>
+
 #include <QApplication>
 #include <QColorDialog>
 #include <QGraphicsSceneMouseEvent>
@@ -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<GraphicsView_PrsImage*>( anObject ) )
-        {
-          QImage anImage = aPrs->getImage();
-          QTransform aTransform = aPrs->getTransform();
-          // ...
-        }
-      }
-    }
+    int aCount = aList.count();
+    GraphicsView_PrsImage* anObj1 = dynamic_cast<GraphicsView_PrsImage*>( aList[0] );
+    GraphicsView_PrsImage* anObj2 = dynamic_cast<GraphicsView_PrsImage*>( 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 );
   }
 }