Commit f4ca4d55 authored by Nikita Sirgienko's avatar Nikita Sirgienko
Browse files

Extend functionality of GraphicPackage: add posibility for not good, but...

Extend functionality of GraphicPackage: add posibility for not good, but workable method of tracking plot by command contents
parent d369291f
......@@ -26,5 +26,52 @@ catch
end_try_catch
clear __cantor_plot_filename__
</ToFileCommandTemplate>
<PlotPrecenseKeywords>
plot
semilogx
semilogy
loglog
polar
contour
bar
stairs
errorbar
sombrero
hist
fplot
imshow
stem
stem3
scatter
pareto
rose
pie
quiver
compass
feather
pcolor
area
fill
comet
plotmatrix
plot3
mesh
meshc
meshz
surf
surfc
surfl
surfnorm
isosurface
isonormals
isocaps
ezplot3
ezmesh
ezmeshc
ezsurf
ezsurfc
cantor_plot2d
cantor_plot3d
</PlotPrecenseKeywords>
</GraphicPackage>
</GraphicPackages>
\ No newline at end of file
</GraphicPackages>
<GraphicPackages>
<GraphicPackage>
<Id>matplotlib</Id>
<Name>Matplotlib</Name>
<TestPresenceCommand>
<GraphicPackage>
<Id>matplotlib</Id>
<Name>Matplotlib</Name>
<TestPresenceCommand>
try:
import matplotlib
print(1)
except ModuleNotFoundError:
print(0)
</TestPresenceCommand>
<EnableCommand>
</TestPresenceCommand>
<EnableCommand>
from matplotlib import pyplot as __cantor_plt__;
__cantor_plot_prefix__ = '%1'
......@@ -23,17 +23,18 @@ def __cantor_matplotlib_show__():
__cantor_matplotlib_original_show__ = matplotlib.pyplot.show
__cantor_plt__.show = __cantor_matplotlib_show__
</EnableCommand>
<DisableCommand>
</EnableCommand>
<DisableCommand>
__cantor_plt__.show = __cantor_matplotlib_original_show__;
</DisableCommand>
<ToFileCommandTemplate></ToFileCommandTemplate>
</GraphicPackage>
</DisableCommand>
<ToFileCommandTemplate></ToFileCommandTemplate>
<PlotPrecenseKeywords></PlotPrecenseKeywords>
</GraphicPackage>
<GraphicPackage>
<Id>plotly</Id>
<Name>Plot.ly</Name>
<TestPresenceCommand>
<GraphicPackage>
<Id>plotly</Id>
<Name>Plot.ly</Name>
<TestPresenceCommand>
def __cantor_plotly_check_presence__():
import matplotlib;
import sys
......@@ -48,8 +49,8 @@ try:
__cantor_plotly_check_presence__()
except ModuleNotFoundError:
print(0)
</TestPresenceCommand>
<EnableCommand>
</TestPresenceCommand>
<EnableCommand>
import plotly as __cantor_plotly__
__cantor_plot_prefix__ = '%1'
def __cantor_plotly_show__(figure):
......@@ -61,10 +62,11 @@ def __cantor_plotly_show__(figure):
__cantor_plotly_original_show__ = __cantor_plotly__.basedatatypes.BaseFigure.show
__cantor_plotly__.basedatatypes.BaseFigure.show = __cantor_plotly_show__
</EnableCommand>
<DisableCommand>
</EnableCommand>
<DisableCommand>
__cantor_plotly__.basedatatypes.BaseFigure.show = __cantor_plotly_original_show__;
</DisableCommand>
<ToFileCommandTemplate></ToFileCommandTemplate>
</GraphicPackage>
</DisableCommand>
<ToFileCommandTemplate></ToFileCommandTemplate>
<PlotPrecenseKeywords></PlotPrecenseKeywords>
</GraphicPackage>
</GraphicPackages>
......@@ -38,6 +38,7 @@ class Cantor::GraphicPackagePrivate
QString enableSupportCommand;
QString disableSupportCommand;
QString saveToFileCommandTemplate;
QStringList plotPrecenseKeywords;
};
Cantor::GraphicPackage::GraphicPackage(const Cantor::GraphicPackage& other): d(new GraphicPackagePrivate)
......@@ -89,6 +90,11 @@ bool Cantor::GraphicPackage::isHavePlotCommand() const
return !d->saveToFileCommandTemplate.isEmpty();
}
const QStringList & Cantor::GraphicPackage::plotCommandPrecentsKeywords() const
{
return d->plotPrecenseKeywords;
}
QList<GraphicPackage> Cantor::GraphicPackage::loadFromFile(const QString& filename)
{
QList<GraphicPackage> packages;
......@@ -115,11 +121,19 @@ QList<GraphicPackage> Cantor::GraphicPackage::loadFromFile(const QString& filena
package.d->disableSupportCommand = root.firstChildElement(QLatin1String("DisableCommand")).text().trimmed();
package.d->saveToFileCommandTemplate = root.firstChildElement(QLatin1String("ToFileCommandTemplate")).text().trimmed();
QString delimiter = QLatin1String("\n");
const QDomElement& delimiterElement = root.firstChildElement(QLatin1String("PlotPrecenseKeywordsDelimiter"));
if (!delimiterElement.isNull())
delimiter = delimiterElement.text().trimmed();
package.d->plotPrecenseKeywords = root.firstChildElement(QLatin1String("PlotPrecenseKeywords")).text().trimmed().split(delimiter, QString::SkipEmptyParts);
for (QString& name : package.d->plotPrecenseKeywords)
name = name.trimmed();
packages.append(package);
}
}
else
qDebug() << "fail parse" << filename << "as xml file";
qWarning() << "fail parse" << filename << "as xml file";
}
return packages;
......
......@@ -93,6 +93,14 @@ public:
*/
QString savePlotCommand(QString filenamePrefix = QString(), int plotNumber = -1, QString additionalInfo = QString()) const;
/**
* Some graphic package can't capture plots correctly, for example, some packages can't test precense of created plot.
* So, the package handling need some code for testing of plot command precense
* This method return list of some strings, which should be in plot command.
* @return List of strings, which should be in plot command or empty list.
*/
const QStringList& plotCommandPrecentsKeywords() const;
/**
* @brief Load graphic packages from XML file.
*
......
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