Commit 9653be87 authored by Alexander Semke's avatar Alexander Semke
Browse files

Started removing the usage of libspectre.

Reasoning:
* right now we're asking the backend to produce an EPS file for the plot and convert it via libspectre to PNG to render. We can directly ask the backend to generate the PNG file and remove this unneeded conversion.
* libspectre is very unstable and crashing often, at least on openSuse
* this library doesn't seem to be heavily developed/supported anymore
* later we'll switch to the PDF output in the backend systems and render it via poppler to PNG as it is already done for Jupyter content.

We start removing it for maxima now, other parts of the code will be addressed step by step.
parent 3ca8a792
Pipeline #114795 passed with stage
in 18 minutes and 34 seconds
......@@ -73,11 +73,7 @@ void MaximaExpression::evaluate()
&& cmd.contains(QRegularExpression(QStringLiteral("(?:plot2d|plot3d|contour_plot)\\s*\\([^\\)]"))))
{
m_isPlot=true;
#ifdef WITH_EPS
m_tempFile=new QTemporaryFile(QDir::tempPath() + QLatin1String("/cantor_maxima-XXXXXX.eps" ));
#else
m_tempFile=new QTemporaryFile(QDir::tempPath() + QLatin1String("/cantor_maxima-XXXXXX.png"));
#endif
m_tempFile = new QTemporaryFile(QDir::tempPath() + QLatin1String("/cantor_maxima-XXXXXX.png"));
m_tempFile->open();
m_fileWatch.removePaths(m_fileWatch.files());
......@@ -154,13 +150,13 @@ QString MaximaExpression::internalCommand()
}
QString fileName = m_tempFile->fileName();
#ifdef WITH_EPS
const QString psParam=QLatin1String("[gnuplot_ps_term_command, \"set size 1.0, 1.0; set term postscript eps color solid \"]");
const QString plotParameters = QLatin1String("[ps_file, \"")+ fileName+QLatin1String("\"],")+psParam;
#else
/*
const QString pdfParam = QLatin1String("[gnuplot_pdf_term_command, \"set term pdfcairo size 9cm, 6cm\"]"); // size 5.9in, 4.7in
const QString plotParameters = QLatin1String("[pdf_file, \"") + fileName + QLatin1String("\"], ") + pdfParam;
*/
const QString plotParameters = QLatin1String("[gnuplot_term, \"png size 500,340\"], [gnuplot_out_file, \"")+fileName+QLatin1String("\"]");
#endif
cmd.replace(QRegularExpression(QStringLiteral("((plot2d|plot3d|contour_plot)\\s*\\(.*)\\)([;\n$]|$)")),
QLatin1String("\\1, ") + plotParameters + QLatin1String(");"));
......@@ -419,11 +415,13 @@ void MaximaExpression::imageChanged()
{
if(m_tempFile->size()>0)
{
#ifdef WITH_EPS
m_plotResult = new Cantor::EpsResult( QUrl::fromLocalFile(m_tempFile->fileName()) );
#else
m_plotResult = new Cantor::ImageResult( QUrl::fromLocalFile(m_tempFile->fileName()) );
#endif
/*
QSizeF size;
const QImage& image = Cantor::Renderer::pdfRenderToImage(QUrl::fromLocalFile(m_tempFile->fileName()), 1., false, &size);
m_plotResult = new Cantor::ImageResult(image);
*/
// Check, that we already parse maxima output for this plot, and if not, keep it up to this moment
// If it's true, replace text info result by real plot and set status as Done
if (m_plotResultIndex != -1)
......
......@@ -66,11 +66,7 @@ void TestMaxima::testPlot()
waitForSignal(e, SIGNAL(gotResult()));
}
#ifdef WITH_EPS
QCOMPARE( e->result()->type(), (int)Cantor::EpsResult::Type );
#else
QCOMPARE( e->result()->type(), (int)Cantor::ImageResult::Type );
#endif
QVERIFY( !e->result()->data().isNull() );
QVERIFY( e->errorMessage().isNull() );
}
......@@ -97,11 +93,7 @@ void TestMaxima::testPlotWithAnotherTextResults()
QCOMPARE(e->results().at(0)->data().toString(), QLatin1String("4"));
#ifdef WITH_EPS
QCOMPARE( e->results().at(1)->type(), (int)Cantor::EpsResult::Type );
#else
QCOMPARE( e->results().at(1)->type(), (int)Cantor::ImageResult::Type );
#endif
QVERIFY( !e->results().at(1)->data().isNull() );
QCOMPARE(e->results().at(2)->data().toString(), QLatin1String("16"));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment