]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
Fix problem with dump view contents (with overlapping windows) for OCC viewer
authordmv <dmv@opencascade.com>
Tue, 17 Nov 2009 13:17:02 +0000 (13:17 +0000)
committerdmv <dmv@opencascade.com>
Tue, 17 Nov 2009 13:17:02 +0000 (13:17 +0000)
src/OCCViewer/OCCViewer_ViewWindow.cxx

index 82c6c30118d5c0d264886682dfe5ad088baa9e9f..ea102e914998b28dce6bdb002b38d65d1eff1e5d 100755 (executable)
@@ -75,6 +75,8 @@ static QEvent* l_mbPressEvent = 0;
 # include <QWindowsStyle>
 #endif
 
+#include <GL/gl.h>
+
 const char* imageZoomCursor[] = {
 "32 32 3 1",
 ". c None",
@@ -1427,8 +1429,25 @@ void OCCViewer_ViewWindow::onTrihedronShow()
 */
 QImage OCCViewer_ViewWindow::dumpView()
 {
-  QPixmap px = QPixmap::grabWindow( myViewPort->winId() );
-  return px.toImage();
+  Handle(V3d_View) view = myViewPort->getView();
+  if ( view.IsNull() )
+    return QImage();
+  QApplication::syncX();
+  view->Update();
+  view->Redraw();
+
+  unsigned char* data = new unsigned char[ (myViewPort->width()*myViewPort->height())*4 ];
+
+  QPoint p = myViewPort->mapFromParent(myViewPort->geometry().topLeft());
+
+  glReadPixels( p.x(), p.y(), myViewPort->width(), myViewPort->height(), GL_RGBA, GL_UNSIGNED_BYTE,
+                data);
+
+  QImage anImage( data, myViewPort->width(), myViewPort->height(), QImage::Format_ARGB32 );
+  anImage = anImage.mirrored();
+  anImage = anImage.rgbSwapped();
+  return anImage;
+
 }
 
 bool OCCViewer_ViewWindow::dumpViewToFormat( const QImage& img,