VTK
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=========================================================================*/
31#ifndef vtkMatplotlibMathTextUtilities_h
32#define vtkMatplotlibMathTextUtilities_h
33
34#include "vtkRenderingMatplotlibModule.h" // For export macro
36
37struct _object;
38typedef struct _object PyObject;
39class vtkImageData;
40class vtkPath;
41class vtkPythonInterpreter;
42class vtkTextProperty;
43
44class VTKRENDERINGMATPLOTLIB_EXPORT vtkMatplotlibMathTextUtilities :
46{
47public:
49 void PrintSelf(ostream& os, vtkIndent indent);
50
52
53 virtual bool IsAvailable();
54
62 bool GetBoundingBox(vtkTextProperty *tprop, const char *str, int dpi,
63 int bbox[4]);
64
65 bool GetMetrics(vtkTextProperty *tprop, const char *str, int dpi,
67
78 bool RenderString(const char *str, vtkImageData *data, vtkTextProperty *tprop,
79 int dpi, int textDims[2] = NULL);
80
87 bool StringToPath(const char *str, vtkPath *path, vtkTextProperty *tprop,
88 int dpi);
89
91
96 vtkSetMacro(ScaleToPowerOfTwo, bool);
97 vtkGetMacro(ScaleToPowerOfTwo, bool);
99
100protected:
103
107
109 bool CheckForError(PyObject *object);
110
116
123
124 vtkPythonInterpreter* Interpreter;
128
129 static void GetJustifiedBBox(int rows, int cols, vtkTextProperty *tprop,
130 int bbox[4]);
131
132 // Rotate the 4 2D corner points by the specified angle (degrees) around the
133 // origin and calculate the bounding box
134 static void RotateCorners(double angleDeg, double corners[4][2],
135 double bbox[4]);
136
138 bool PrepareImageData(vtkImageData *data, int bbox[4]);
139
140private:
142 void operator=(const vtkMatplotlibMathTextUtilities&) VTK_DELETE_FUNCTION;
143
148 enum Availability
149 {
150 NOT_TESTED = 0,
151 AVAILABLE,
152 UNAVAILABLE
153 };
154
161 static Availability CheckMPLAvailability();
162 static void DisableMPL()
163 {
164 MPLMathTextAvailable = UNAVAILABLE;
165 };
166
168
171 static Availability MPLMathTextAvailable;
172};
174
175#endif
topologically and geometrically regular array of data
Definition: vtkImageData.h:46
a simple class to control print indentation
Definition: vtkIndent.h:40
Abstract interface to equation rendering.
Access to MatPlotLib MathText rendering.
PyObject * GetFontProperties(vtkTextProperty *tprop)
Returns a matplotlib.font_manager.FontProperties PyObject, initialized from the vtkTextProperty tprop...
bool StringToPath(const char *str, vtkPath *path, vtkTextProperty *tprop, int dpi)
Parse the MathText expression in str and fill path with a contour of the glyphs.
static void GetJustifiedBBox(int rows, int cols, vtkTextProperty *tprop, int bbox[4])
bool CheckForError(PyObject *object)
void CleanupPythonObjects()
Cleanup and destroy any python objects.
virtual bool IsAvailable()
Returns true if mathtext rendering is available.
bool RenderString(const char *str, vtkImageData *data, vtkTextProperty *tprop, int dpi, int textDims[2]=NULL)
Render the given string str into the vtkImageData data with a resolution of dpi.
static vtkMatplotlibMathTextUtilities * New()
bool GetMetrics(vtkTextProperty *tprop, const char *str, int dpi, vtkTextRenderer::Metrics &metrics)
Return the metrics for the rendered str, tprop, and dpi.
void PrintSelf(ostream &os, vtkIndent indent)
Methods invoked by print to print information about the object including superclasses.
static void RotateCorners(double angleDeg, double corners[4][2], double bbox[4])
bool GetBoundingBox(vtkTextProperty *tprop, const char *str, int dpi, int bbox[4])
Given a text property and a string, get the bounding box {xmin, xmax, ymin, ymax} of the rendered str...
bool PrepareImageData(vtkImageData *data, int bbox[4])
concrete dataset representing a path defined by Bezier curves.
Definition: vtkPath.h:36
represent text properties.
@ data
Definition: vtkX3D.h:315
struct _object PyObject
vtkSetMacro(IgnoreDriverBugs, bool)
Updates the extensions string.