added saving of layout as .ps and .eps file

--HG--
branch : develop
This commit is contained in:
Sabine Schmaltz 2014-02-17 23:57:51 +01:00
parent 16ce3f6728
commit c1191c4e9d
2 changed files with 73 additions and 3 deletions

View File

@ -166,6 +166,8 @@ void TableWindow::saveScene()
extByMessage[ tr("Svg files (*.svg)") ] = ".svg"; extByMessage[ tr("Svg files (*.svg)") ] = ".svg";
extByMessage[ tr("PDF files (*.pdf)") ] = ".pdf"; extByMessage[ tr("PDF files (*.pdf)") ] = ".pdf";
extByMessage[ tr("Images (*.png)") ] = ".png"; extByMessage[ tr("Images (*.png)") ] = ".png";
extByMessage[ tr("PS files (*.ps)") ] = ".ps";
extByMessage[ tr("EPS files (*.eps)") ] = ".eps";
QString saveMessage; QString saveMessage;
QMapIterator<QString, QString> i(extByMessage); QMapIterator<QString, QString> i(extByMessage);
@ -191,7 +193,8 @@ void TableWindow::saveScene()
// what if the users did not specify a suffix...? // what if the users did not specify a suffix...?
QFileInfo f( name ); QFileInfo f( name );
if (f.suffix().isEmpty() && f.suffix() != "svg" && f.suffix() != "png" && f.suffix() != "pdf") if (f.suffix().isEmpty() && f.suffix() != "svg" && f.suffix() != "png" && f.suffix() != "pdf"
&& f.suffix() != "eps" && f.suffix() != "ps")
{ {
name += extByMessage[sf]; name += extByMessage[sf];
} }
@ -220,7 +223,18 @@ void TableWindow::saveScene()
PdfFile(name); PdfFile(name);
paper->setPen(QPen(Qt::black, widthMainLine)); paper->setPen(QPen(Qt::black, widthMainLine));
} }
else if (fi.suffix() == "eps")
{
paper->setPen(QPen(Qt::white, 0.1, Qt::NoPen));
EpsFile(name);
paper->setPen(QPen(Qt::black, widthMainLine));
}
else if (fi.suffix() == "ps")
{
paper->setPen(QPen(Qt::white, 0.1, Qt::NoPen));
PsFile(name);
paper->setPen(QPen(Qt::black, widthMainLine));
}
brush->setColor( QColor( Qt::gray ) ); brush->setColor( QColor( Qt::gray ) );
brush->setStyle( Qt::SolidPattern ); brush->setStyle( Qt::SolidPattern );
tableScene->setBackgroundBrush( *brush ); tableScene->setBackgroundBrush( *brush );
@ -460,3 +474,49 @@ void TableWindow::PdfFile(const QString &name) const
tableScene->render(&painter); tableScene->render(&painter);
painter.end(); painter.end();
} }
void TableWindow::EpsFile(const QString &name) const
{
QTemporaryFile tmp;
if (tmp.open()) {
QProcess proc;
QString program;
QStringList params;
PdfFile(tmp.fileName());
#ifdef Q_OS_WIN32
program = "pdftops.exe";
#else
program = "pdftops";
#endif
params << "-eps" << tmp.fileName() << name;
proc.start(program,params);
proc.waitForFinished();
qDebug() << proc.errorString();
}
}
void TableWindow::PsFile(const QString &name) const
{
QTemporaryFile tmp;
if (tmp.open()) {
QProcess proc;
QString program;
QStringList params;
PdfFile(tmp.fileName());
#ifdef Q_OS_WIN32
program = "pdftops.exe";
#else
program = "pdftops";
#endif
params << tmp.fileName() << name;
proc.start(program,params);
proc.waitForFinished();
qDebug() << proc.errorString();
}
}

View File

@ -204,10 +204,20 @@ private:
*/ */
void PngFile(const QString &name)const; void PngFile(const QString &name)const;
/** /**
* @brief PdfFile save layout to ps file. * @brief PdfFile save layout to pdf file.
* @param name name layout file. * @param name name layout file.
*/ */
void PdfFile(const QString &name)const; void PdfFile(const QString &name)const;
/**
* @brief EpsFile save layout to eps file.
* @param name name layout file.
*/
void EpsFile(const QString &name)const;
/**
* @brief PsFile save layout to ps file.
* @param name name layout file.
*/
void PsFile(const QString &name)const;
}; };
#endif // TABLEWINDOW_H #endif // TABLEWINDOW_H