MCPcopy Create free account
hub / github.com/Kitware/VTK / InitializeMaskParser

Method InitializeMaskParser

Rendering/Matplotlib/vtkMatplotlibMathTextUtilities.cxx:207–242  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

205
206//------------------------------------------------------------------------------
207bool vtkMatplotlibMathTextUtilities::InitializeMaskParser()
208{
209#if VTK_MODULE_ENABLE_VTK_PythonInterpreter
210 if (!Py_IsInitialized())
211 {
212 // ensure that Python is initialized.
213 vtkPythonInterpreter::Initialize();
214 }
215#endif
216 if (!Py_IsInitialized())
217 {
218 return false;
219 }
220
221 vtkPythonScopeGilEnsurer gilEnsurer;
222 vtkSmartPyObject mplMathTextLib(PyImport_ImportModule("matplotlib.mathtext"));
223 if (this->CheckForError(mplMathTextLib))
224 {
225 return false;
226 }
227
228 vtkSmartPyObject mathTextParserClass(PyObject_GetAttrString(mplMathTextLib, "MathTextParser"));
229 if (this->CheckForError(mathTextParserClass))
230 {
231 return false;
232 }
233
234 this->MaskParser = PyObject_CallFunction(mathTextParserClass, const_cast<char*>("s"), "agg");
235 if (this->CheckForError(this->MaskParser))
236 {
237 Py_CLEAR(this->MaskParser);
238 return false;
239 }
240
241 return true;
242}
243
244//------------------------------------------------------------------------------
245bool vtkMatplotlibMathTextUtilities::InitializePathParser()

Callers 2

GetMetricsMethod · 0.95
RenderStringMethod · 0.95

Calls 2

CheckForErrorMethod · 0.95
InitializeFunction · 0.50

Tested by

no test coverage detected