]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
Implementation of the "23166: EDF 11517 SMESH: Dump view into ps fails" improvement.
authorrnv <rnv@opencascade.com>
Tue, 2 Aug 2016 08:17:49 +0000 (11:17 +0300)
committerrnv <rnv@opencascade.com>
Tue, 2 Aug 2016 08:17:49 +0000 (11:17 +0300)
src/SVTK/CMakeLists.txt
src/SVTK/SVTK_PsOptionsDlg.cxx [new file with mode: 0644]
src/SVTK/SVTK_PsOptionsDlg.h [new file with mode: 0644]
src/SVTK/SVTK_ViewWindow.cxx
src/SVTK/resources/SVTK_msg_en.ts

index 53dcf7e84da194a739c4b45f04dd7a46ba2618d3..493e5651ced4e8d99dc0affcb0cb8057a3da3edb 100755 (executable)
@@ -58,6 +58,7 @@ SET(_moc_HEADERS
    SVTK_FontWidget.h
    SVTK_GenericRenderWindowInteractor.h
    SVTK_RecorderDlg.h
+   SVTK_PsOptionsDlg.h 
    SVTK_RenderWindowInteractor.h
    SVTK_SetRotationPointDlg.h
    SVTK_View.h
@@ -169,6 +170,7 @@ SET(_other_SOURCES
   SVTK_Prs.cxx
   SVTK_Recorder.cxx
   SVTK_RecorderDlg.cxx
+  SVTK_PsOptionsDlg.cxx
   SVTK_RenderWindowInteractor.cxx
   SVTK_Renderer.cxx
   SVTK_Selector.cxx
diff --git a/src/SVTK/SVTK_PsOptionsDlg.cxx b/src/SVTK/SVTK_PsOptionsDlg.cxx
new file mode 100644 (file)
index 0000000..33ab91f
--- /dev/null
@@ -0,0 +1,145 @@
+// Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "SVTK_PsOptionsDlg.h"
+
+#include <QtxDoubleSpinBox.h>
+
+#include <QCheckBox>
+#include <QComboBox>
+#include <QGroupBox>
+#include <QLabel>
+#include <QLayout>
+#include <QSlider>
+#include <QPushButton>
+
+/*!
+ * Constructor
+ */
+SVTK_PsOptionsDlg::SVTK_PsOptionsDlg( QWidget* theParent):
+  QDialog( theParent )
+{
+  setWindowTitle( tr( "DLG_PSOPTIONS_TITLE" ) );
+  QVBoxLayout* aTopLayout = new QVBoxLayout( this );
+  aTopLayout->setSpacing( 6 );
+  aTopLayout->setMargin( 6 );
+  
+  // 1. Options
+  QGroupBox* anOptionsBox = new QGroupBox( tr( "PS_OPTIONS" ), this );
+  QGridLayout* anOptionsLayout = new QGridLayout( anOptionsBox );
+  anOptionsLayout->setSpacing( 6 );
+  anOptionsLayout->setMargin( 11 );
+
+  // 1.1 Line width factor
+  QLabel* lineLabel = new QLabel( tr( "PS_LINE_WIDTH" ), anOptionsBox);
+  myLineFactor = new QtxDoubleSpinBox(0.0, 10.0, 0.1, anOptionsBox);
+  myLineFactor->setValue(0.714);
+  
+  // 1.2 Point size factor
+  QLabel* pointLabel = new QLabel( tr( "PS_POINT_SIZE" ), anOptionsBox);
+  myPointFactor = new QtxDoubleSpinBox(0.0, 10.0, 0.1, anOptionsBox);
+  myPointFactor->setValue(0.714);
+
+  // 1.3 Sort method ("No sorting (fastest, poor)", "Simple sorting (fast, good)" and "BSP sorting (slow, best)"
+  QLabel* sortLabel = new QLabel( tr( "PS_SORT_METHOD" ), anOptionsBox);
+  mySortType = new QComboBox( anOptionsBox );
+  mySortType->addItem( tr( "PS_NO_SORTING" ) );
+  mySortType->addItem( tr( "PS_SIMPLE_SORTING" ) );
+  mySortType->addItem( tr( "PS_BPS_SORTING" ) );
+  
+  // 1.4 Rasterize 3D geometry
+  myRasterize3D = new QCheckBox( tr( "PS_RASTERIZE_3D" ), anOptionsBox );
+  
+  // 1.5 Use shfill shading operator
+  myPs3Shading = new QCheckBox( tr( "PS_USE_SHFILL" ), anOptionsBox );
+
+  // Add widgets to layout
+  anOptionsLayout->addWidget( lineLabel, 0, 0 );
+  anOptionsLayout->addWidget( myLineFactor, 0, 1 );
+  anOptionsLayout->addWidget( pointLabel, 1, 0 );
+  anOptionsLayout->addWidget( myPointFactor, 1, 1 );
+  anOptionsLayout->addWidget( sortLabel, 2, 0 );
+  anOptionsLayout->addWidget( mySortType, 2, 1 );
+  anOptionsLayout->addWidget( myRasterize3D, 3, 0, 1, 2 );
+  anOptionsLayout->addWidget( myPs3Shading, 4, 0, 1, 2 );
+
+  
+  QGroupBox* aButtonBox = new QGroupBox(theParent);
+
+  QPushButton* okBtn    = new QPushButton(tr("BUT_OK"), aButtonBox);
+  QPushButton* closeBtn = new QPushButton(tr("BUT_CLOSE"), aButtonBox);
+
+  QSpacerItem* aSpacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum);
+
+  QHBoxLayout* aLay = new QHBoxLayout(aButtonBox);
+  aLay->setMargin(6);
+  aLay->setSpacing(11);
+
+  aLay->addWidget(okBtn);
+  aLay->addItem(aSpacer);
+  aLay->addWidget(closeBtn);
+
+  connect(okBtn,    SIGNAL(clicked()), SLOT(accept()));
+  connect(closeBtn, SIGNAL(clicked()), SLOT(reject()));
+  
+  aTopLayout->addWidget( anOptionsBox );
+  aTopLayout->addWidget( aButtonBox );
+}
+
+/*!
+ * Destructor
+ */  
+SVTK_PsOptionsDlg::~SVTK_PsOptionsDlg()
+{
+}
+
+/*!
+ * Return line scale factor
+ */  
+double SVTK_PsOptionsDlg::getLineFactor() const {
+  return myLineFactor->value();
+}
+
+/*!
+ * Return point scale factor
+ */  
+double SVTK_PsOptionsDlg::getPointFactor() const {
+  return myPointFactor->value();
+}
+
+/*!
+ * Return sort type
+ */  
+int SVTK_PsOptionsDlg::getSortType() const {
+  return mySortType->currentIndex();
+}
+
+/*!
+ * Return rasterize 3D flag
+ */  
+bool SVTK_PsOptionsDlg::isRasterize3D() const {
+  return myRasterize3D->isChecked();
+}
+
+/*!
+ * Return Ps3Shading flag
+ */  
+bool SVTK_PsOptionsDlg::isPs3Shading() const {
+  return myPs3Shading->isChecked();
+}
diff --git a/src/SVTK/SVTK_PsOptionsDlg.h b/src/SVTK/SVTK_PsOptionsDlg.h
new file mode 100644 (file)
index 0000000..5db67e0
--- /dev/null
@@ -0,0 +1,52 @@
+// Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef SVTK_PSOPTIONSDLG_H
+#define SVTK_PSOPTIONSDLG_H
+
+#include <QDialog>
+
+class QtxDoubleSpinBox;
+class QCheckBox;
+class QComboBox;
+
+
+class SVTK_PsOptionsDlg : public QDialog
+{
+  Q_OBJECT
+
+public:
+  SVTK_PsOptionsDlg( QWidget* parent );
+  ~SVTK_PsOptionsDlg();
+
+  double getLineFactor() const;
+  double getPointFactor() const;
+  int    getSortType() const;
+  bool   isRasterize3D() const;
+  bool   isPs3Shading() const;
+
+private:
+  QtxDoubleSpinBox*   myLineFactor;
+  QtxDoubleSpinBox*   myPointFactor;
+  QComboBox*          mySortType;
+  QCheckBox*          myRasterize3D;
+  QCheckBox*          myPs3Shading;
+};
+
+#endif //SVTK_PSOPTIONSDLG_H
index b8eb05ee92e40df61c6d87df4e2fa5258acefb23..b9df65cdf8a08c76e18182ac713ad206078123be 100755 (executable)
@@ -23,6 +23,7 @@
 #include "SVTK_NonIsometricDlg.h"
 #include "SVTK_UpdateRateDlg.h"
 #include "SVTK_CubeAxesDlg.h"
+#include "SVTK_PsOptionsDlg.h"
 #include "SVTK_SetRotationPointDlg.h"
 #include "SVTK_ViewParameterDlg.h"
 #include "SVTK_ViewModel.h"
@@ -1375,33 +1376,43 @@ bool SVTK_ViewWindow::dumpViewToFormat( const QImage& img, const QString& fileNa
   if ( format != "PS" && format != "EPS" && format != "PDF" )
     return SUIT_ViewWindow::dumpViewToFormat( img, fileName, format );
 
-  SUIT_OverrideCursor wc;
+  SVTK_PsOptionsDlg* optionsDlg = new SVTK_PsOptionsDlg(this);
+  if ( optionsDlg->exec() == QDialog::Accepted ) {
+    SUIT_OverrideCursor wc;
 
-  vtkGL2PSExporter *anExporter = vtkGL2PSExporter::New();
-  anExporter->SetRenderWindow(getRenderWindow());
+    vtkGL2PSExporter *anExporter = vtkGL2PSExporter::New();
+    anExporter->SetRenderWindow(getRenderWindow());
 
-  if ( format == "PS" ) {
-    anExporter->SetFileFormatToPS();
-    anExporter->CompressOff();
-  }
-
-  if ( format == "EPS" ) {
-    anExporter->SetFileFormatToEPS();
-    anExporter->CompressOff();
-  }
+    // Set options
+    anExporter->SetLineWidthFactor(optionsDlg->getLineFactor());
+    anExporter->SetPointSizeFactor(optionsDlg->getPointFactor());
+    anExporter->SetSort((vtkGL2PSExporter::SortScheme)optionsDlg->getSortType());
+    anExporter->SetWrite3DPropsAsRasterImage((int)optionsDlg->isRasterize3D());
+    anExporter->SetPS3Shading((int)optionsDlg->isPs3Shading());
+    
+    if ( format == "PS" ) {
+      anExporter->SetFileFormatToPS();
+      anExporter->CompressOff();
+    }
+    
+    if ( format == "EPS" ) {
+      anExporter->SetFileFormatToEPS();
+      anExporter->CompressOff();
+    }
 
-  if ( format == "PDF" ) {
-    anExporter->SetFileFormatToPDF();
+    if ( format == "PDF" ) {
+      anExporter->SetFileFormatToPDF();
+    }
+    
+    QString aFilePrefix(fileName);
+    QString anExtension(SUIT_Tools::extension(fileName));
+    aFilePrefix.truncate(aFilePrefix.length() - 1 - anExtension.length());
+    anExporter->SetFilePrefix(aFilePrefix.toLatin1().data());
+    anExporter->Write();
+    anExporter->Delete();
   }
-
-  QString aFilePrefix(fileName);
-  QString anExtension(SUIT_Tools::extension(fileName));
-  aFilePrefix.truncate(aFilePrefix.length() - 1 - anExtension.length());
-  anExporter->SetFilePrefix(aFilePrefix.toLatin1().data());
-  anExporter->Write();
-  anExporter->Delete();
-
-  return true;
+  delete optionsDlg;
+  return true;  
 }
 
 /*!
index f922e9b1431e961013fcd0800e0c3b9e09800c9e..38591863b21dd5f0838f226a124fb4b198063610 100644 (file)
@@ -366,6 +366,49 @@ Please, refer to the documentation.</translation>
         <translation>Scaling</translation>
     </message>
 </context>
+<context>
+    <name>SVTK_PsOptionsDlg</name>
+    <message>
+        <source>DLG_PSOPTIONS_TITLE</source>
+        <translation>Post Script export options</translation>
+    </message>
+    <message>
+        <source>PS_OPTIONS</source>
+        <translation>Options</translation>
+    </message>
+    <message>
+        <source>PS_LINE_WIDTH</source>
+        <translation>Line width factor</translation>
+    </message>
+    <message>
+        <source>PS_POINT_SIZE</source>
+        <translation>Point size factor</translation>
+    </message>
+    <message>
+        <source>PS_SORT_METHOD</source>
+        <translation>Sort method</translation>
+    </message>
+    <message>
+        <source>PS_NO_SORTING</source>
+        <translation>No sorting</translation>
+    </message>
+    <message>
+        <source>PS_SIMPLE_SORTING</source>
+        <translation>Simple sorting</translation>
+    </message>
+    <message>
+        <source>PS_BPS_SORTING</source>
+        <translation>BSP sorting</translation>
+    </message>
+    <message>
+        <source>PS_RASTERIZE_3D</source>
+        <translation>Rasterize 3D geometry</translation>
+    </message>
+    <message>
+        <source>PS_USE_SHFILL</source>
+        <translation>Use shfill shading operator</translation>
+    </message>                
+</context>
 <context>
     <name>SVTK_RecorderDlg</name>
     <message>