Salome HOME
Support both 5.5 and 5.6 version of ParaView
[modules/gui.git] / src / SUIT / SUIT_ViewWindow.cxx
index e8beaf491e60d99c20f30c17fbfecf8ec8f0d79d..d5d9032faeed6fff80f6bbf0b1d9f253a446034e 100755 (executable)
@@ -32,6 +32,7 @@
 #include "SUIT_Application.h"
 #include "SUIT_ViewManager.h"
 #include "SUIT_ResourceMgr.h"
+#include "SUIT_FileDlg.h"
 #include "QtxActionToolMgr.h"
 #include "QtxMultiAction.h"
 
@@ -93,11 +94,6 @@ QImage SUIT_ViewWindow::dumpView()
   return QImage();
 }
 
-bool SUIT_ViewWindow::dumpViewToPSFormat(const QString& fileName)
-{
-  return false;
-}
-
 /*!
   Saves image to file according to the format
   \param image - image
@@ -176,16 +172,9 @@ void SUIT_ViewWindow::onDumpView()
 /*!
   \return filters for image files
 */
-QString SUIT_ViewWindow::filter(bool includePS) const
+QString SUIT_ViewWindow::filter() const
 {
-  QString aFilter = tr( "TLT_IMAGE_FILES" );
-  if (!includePS)
-    return aFilter;
-  else
-  {
-    aFilter+=";;"+tr( "POSTSCRIPT_FILES" );
-    return aFilter;
-  }
+  return tr( "TLT_IMAGE_FILES" );
 }
 
 /*! Reaction view window on event \a e.
@@ -195,27 +184,27 @@ bool SUIT_ViewWindow::event( QEvent* e )
   if ( e->type() == DUMP_EVENT )
   {
     bool bOk = false;
-    if ( myManager && myManager->study() && myManager->study()->application() )
+    SUIT_Application* app = NULL;
+    if (myManager && myManager->study() && myManager->study()->application())
+      app = myManager->study()->application();
+    QString fileName;
+    if (app)
+      fileName = app->getFileName( false, QString(), filter(), tr( "TLT_DUMP_VIEW" ), 0 ); //old way
+    else
     {
-      // get file name
-      SUIT_Application* app = myManager->study()->application();
-      bool IncludePs = true; //TODO for oscar only
-      QString fileName = app->getFileName( false, QString(), filter(IncludePs), tr( "TLT_DUMP_VIEW" ), 0 );
-      if ( !fileName.isEmpty() )
-      {
-        QString fmt = SUIT_Tools::extension( fileName ).toUpper();
-        if (fmt == "PS" || fmt == "EPS" )
-          bOk = dumpViewToPSFormat(fileName);
-        else
-        {
-          QImage im = dumpView();      
-          Qtx::Localizer loc;
-          bOk = dumpViewToFormat( im, fileName, fmt );
-        }
-      }
-      else
-       bOk = true; // cancelled
+      QStringList fls = filter().split( ";;", QString::SkipEmptyParts );
+      fileName = SUIT_FileDlg::getFileName( NULL, QString(), fls, tr( "TLT_DUMP_VIEW" ), false, true );
+    }
+    if ( !fileName.isEmpty() )
+    {
+      QString fmt = SUIT_Tools::extension( fileName ).toUpper();
+      QImage im = dumpView();  
+      Qtx::Localizer loc;
+      bOk = dumpViewToFormat( im, fileName, fmt );
     }
+    else
+      bOk = true; // cancelled
+
     if ( !bOk )
       SUIT_MessageBox::critical( this, tr( "ERROR" ), tr( "ERR_CANT_DUMP_VIEW" ) );
 
@@ -560,3 +549,15 @@ void SUIT_ViewWindow::synchronizeView( SUIT_ViewWindow* viewWindow, int id )
     }
   }
 }
+
+void SUIT_ViewWindow::setVisible( bool on )
+{
+  // This is a workaround to avoid showing view window as a top-level window
+  // before re-parenting it to workstack (issue #23467).
+  // See SUIT_Desktop::childEvent().
+  QApplication::sendPostedEvents( 0, QEvent::ChildRemoved );
+  QApplication::sendPostedEvents( 0, QEvent::ChildAdded );
+  QApplication::sendPostedEvents( 0, QEvent::ChildPolished );
+  if ( !property( "blockShow" ).toBool() )
+    QMainWindow::setVisible( on );
+}