From: rnv Date: Tue, 2 Aug 2016 08:17:49 +0000 (+0300) Subject: Implementation of the "23166: EDF 11517 SMESH: Dump view into ps fails" improvement. X-Git-Tag: V8_1_0b1~9 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=a0343721871ad7fd16734a502d35c4ebea376d89;p=modules%2Fgui.git Implementation of the "23166: EDF 11517 SMESH: Dump view into ps fails" improvement. --- diff --git a/src/SVTK/CMakeLists.txt b/src/SVTK/CMakeLists.txt index 53dcf7e84..493e5651c 100755 --- a/src/SVTK/CMakeLists.txt +++ b/src/SVTK/CMakeLists.txt @@ -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 index 000000000..33ab91fd4 --- /dev/null +++ b/src/SVTK/SVTK_PsOptionsDlg.cxx @@ -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 + +#include +#include +#include +#include +#include +#include +#include + +/*! + * 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 index 000000000..5db67e06d --- /dev/null +++ b/src/SVTK/SVTK_PsOptionsDlg.h @@ -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 + +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 diff --git a/src/SVTK/SVTK_ViewWindow.cxx b/src/SVTK/SVTK_ViewWindow.cxx index b8eb05ee9..b9df65cdf 100755 --- a/src/SVTK/SVTK_ViewWindow.cxx +++ b/src/SVTK/SVTK_ViewWindow.cxx @@ -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; } /*! diff --git a/src/SVTK/resources/SVTK_msg_en.ts b/src/SVTK/resources/SVTK_msg_en.ts index f922e9b14..38591863b 100644 --- a/src/SVTK/resources/SVTK_msg_en.ts +++ b/src/SVTK/resources/SVTK_msg_en.ts @@ -366,6 +366,49 @@ Please, refer to the documentation. Scaling + + SVTK_PsOptionsDlg + + DLG_PSOPTIONS_TITLE + Post Script export options + + + PS_OPTIONS + Options + + + PS_LINE_WIDTH + Line width factor + + + PS_POINT_SIZE + Point size factor + + + PS_SORT_METHOD + Sort method + + + PS_NO_SORTING + No sorting + + + PS_SIMPLE_SORTING + Simple sorting + + + PS_BPS_SORTING + BSP sorting + + + PS_RASTERIZE_3D + Rasterize 3D geometry + + + PS_USE_SHFILL + Use shfill shading operator + + SVTK_RecorderDlg