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
35 #include "vtkMathTextUtilities.h"
36 
37 struct _object;
38 typedef struct _object PyObject;
39 class vtkImageData;
40 class vtkPath;
41 class vtkPythonInterpreter;
42 class vtkTextProperty;
43 
44 class VTKRENDERINGMATPLOTLIB_EXPORT vtkMatplotlibMathTextUtilities :
46 {
47 public:
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,
66  vtkTextRenderer::Metrics &metrics);
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 
100 protected:
103 
104  bool InitializeMaskParser();
105  bool InitializePathParser();
106  bool InitializeFontPropertiesClass();
107 
108  bool CheckForError();
109  bool CheckForError(PyObject *object);
110 
115  PyObject * GetFontProperties(vtkTextProperty *tprop);
116 
122  void CleanupPythonObjects();
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 
140 private:
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
vtkMathTextUtilities::IsAvailable
virtual bool IsAvailable()
Returns true if mathtext rendering is available.
Definition: vtkMathTextUtilities.h:63
vtkMatplotlibMathTextUtilities
Access to MatPlotLib MathText rendering.
Definition: vtkMatplotlibMathTextUtilities.h:44
vtkMathTextUtilities::GetMetrics
virtual bool GetMetrics(vtkTextProperty *tprop, const char *str, int dpi, vtkTextRenderer::Metrics &metrics)=0
Return the metrics for the rendered str, tprop, and dpi.
vtkX3D::data
@ data
Definition: vtkX3D.h:315
vtkPath
concrete dataset representing a path defined by Bezier curves.
Definition: vtkPath.h:35
vtkMatplotlibMathTextUtilities::MaskParser
PyObject * MaskParser
Definition: vtkMatplotlibMathTextUtilities.h:125
vtkMathTextUtilities::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent)
Methods invoked by print to print information about the object including superclasses.
vtkMathTextUtilities::RenderString
virtual bool RenderString(const char *str, vtkImageData *data, vtkTextProperty *tprop, int dpi, int textDims[2]=NULL)=0
Render the given string str into the vtkImageData data with a resolution of dpi.
vtkMathTextUtilities
Abstract interface to equation rendering.
Definition: vtkMathTextUtilities.h:54
PyObject
struct _object PyObject
Definition: vtkMatplotlibMathTextUtilities.h:38
vtkMathTextUtilities::StringToPath
virtual bool StringToPath(const char *str, vtkPath *path, vtkTextProperty *tprop, int dpi)=0
Parse the MathText expression in str and fill path with a contour of the glyphs.
vtkImageData
topologically and geometrically regular array of data
Definition: vtkImageData.h:45
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:39
vtkMatplotlibMathTextUtilities::FontPropertiesClass
PyObject * FontPropertiesClass
Definition: vtkMatplotlibMathTextUtilities.h:127
vtkMatplotlibMathTextUtilities::PathParser
PyObject * PathParser
Definition: vtkMatplotlibMathTextUtilities.h:126
vtkMathTextUtilities::GetBoundingBox
virtual bool GetBoundingBox(vtkTextProperty *tprop, const char *str, int dpi, int bbox[4])=0
Determine the dimensions of the image that RenderString will produce for a given str,...
vtkTextProperty
represent text properties.
Definition: vtkTextProperty.h:39
vtkSetMacro
vtkSetMacro(IgnoreDriverBugs, bool)
Updates the extensions string.
vtkMathTextUtilities.h
vtkMathTextUtilities::New
static vtkMathTextUtilities * New()
This is a singleton pattern New.
vtkTextRenderer::Metrics
Definition: vtkTextRenderer.h:78
vtkMatplotlibMathTextUtilities::Interpreter
vtkPythonInterpreter * Interpreter
Definition: vtkMatplotlibMathTextUtilities.h:124
vtkMatplotlibMathTextUtilities::ScaleToPowerOfTwo
bool ScaleToPowerOfTwo
Definition: vtkMatplotlibMathTextUtilities.h:137