]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
dump view to PS format (draft)
authorisn <isn@opencascade.com>
Tue, 14 Nov 2017 17:05:27 +0000 (20:05 +0300)
committerisn <isn@opencascade.com>
Tue, 14 Nov 2017 17:05:27 +0000 (20:05 +0300)
src/GraphicsView/GraphicsView_ViewFrame.cxx
src/GraphicsView/GraphicsView_ViewFrame.h
src/GraphicsView/GraphicsView_ViewPort.cxx
src/GraphicsView/GraphicsView_ViewPort.h
src/SUIT/SUIT_ViewWindow.cxx
src/SUIT/SUIT_ViewWindow.h
src/SUIT/resources/SUIT_msg_en.ts

index ea7a4a912292c5357f495eb86de338c3db3cb36d..c5f1dfaad6c4fd7266c6e58b818a1a270bd78eb0 100644 (file)
@@ -211,6 +211,15 @@ QImage GraphicsView_ViewFrame::dumpView()
   return myViewPort->dumpView();
 }
 
+//================================================================
+// Function : dumpViewToPSFormat
+// Purpose  : 
+//================================================================
+bool GraphicsView_ViewFrame::dumpViewToPSFormat(const QString& fileName)
+{
+  return myViewPort->dumpViewToPSFormat(fileName);
+}
+
 //================================================================
 // Function : getVisualParameters
 // Purpose  : 
index 537c81052e7a16946371cfb61871647964a90b41..ce7d386d0417cb3ea538c8632f03d4f1808c0cd2 100644 (file)
@@ -55,6 +55,7 @@ public:
   GraphicsView_ViewPort*  getViewPort() const  { return myViewPort; }
 
   virtual QImage          dumpView();
+  virtual bool            dumpViewToPSFormat(const QString& fileName);
 
   virtual QString         getVisualParameters();
   virtual void            setVisualParameters( const QString& theParameters );
index dac64f7ceedc12f3b3b784277a701824bb833471..de9a19d9e1fe38aee63adf619d0164b83af3b6ca 100644 (file)
@@ -34,6 +34,8 @@
 #include <QRectF>
 #include <QRubberBand>
 #include <QScrollBar>
+#include <QPrinter>
+#include <QPainter>
 
 #include <math.h>
 
@@ -457,6 +459,18 @@ QImage GraphicsView_ViewPort::dumpView( bool theWholeScene,
   return anImage;
 }
 
+bool GraphicsView_ViewPort::dumpViewToPSFormat(const QString& fileName)
+{
+  QPrinter printer(QPrinter::HighResolution);
+  printer.setOutputFileName(fileName);
+  QPainter painter;  
+  if (!painter.begin(&printer))
+    return false;
+  myScene->render(&painter);
+  if (!painter.end())
+    return false;;
+}
+
 //================================================================
 // Function : setSceneGap
 // Purpose  : 
index 4b5acfc2eaf637505d4c54aefd2b98bd53dedb31..f6b440bc09d4a2f9e73e0c3bf348a6f89e32e6cd 100644 (file)
@@ -93,6 +93,8 @@ public:
   QImage                           dumpView( bool theWholeScene = false,
                                              QSizeF theSize = QSizeF() );
 
+  bool                             dumpViewToPSFormat(const QString& fileName);
+
 public:
   // scene
   void                             setSceneGap( double theSceneGap );
index 6bc8af07c566165449526f79e05e2c665be1fcb1..e8beaf491e60d99c20f30c17fbfecf8ec8f0d79d 100755 (executable)
@@ -93,6 +93,11 @@ 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
@@ -171,9 +176,16 @@ void SUIT_ViewWindow::onDumpView()
 /*!
   \return filters for image files
 */
-QString SUIT_ViewWindow::filter() const
+QString SUIT_ViewWindow::filter(bool includePS) const
 {
-  return tr( "TLT_IMAGE_FILES" );
+  QString aFilter = tr( "TLT_IMAGE_FILES" );
+  if (!includePS)
+    return aFilter;
+  else
+  {
+    aFilter+=";;"+tr( "POSTSCRIPT_FILES" );
+    return aFilter;
+  }
 }
 
 /*! Reaction view window on event \a e.
@@ -187,13 +199,19 @@ bool SUIT_ViewWindow::event( QEvent* e )
     {
       // get file name
       SUIT_Application* app = myManager->study()->application();
-      QString fileName = app->getFileName( false, QString(), filter(), tr( "TLT_DUMP_VIEW" ), 0 );
+      bool IncludePs = true; //TODO for oscar only
+      QString fileName = app->getFileName( false, QString(), filter(IncludePs), tr( "TLT_DUMP_VIEW" ), 0 );
       if ( !fileName.isEmpty() )
       {
-        QImage im = dumpView();
-       QString fmt = SUIT_Tools::extension( fileName ).toUpper();
-       Qtx::Localizer loc;
-       bOk = dumpViewToFormat( im, fileName, fmt );
+        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
index fd717f617adeb8e96a33fac802e7b8c7391028f6..3e49587ab75c2f161a3a1069328dbaae9df79ac8 100755 (executable)
@@ -53,6 +53,7 @@ public:
   bool              event(QEvent*);
 
   virtual QImage    dumpView();
+  virtual bool      dumpViewToPSFormat(const QString& fileName);
   bool              dumpViewToFormat( const QString& fileName, const QString& format );
 
   bool              onAccelAction( int );
@@ -93,7 +94,7 @@ signals:
 protected:
   void              closeEvent( QCloseEvent* );
   virtual void      contextMenuEvent( QContextMenuEvent* );
-  virtual QString   filter() const;
+  virtual QString   filter(bool includePS = false) const;
   virtual bool      action( const int );
   virtual bool      dumpViewToFormat( const QImage&, const QString& fileName, const QString& format );
 
index 31bbc382a8d46ff7f789c34ebf8e6cf918ff57f0..6f7991d9848524cff1bd0bf38db43caf93d045b0 100644 (file)
         <source>TLT_IMAGE_FILES</source>
         <translation>Images Files (*.bmp *.png *.jpg *.jpeg)</translation>
     </message>
+    <message>
+        <source>POSTSCRIPT_FILES</source>
+        <translation>PostScript files (*.ps *.eps)</translation>
+    </message>
     <message>
         <source>MEN_DESK_WINDOW_CASCADE</source>
         <translation>&amp;Cascade</translation>