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 
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 
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
vtkMatplotlibMathTextUtilities::New
static vtkMatplotlibMathTextUtilities * New()
vtkMatplotlibMathTextUtilities::GetFontProperties
PyObject * GetFontProperties(vtkTextProperty *tprop)
Returns a matplotlib.font_manager.FontProperties PyObject, initialized from the vtkTextProperty tprop...
vtkMatplotlibMathTextUtilities
Access to MatPlotLib MathText rendering.
Definition: vtkMatplotlibMathTextUtilities.h:46
vtkMatplotlibMathTextUtilities::GetBoundingBox
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...
vtkMatplotlibMathTextUtilities::InitializeMaskParser
bool InitializeMaskParser()
vtkX3D::data
@ data
Definition: vtkX3D.h:315
vtkPath
concrete dataset representing a path defined by Bezier curves.
Definition: vtkPath.h:36
vtkMatplotlibMathTextUtilities::MaskParser
PyObject * MaskParser
Definition: vtkMatplotlibMathTextUtilities.h:125
vtkMathTextUtilities
Abstract interface to equation rendering.
Definition: vtkMathTextUtilities.h:55
vtkMatplotlibMathTextUtilities::~vtkMatplotlibMathTextUtilities
virtual ~vtkMatplotlibMathTextUtilities()
PyObject
struct _object PyObject
Definition: vtkMatplotlibMathTextUtilities.h:38
vtkImageData
topologically and geometrically regular array of data
Definition: vtkImageData.h:46
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:40
vtkMatplotlibMathTextUtilities::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent)
Methods invoked by print to print information about the object including superclasses.
vtkMatplotlibMathTextUtilities::CheckForError
bool CheckForError(PyObject *object)
vtkMatplotlibMathTextUtilities::FontPropertiesClass
PyObject * FontPropertiesClass
Definition: vtkMatplotlibMathTextUtilities.h:127
vtkMatplotlibMathTextUtilities::RotateCorners
static void RotateCorners(double angleDeg, double corners[4][2], double bbox[4])
vtkMatplotlibMathTextUtilities::PathParser
PyObject * PathParser
Definition: vtkMatplotlibMathTextUtilities.h:126
vtkTextProperty
represent text properties.
Definition: vtkTextProperty.h:40
vtkSetMacro
vtkSetMacro(IgnoreDriverBugs, bool)
Updates the extensions string.
vtkMatplotlibMathTextUtilities::InitializePathParser
bool InitializePathParser()
vtkMatplotlibMathTextUtilities::GetMetrics
bool GetMetrics(vtkTextProperty *tprop, const char *str, int dpi, vtkTextRenderer::Metrics &metrics)
Return the metrics for the rendered str, tprop, and dpi.
vtkMatplotlibMathTextUtilities::CheckForError
bool CheckForError()
vtkMatplotlibMathTextUtilities::RenderString
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.
vtkMatplotlibMathTextUtilities::StringToPath
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.
vtkMatplotlibMathTextUtilities::vtkMatplotlibMathTextUtilities
vtkMatplotlibMathTextUtilities()
vtkMatplotlibMathTextUtilities::InitializeFontPropertiesClass
bool InitializeFontPropertiesClass()
vtkMatplotlibMathTextUtilities::CleanupPythonObjects
void CleanupPythonObjects()
Cleanup and destroy any python objects.
vtkMathTextUtilities.h
vtkMatplotlibMathTextUtilities::IsAvailable
virtual bool IsAvailable()
Returns true if mathtext rendering is available.
vtkTextRenderer::Metrics
Definition: vtkTextRenderer.h:79
vtkMatplotlibMathTextUtilities::PrepareImageData
bool PrepareImageData(vtkImageData *data, int bbox[4])
vtkMatplotlibMathTextUtilities::Interpreter
vtkPythonInterpreter * Interpreter
Definition: vtkMatplotlibMathTextUtilities.h:124
vtkMatplotlibMathTextUtilities::ScaleToPowerOfTwo
bool ScaleToPowerOfTwo
Definition: vtkMatplotlibMathTextUtilities.h:137
vtkMatplotlibMathTextUtilities::GetJustifiedBBox
static void GetJustifiedBBox(int rows, int cols, vtkTextProperty *tprop, int bbox[4])