From: asl Date: Mon, 19 Mar 2018 11:55:49 +0000 (+0300) Subject: redesign of the export to PostScript X-Git-Tag: V8_5_0b1^2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2Foscar%2Fimps_2017;p=modules%2Fgui.git redesign of the export to PostScript --- diff --git a/src/GraphicsView/GraphicsView_ViewFrame.cxx b/src/GraphicsView/GraphicsView_ViewFrame.cxx index 342778427..899d64faf 100644 --- a/src/GraphicsView/GraphicsView_ViewFrame.cxx +++ b/src/GraphicsView/GraphicsView_ViewFrame.cxx @@ -211,12 +211,15 @@ QImage GraphicsView_ViewFrame::dumpView() } //================================================================ -// Function : dumpViewToPSFormat +// Function : dumpViewToFormat // Purpose : //================================================================ -bool GraphicsView_ViewFrame::dumpViewToPSFormat(const QString& fileName) +bool GraphicsView_ViewFrame::dumpViewToFormat( const QImage& image, const QString& fileName, const QString& format ) { - return myViewPort->dumpViewToPSFormat(fileName); + bool isOK = myViewPort->dumpViewToFormat(fileName, format); + if( !isOK ) + isOK = SUIT_ViewWindow::dumpViewToFormat( image, fileName, format ); + return isOK; } //================================================================ @@ -456,3 +459,13 @@ void GraphicsView_ViewFrame::hideEvent( QHideEvent* theEvent ) { emit Hide( theEvent ); } + +/*! + \return filters for image files +*/ +QString GraphicsView_ViewFrame::filter() const +{ + QStringList filters = SUIT_ViewWindow::filter().split( ";;", QString::SkipEmptyParts ); + filters << tr( "POSTSCRIPT_FILES" ); + return filters.join( ";;" ); +} diff --git a/src/GraphicsView/GraphicsView_ViewFrame.h b/src/GraphicsView/GraphicsView_ViewFrame.h index 9e2408b7b..8068f9e9f 100644 --- a/src/GraphicsView/GraphicsView_ViewFrame.h +++ b/src/GraphicsView/GraphicsView_ViewFrame.h @@ -54,8 +54,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 ); @@ -98,6 +97,8 @@ signals: protected: virtual void createActions(); virtual int createToolBar(); + virtual QString filter() const; + virtual bool dumpViewToFormat( const QImage&, const QString& fileName, const QString& format ); private: GraphicsView_Viewer* myViewer; diff --git a/src/GraphicsView/GraphicsView_ViewPort.cxx b/src/GraphicsView/GraphicsView_ViewPort.cxx index 6753aa5f6..aa60c1f63 100644 --- a/src/GraphicsView/GraphicsView_ViewPort.cxx +++ b/src/GraphicsView/GraphicsView_ViewPort.cxx @@ -474,8 +474,11 @@ QImage GraphicsView_ViewPort::dumpView( bool theWholeScene, return anImage; } -bool GraphicsView_ViewPort::dumpViewToPSFormat(const QString& fileName) +bool GraphicsView_ViewPort::dumpViewToFormat(const QString& fileName, const QString& format) { + if( format!="PS" && format!="EPS" ) + return false; + QPrinter printer(QPrinter::ScreenResolution); printer.setOutputFormat(QPrinter::PostScriptFormat); printer.setOutputFileName(fileName); diff --git a/src/GraphicsView/GraphicsView_ViewPort.h b/src/GraphicsView/GraphicsView_ViewPort.h index 50ac0b65f..c99a881d7 100644 --- a/src/GraphicsView/GraphicsView_ViewPort.h +++ b/src/GraphicsView/GraphicsView_ViewPort.h @@ -94,7 +94,7 @@ public: QImage dumpView( bool theWholeScene = false, QSizeF theSize = QSizeF() ); - bool dumpViewToPSFormat(const QString& fileName); + bool dumpViewToFormat(const QString& fileName, const QString& format); public: // scene diff --git a/src/GraphicsView/resources/GraphicsView_msg_en.ts b/src/GraphicsView/resources/GraphicsView_msg_en.ts index 919919eba..a6ee6ba23 100644 --- a/src/GraphicsView/resources/GraphicsView_msg_en.ts +++ b/src/GraphicsView/resources/GraphicsView_msg_en.ts @@ -70,6 +70,10 @@ MNU_ZOOM_VIEW Zoom + + POSTSCRIPT_FILES + PostScript files (*.ps *.eps) + GraphicsView_Viewer diff --git a/src/GraphicsView/resources/GraphicsView_msg_fr.ts b/src/GraphicsView/resources/GraphicsView_msg_fr.ts index fe21b4927..031620364 100644 --- a/src/GraphicsView/resources/GraphicsView_msg_fr.ts +++ b/src/GraphicsView/resources/GraphicsView_msg_fr.ts @@ -71,6 +71,10 @@ MNU_ZOOM_VIEW Zoom + + POSTSCRIPT_FILES + Fichiers PostScript (*.ps *.eps) + GraphicsView_Viewer diff --git a/src/GraphicsView/resources/GraphicsView_msg_ja.ts b/src/GraphicsView/resources/GraphicsView_msg_ja.ts index 23d069232..efc189b5b 100644 --- a/src/GraphicsView/resources/GraphicsView_msg_ja.ts +++ b/src/GraphicsView/resources/GraphicsView_msg_ja.ts @@ -71,6 +71,10 @@ MNU_ZOOM_VIEW ズーム + + POSTSCRIPT_FILES + PostScript files (*.ps *.eps) + GraphicsView_Viewer diff --git a/src/SUIT/SUIT_ViewWindow.cxx b/src/SUIT/SUIT_ViewWindow.cxx index 040926319..d0ac1a066 100755 --- a/src/SUIT/SUIT_ViewWindow.cxx +++ b/src/SUIT/SUIT_ViewWindow.cxx @@ -94,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 @@ -177,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. @@ -199,26 +187,20 @@ bool SUIT_ViewWindow::event( QEvent* e ) SUIT_Application* app = NULL; if (myManager && myManager->study() && myManager->study()->application()) app = myManager->study()->application(); - bool IncludePs = true; QString fileName; if (app) - fileName = app->getFileName( false, QString(), filter(IncludePs), tr( "TLT_DUMP_VIEW" ), 0 ); //old way + fileName = app->getFileName( false, QString(), filter(), tr( "TLT_DUMP_VIEW" ), 0 ); //old way else { - QStringList fls = filter(IncludePs).split( ";;", QString::SkipEmptyParts ); + 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(); - if (fmt == "PS" || fmt == "EPS" ) - bOk = dumpViewToPSFormat(fileName); - else - { - QImage im = dumpView(); - Qtx::Localizer loc; - bOk = dumpViewToFormat( im, fileName, fmt ); - } + QImage im = dumpView(); + Qtx::Localizer loc; + bOk = dumpViewToFormat( im, fileName, fmt ); } else bOk = true; // cancelled diff --git a/src/SUIT/SUIT_ViewWindow.h b/src/SUIT/SUIT_ViewWindow.h index 3e49587ab..fd717f617 100755 --- a/src/SUIT/SUIT_ViewWindow.h +++ b/src/SUIT/SUIT_ViewWindow.h @@ -53,7 +53,6 @@ public: bool event(QEvent*); virtual QImage dumpView(); - virtual bool dumpViewToPSFormat(const QString& fileName); bool dumpViewToFormat( const QString& fileName, const QString& format ); bool onAccelAction( int ); @@ -94,7 +93,7 @@ signals: protected: void closeEvent( QCloseEvent* ); virtual void contextMenuEvent( QContextMenuEvent* ); - virtual QString filter(bool includePS = false) const; + virtual QString filter() const; virtual bool action( const int ); virtual bool dumpViewToFormat( const QImage&, const QString& fileName, const QString& format ); diff --git a/src/SUIT/resources/SUIT_msg_en.ts b/src/SUIT/resources/SUIT_msg_en.ts index 5c3012b86..03659c6a8 100644 --- a/src/SUIT/resources/SUIT_msg_en.ts +++ b/src/SUIT/resources/SUIT_msg_en.ts @@ -15,10 +15,6 @@ TLT_IMAGE_FILES Images Files (*.bmp *.png *.jpg *.jpeg) - - POSTSCRIPT_FILES - PostScript files (*.ps *.eps) - MEN_DESK_WINDOW_CASCADE &Cascade @@ -174,9 +170,5 @@ Do you want to overwrite it? TLT_IMAGE_FILES Images Files (*.bmp *.png *.jpg *.jpeg) - - POSTSCRIPT_FILES - PostScript files (*.ps *.eps) -