Salome HOME
studyActivated() virtual method has been added
[modules/gui.git] / src / GLViewer / GLViewer_ViewFrame.cxx
index 5e9e173802a3e5b42b5b93217987b639a629e77b..5053889bd09b39be1c4191a7485e1f81e2a3ea76 100644 (file)
 #include "GLViewer_ViewPort2d.h"
 
 #include <SUIT_Desktop.h>
+#include <SUIT_Application.h>
 #include <SUIT_Session.h>
 #include <SUIT_ToolButton.h>
 #include <SUIT_ResourceMgr.h>
+#include <SUIT_Tools.h>
 #include <QtxAction.h>
 #include <SUIT_MessageBox.h>
 
 #include <qcolor.h>
-#include <qfiledialog.h>
 #include <qimage.h>
 #include <qlayout.h>
 #include <qstring.h>
@@ -80,7 +81,7 @@ void GLViewer_ViewFrame::createActions()
   aAction = new QtxAction(tr("MNU_DUMP_VIEW"), aResMgr->loadPixmap( "GLViewer", tr( "ICON_GL_DUMP" ) ),
                            tr( "MNU_DUMP_VIEW" ), 0, this);
   aAction->setStatusTip(tr("DSC_DUMP_VIEW"));
-  connect(aAction, SIGNAL(activated()), this, SLOT(onViewDump()));
+  connect(aAction, SIGNAL(activated()), this, SLOT(onDumpView()));
   myActionsMap[ DumpId ] = aAction;
 
   // FitAll
@@ -245,7 +246,7 @@ void GLViewer_ViewFrame::onUpdate( int )
 {
 }
 
-void GLViewer_ViewFrame::onViewDump()
+QImage GLViewer_ViewFrame::dumpView()
 {
     GLViewer_Widget* aWidget = ((GLViewer_ViewPort2d*)myVP)->getGLWidget();
     int width, height;
@@ -382,48 +383,7 @@ void GLViewer_ViewFrame::onViewDump()
     }
 
     delete [] imageBits;
-
-    QString aFilter( "*.bmp\n*.png" );
-
-    QFileDialog aFileDlg( QDir::current().absPath(), aFilter, this );
-    aFileDlg.setCaption( tr( "DUMP_VIEW_SAVE_FILE_DLG_CAPTION" ) );
-    aFileDlg.setMode( QFileDialog::AnyFile );
-
-    if( !aFileDlg.exec() )
-        return;
-
-    QString aFileName = aFileDlg.selectedFile();
-    QString aFileExt = aFileDlg.selectedFilter();
-
-    if( aFileName.isEmpty() )
-    {
-        SUIT_MessageBox::error1( this,
-                                tr( "DUMP_VIEW_ERROR_DLG_CAPTION" ),
-                                tr( "DUMP_VIEW_ERROR_DLG_TEXT" ),
-                                tr( "BUT_OK" ) );
-    }
-
-    QString aSaveOp = "BMP";
-    QString aTypedFileExt = QFileInfo( aFileName ).extension( false ).lower();
-
-    if( aFileExt == "*.bmp" )
-    {
-        if( aTypedFileExt.isEmpty() )
-            aFileName += ".bmp";
-        aSaveOp = "BMP";
-    }
-    else if( aFileExt == "*.png" )
-        if( aTypedFileExt.isEmpty() )
-            aFileName += ".png";
-        aSaveOp = "PNG";
-
-    if( !anImage.save( aFileName, aSaveOp ) )
-    {
-        SUIT_MessageBox::error1( this,
-                                tr( "DUMP_VIEW_ERROR_DLG_CAPTION" ),
-                                tr( "DUMP_VIEW_ERROR_DLG_TEXT" ),
-                                tr( "BUT_OK" ) );
-    }
+    return anImage;
 }
 
 void GLViewer_ViewFrame::onViewPan()
@@ -525,3 +485,4 @@ void GLViewer_ViewFrame::wheelEvent( QWheelEvent* e )
     break;
   }
 }
+