VTK  9.0.1
vtkMatplotlibMathTextUtilities.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkMatplotlibMathTextUtilities.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
28 #ifndef vtkMatplotlibMathTextUtilities_h
29 #define vtkMatplotlibMathTextUtilities_h
30 
31 #include "vtkMathTextUtilities.h"
32 #include "vtkRenderingMatplotlibModule.h" // For export macro
33 
34 struct _object;
35 typedef struct _object PyObject;
36 class vtkImageData;
37 class vtkPath;
38 class vtkPythonInterpreter;
39 class vtkTextProperty;
40 
41 class VTKRENDERINGMATPLOTLIB_EXPORT vtkMatplotlibMathTextUtilities : public vtkMathTextUtilities
42 {
43 public:
45  void PrintSelf(ostream& os, vtkIndent indent) override;
46 
48 
49  bool IsAvailable() override;
50 
58  bool GetBoundingBox(vtkTextProperty* tprop, const char* str, int dpi, int bbox[4]) override;
59 
60  bool GetMetrics(
61  vtkTextProperty* tprop, const char* str, int dpi, vtkTextRenderer::Metrics& metrics) override;
62 
73  bool RenderString(const char* str, vtkImageData* data, vtkTextProperty* tprop, int dpi,
74  int textDims[2] = NULL) override;
75 
82  bool StringToPath(const char* str, vtkPath* path, vtkTextProperty* tprop, int dpi) override;
83 
85 
90  void SetScaleToPowerOfTwo(bool val) override;
91  bool GetScaleToPowerOfTwo() override;
93 
94 protected:
97 
101 
103  bool CheckForError(PyObject* object);
104 
110 
117 
118  vtkPythonInterpreter* Interpreter;
122 
123  static void GetJustifiedBBox(int rows, int cols, vtkTextProperty* tprop, int bbox[4]);
124 
125  // Rotate the 4 2D corner points by the specified angle (degrees) around the
126  // origin and calculate the bounding box
127  static void RotateCorners(double angleDeg, double corners[4][2], double bbox[4]);
128 
130  bool PrepareImageData(vtkImageData* data, int bbox[4]);
131 
132 private:
134  void operator=(const vtkMatplotlibMathTextUtilities&) = delete;
135 
140  enum Availability
141  {
142  NOT_TESTED = 0,
143  AVAILABLE,
144  UNAVAILABLE
145  };
146 
153  static Availability CheckMPLAvailability();
154  static void DisableMPL()
155  {
156  MPLMathTextAvailable = UNAVAILABLE;
157  };
158 
160 
163  static Availability MPLMathTextAvailable;
165 };
166 
167 #endif
vtkMatplotlibMathTextUtilities::New
static vtkMatplotlibMathTextUtilities * New()
vtkMatplotlibMathTextUtilities::GetFontProperties
PyObject * GetFontProperties(vtkTextProperty *tprop)
Returns a matplotlib.font_manager.FontProperties PyObject, initialized from the vtkTextProperty tprop...
vtkMatplotlibMathTextUtilities::StringToPath
bool StringToPath(const char *str, vtkPath *path, vtkTextProperty *tprop, int dpi) override
Parse the MathText expression in str and fill path with a contour of the glyphs.
vtkMatplotlibMathTextUtilities
Access to MatPlotLib MathText rendering.
Definition: vtkMatplotlibMathTextUtilities.h:42
vtkMatplotlibMathTextUtilities::InitializeMaskParser
bool InitializeMaskParser()
vtkMatplotlibMathTextUtilities::~vtkMatplotlibMathTextUtilities
~vtkMatplotlibMathTextUtilities() override
vtkX3D::data
@ data
Definition: vtkX3D.h:321
vtkPath
concrete dataset representing a path defined by Bezier curves.
Definition: vtkPath.h:33
vtkMatplotlibMathTextUtilities::MaskParser
PyObject * MaskParser
Definition: vtkMatplotlibMathTextUtilities.h:119
vtkMatplotlibMathTextUtilities::SetScaleToPowerOfTwo
void SetScaleToPowerOfTwo(bool val) override
Set to true if the graphics implementation requires texture image dimensions to be a power of two.
vtkMathTextUtilities
Abstract interface to equation rendering.
Definition: vtkMathTextUtilities.h:52
vtkMatplotlibMathTextUtilities::GetBoundingBox
bool GetBoundingBox(vtkTextProperty *tprop, const char *str, int dpi, int bbox[4]) override
Given a text property and a string, get the bounding box {xmin, xmax, ymin, ymax} of the rendered str...
vtkMatplotlibMathTextUtilities::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
PyObject
struct _object PyObject
Definition: vtkMatplotlibMathTextUtilities.h:35
vtkMatplotlibMathTextUtilities::GetScaleToPowerOfTwo
bool GetScaleToPowerOfTwo() override
Set to true if the graphics implementation requires texture image dimensions to be a power of two.
vtkMatplotlibMathTextUtilities::GetMetrics
bool GetMetrics(vtkTextProperty *tprop, const char *str, int dpi, vtkTextRenderer::Metrics &metrics) override
Return the metrics for the rendered str, tprop, and dpi.
vtkImageData
topologically and geometrically regular array of data
Definition: vtkImageData.h:42
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:34
vtkMatplotlibMathTextUtilities::CheckForError
bool CheckForError(PyObject *object)
vtkMatplotlibMathTextUtilities::FontPropertiesClass
PyObject * FontPropertiesClass
Definition: vtkMatplotlibMathTextUtilities.h:121
vtkMatplotlibMathTextUtilities::RotateCorners
static void RotateCorners(double angleDeg, double corners[4][2], double bbox[4])
vtkMatplotlibMathTextUtilities::PathParser
PyObject * PathParser
Definition: vtkMatplotlibMathTextUtilities.h:120
vtkTextProperty
represent text properties.
Definition: vtkTextProperty.h:34
vtkMatplotlibMathTextUtilities::InitializePathParser
bool InitializePathParser()
vtkMatplotlibMathTextUtilities::CheckForError
bool CheckForError()
vtkMatplotlibMathTextUtilities::vtkMatplotlibMathTextUtilities
vtkMatplotlibMathTextUtilities()
vtkMatplotlibMathTextUtilities::InitializeFontPropertiesClass
bool InitializeFontPropertiesClass()
vtkMatplotlibMathTextUtilities::CleanupPythonObjects
void CleanupPythonObjects()
Cleanup and destroy any python objects.
vtkMatplotlibMathTextUtilities::RenderString
bool RenderString(const char *str, vtkImageData *data, vtkTextProperty *tprop, int dpi, int textDims[2]=NULL) override
Render the given string str into the vtkImageData data with a resolution of dpi.
vtkMathTextUtilities.h
vtkTextRenderer::Metrics
Definition: vtkTextRenderer.h:77
vtkMatplotlibMathTextUtilities::PrepareImageData
bool PrepareImageData(vtkImageData *data, int bbox[4])
vtkMatplotlibMathTextUtilities::Interpreter
vtkPythonInterpreter * Interpreter
Definition: vtkMatplotlibMathTextUtilities.h:118
vtkMatplotlibMathTextUtilities::ScaleToPowerOfTwo
bool ScaleToPowerOfTwo
Definition: vtkMatplotlibMathTextUtilities.h:129
vtkMatplotlibMathTextUtilities::GetJustifiedBBox
static void GetJustifiedBBox(int rows, int cols, vtkTextProperty *tprop, int bbox[4])
vtkMatplotlibMathTextUtilities::IsAvailable
bool IsAvailable() override
Returns true if mathtext rendering is available.