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 
164 
167  static Availability MPLMathTextAvailable;
168 };
170 
171 #endif
virtual bool IsAvailable()
Returns true if mathtext rendering is available.
concrete dataset representing a path defined by Bezier curves.
Definition: vtkPath.h:35
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.
virtual bool GetMetrics(vtkTextProperty *tprop, const char *str, int dpi, vtkTextRenderer::Metrics &metrics)=0
Return the metrics for the rendered str, tprop, and dpi.
Access to MatPlotLib MathText rendering.
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.
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, tprop, and dpi.
a simple class to control print indentation
Definition: vtkIndent.h:39
void PrintSelf(ostream &os, vtkIndent indent)
Methods invoked by print to print information about the object including superclasses.
topologically and geometrically regular array of data
Definition: vtkImageData.h:45
represent text properties.
vtkSetMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
Abstract interface to equation rendering.
static vtkMathTextUtilities * New()
This is a singleton pattern New.
struct _object PyObject