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 =========================================================================*/
30 #ifndef vtkMatplotlibMathTextUtilities_h
31 #define vtkMatplotlibMathTextUtilities_h
32 
33 #include "vtkRenderingMatplotlibModule.h" // For export macro
34 #include "vtkMathTextUtilities.h"
35 
36 struct _object;
37 typedef struct _object PyObject;
38 class vtkImageData;
39 class vtkPath;
40 class vtkPythonInterpreter;
41 class vtkTextProperty;
42 
43 class VTKRENDERINGMATPLOTLIB_EXPORT vtkMatplotlibMathTextUtilities :
45 {
46 public:
48  void PrintSelf(ostream& os, vtkIndent indent);
49 
51 
52  virtual bool IsAvailable();
53 
55 
60  bool GetBoundingBox(vtkTextProperty *tprop, const char *str, int dpi,
61  int bbox[4]);
63 
64  bool GetMetrics(vtkTextProperty *tprop, const char *str, int dpi,
65  vtkTextRenderer::Metrics &metrics);
66 
68 
76  bool RenderString(const char *str, vtkImageData *data, vtkTextProperty *tprop,
77  int dpi, int textDims[2] = NULL);
79 
81 
85  bool StringToPath(const char *str, vtkPath *path, vtkTextProperty *tprop,
86  int dpi);
88 
90 
93  vtkSetMacro(ScaleToPowerOfTwo, bool);
94  vtkGetMacro(ScaleToPowerOfTwo, bool);
96 
97 protected:
100 
101  bool InitializeMaskParser();
102  bool InitializePathParser();
103  bool InitializeFontPropertiesClass();
104 
105  bool CheckForError();
106  bool CheckForError(PyObject *object);
107 
110  PyObject * GetFontProperties(vtkTextProperty *tprop);
111 
116  void CleanupPythonObjects();
117 
118  vtkPythonInterpreter* Interpreter;
122 
123  static void GetJustifiedBBox(int rows, int cols, vtkTextProperty *tprop,
124  int bbox[4]);
125 
126  // Rotate the 4 2D corner points by the specified angle (degrees) around the
127  // origin and calculate the bounding box
128  static void RotateCorners(double angleDeg, double corners[4][2],
129  double bbox[4]);
130 
132  bool PrepareImageData(vtkImageData *data, int bbox[4]);
133 
134 private:
136  void operator=(const vtkMatplotlibMathTextUtilities&); // Not implemented.
137 
139 
141  enum Availability
142  {
143  NOT_TESTED = 0,
144  AVAILABLE,
145  UNAVAILABLE
146  };
148 
153  static Availability CheckMPLAvailability();
154 
156 
157  static Availability MPLMathTextAvailable;
158 };
160 
161 #endif
concrete dataset representing a path defined by Bezier curves.
Definition: vtkPath.h:34
virtual bool RenderString(const char *str, vtkImageData *data, vtkTextProperty *tprop, int dpi, int textDims[2]=NULL)=0
virtual bool GetMetrics(vtkTextProperty *tprop, const char *str, int dpi, vtkTextRenderer::Metrics &metrics)=0
Access to MatPlotLib MathText rendering.
virtual bool StringToPath(const char *str, vtkPath *path, vtkTextProperty *tprop, int dpi)=0
virtual bool GetBoundingBox(vtkTextProperty *tprop, const char *str, int dpi, int bbox[4])=0
a simple class to control print indentation
Definition: vtkIndent.h:38
void PrintSelf(ostream &os, vtkIndent indent)
topologically and geometrically regular array of data
Definition: vtkImageData.h:44
represent text properties.
Abstract interface to equation rendering.
static vtkMathTextUtilities * New()
struct _object PyObject