return myViewPort->dumpView();
}
+//================================================================
+// Function : dumpViewToPSFormat
+// Purpose :
+//================================================================
+bool GraphicsView_ViewFrame::dumpViewToPSFormat(const QString& fileName)
+{
+ return myViewPort->dumpViewToPSFormat(fileName);
+}
+
//================================================================
// Function : getVisualParameters
// Purpose :
GraphicsView_ViewPort* getViewPort() const { return myViewPort; }
virtual QImage dumpView();
+ virtual bool dumpViewToPSFormat(const QString& fileName);
virtual QString getVisualParameters();
virtual void setVisualParameters( const QString& theParameters );
#include <QRectF>
#include <QRubberBand>
#include <QScrollBar>
+#include <QPrinter>
+#include <QPainter>
#include <math.h>
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 :
QImage dumpView( bool theWholeScene = false,
QSizeF theSize = QSizeF() );
+ bool dumpViewToPSFormat(const QString& fileName);
+
public:
// scene
void setSceneGap( double theSceneGap );
return QImage();
}
+bool SUIT_ViewWindow::dumpViewToPSFormat(const QString& fileName)
+{
+ return false;
+}
+
/*!
Saves image to file according to the format
\param image - image
/*!
\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.
{
// 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
bool event(QEvent*);
virtual QImage dumpView();
+ virtual bool dumpViewToPSFormat(const QString& fileName);
bool dumpViewToFormat( const QString& fileName, const QString& format );
bool onAccelAction( int );
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 );
<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>&Cascade</translation>