|
@@ -31,6 +31,7 @@ namespace matplotlibcpp {
|
|
|
|
|
|
struct _interpreter {
|
|
struct _interpreter {
|
|
PyObject *s_python_function_show;
|
|
PyObject *s_python_function_show;
|
|
|
|
+ PyObject *s_python_function_close;
|
|
PyObject *s_python_function_draw;
|
|
PyObject *s_python_function_draw;
|
|
PyObject *s_python_function_pause;
|
|
PyObject *s_python_function_pause;
|
|
PyObject *s_python_function_save;
|
|
PyObject *s_python_function_save;
|
|
@@ -122,6 +123,7 @@ namespace matplotlibcpp {
|
|
if(!pylabmod) { throw std::runtime_error("Error loading module pylab!"); }
|
|
if(!pylabmod) { throw std::runtime_error("Error loading module pylab!"); }
|
|
|
|
|
|
s_python_function_show = PyObject_GetAttrString(pymod, "show");
|
|
s_python_function_show = PyObject_GetAttrString(pymod, "show");
|
|
|
|
+ s_python_function_close = PyObject_GetAttrString(pymod, "close");
|
|
s_python_function_draw = PyObject_GetAttrString(pymod, "draw");
|
|
s_python_function_draw = PyObject_GetAttrString(pymod, "draw");
|
|
s_python_function_pause = PyObject_GetAttrString(pymod, "pause");
|
|
s_python_function_pause = PyObject_GetAttrString(pymod, "pause");
|
|
s_python_function_figure = PyObject_GetAttrString(pymod, "figure");
|
|
s_python_function_figure = PyObject_GetAttrString(pymod, "figure");
|
|
@@ -150,6 +152,7 @@ namespace matplotlibcpp {
|
|
s_python_function_xkcd = PyObject_GetAttrString(pymod, "xkcd");
|
|
s_python_function_xkcd = PyObject_GetAttrString(pymod, "xkcd");
|
|
|
|
|
|
if( !s_python_function_show
|
|
if( !s_python_function_show
|
|
|
|
+ || !s_python_function_close
|
|
|| !s_python_function_draw
|
|
|| !s_python_function_draw
|
|
|| !s_python_function_pause
|
|
|| !s_python_function_pause
|
|
|| !s_python_function_figure
|
|
|| !s_python_function_figure
|
|
@@ -179,6 +182,7 @@ namespace matplotlibcpp {
|
|
) { throw std::runtime_error("Couldn't find required function!"); }
|
|
) { throw std::runtime_error("Couldn't find required function!"); }
|
|
|
|
|
|
if ( !PyFunction_Check(s_python_function_show)
|
|
if ( !PyFunction_Check(s_python_function_show)
|
|
|
|
+ || !PyFunction_Check(s_python_function_close)
|
|
|| !PyFunction_Check(s_python_function_draw)
|
|
|| !PyFunction_Check(s_python_function_draw)
|
|
|| !PyFunction_Check(s_python_function_pause)
|
|
|| !PyFunction_Check(s_python_function_pause)
|
|
|| !PyFunction_Check(s_python_function_figure)
|
|
|| !PyFunction_Check(s_python_function_figure)
|
|
@@ -913,6 +917,17 @@ namespace matplotlibcpp {
|
|
Py_DECREF(res);
|
|
Py_DECREF(res);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ inline void close()
|
|
|
|
+ {
|
|
|
|
+ PyObject* res = PyObject_CallObject(
|
|
|
|
+ detail::_interpreter::get().s_python_function_close,
|
|
|
|
+ detail::_interpreter::get().s_python_empty_tuple);
|
|
|
|
+
|
|
|
|
+ if (!res) throw std::runtime_error("Call to close() failed.");
|
|
|
|
+
|
|
|
|
+ Py_DECREF(res);
|
|
|
|
+ }
|
|
|
|
+
|
|
inline void xkcd() {
|
|
inline void xkcd() {
|
|
PyObject* res;
|
|
PyObject* res;
|
|
PyObject *kwargs = PyDict_New();
|
|
PyObject *kwargs = PyDict_New();
|