VTK
/Users/kitware/Dashboards/MyTests/VTK_BLD_Release_docs/Utilities/Doxygen/dox/Rendering/Matplotlib/vtkMatplotlibMathTextUtilities.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkMatplotlibMathTextUtilities.h
00005 
00006   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
00007   All rights reserved.
00008   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00009 
00010      This software is distributed WITHOUT ANY WARRANTY; without even
00011      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00012      PURPOSE.  See the above copyright notice for more information.
00013 
00014 =========================================================================*/
00030 #ifndef vtkMatplotlibMathTextUtilities_h
00031 #define vtkMatplotlibMathTextUtilities_h
00032 
00033 #include "vtkRenderingMatplotlibModule.h" // For export macro
00034 #include "vtkMathTextUtilities.h"
00035 
00036 struct _object;
00037 typedef struct _object PyObject;
00038 class vtkImageData;
00039 class vtkPath;
00040 class vtkPythonInterpreter;
00041 class vtkTextProperty;
00042 
00043 class VTKRENDERINGMATPLOTLIB_EXPORT vtkMatplotlibMathTextUtilities :
00044     public vtkMathTextUtilities
00045 {
00046 public:
00047   vtkTypeMacro(vtkMatplotlibMathTextUtilities, vtkMathTextUtilities);
00048   void PrintSelf(ostream& os, vtkIndent indent);
00049 
00050   static vtkMatplotlibMathTextUtilities *New();
00051 
00053 
00058   bool GetBoundingBox(vtkTextProperty *tprop, const char *str,
00059                       unsigned int dpi, int bbox[4]);
00061 
00062   bool GetMetrics(vtkTextProperty *tprop, const char *str,
00063                   unsigned int dpi, vtkTextRenderer::Metrics &metrics);
00064 
00066 
00074   bool RenderString(const char *str, vtkImageData *data, vtkTextProperty *tprop,
00075                     unsigned int dpi, int textDims[2] = NULL);
00077 
00082   bool StringToPath(const char *str, vtkPath *path, vtkTextProperty *tprop);
00083 
00085 
00088   vtkSetMacro(ScaleToPowerOfTwo, bool);
00089   vtkGetMacro(ScaleToPowerOfTwo, bool);
00091 
00092 protected:
00093   vtkMatplotlibMathTextUtilities();
00094   virtual ~vtkMatplotlibMathTextUtilities();
00095 
00096   bool InitializeMaskParser();
00097   bool InitializePathParser();
00098   bool InitializeFontPropertiesClass();
00099 
00100   bool CheckForError();
00101   bool CheckForError(PyObject *object);
00102 
00105   PyObject * GetFontProperties(vtkTextProperty *tprop);
00106 
00111   void CleanupPythonObjects();
00112 
00113   vtkPythonInterpreter* Interpreter;
00114   PyObject *MaskParser;
00115   PyObject *PathParser;
00116   PyObject *FontPropertiesClass;
00117 
00118   static void GetJustifiedBBox(int rows, int cols, vtkTextProperty *tprop,
00119                                int bbox[4]);
00120 
00121   // Rotate the 4 2D corner points by the specified angle (degrees) around the
00122   // origin and calculate the bounding box
00123   static void RotateCorners(double angleDeg, double corners[4][2],
00124                             double bbox[4]);
00125 
00127 
00128   enum Availablity
00129     {
00130     NOT_TESTED = 0,
00131     AVAILABLE,
00132     UNAVAILABLE
00133     };
00135 
00136   bool ScaleToPowerOfTwo;
00137   bool PrepareImageData(vtkImageData *data, int bbox[4]);
00138 
00139   // Function used to check MPL availability and update MPLMathTextAvailable.
00140   // This will do tests only the first time this method is called.
00141   static void CheckMPLAvailability();
00142 
00143 private:
00144   vtkMatplotlibMathTextUtilities(const vtkMatplotlibMathTextUtilities&); // Not implemented.
00145   void operator=(const vtkMatplotlibMathTextUtilities&); // Not implemented.
00146 
00147 
00148   static Availablity MPLMathTextAvailable;
00149 };
00150 
00151 #endif