VTK  9.2.6
vtkMathTextUtilities.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkMathTextUtilities.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 =========================================================================*/
27 #ifndef vtkMathTextUtilities_h
28 #define vtkMathTextUtilities_h
29 
30 #include "vtkObject.h"
31 #include "vtkRenderingFreeTypeModule.h" // For export macro
32 #include "vtkTextRenderer.h" // for metrics
33 
34 class vtkImageData;
35 class vtkPath;
36 class vtkTextProperty;
37 class vtkTextActor;
38 class vtkViewport;
39 
40 //----------------------------------------------------------------------------
41 // Singleton cleanup
42 
43 class VTKRENDERINGFREETYPE_EXPORT vtkMathTextUtilitiesCleanup
44 {
45 public:
48 
49 private:
51  vtkMathTextUtilitiesCleanup& operator=(const vtkMathTextUtilitiesCleanup& rhs) = delete;
52 };
53 
54 class VTKRENDERINGFREETYPE_EXPORT vtkMathTextUtilities : public vtkObject
55 {
56 public:
58  void PrintSelf(ostream& os, vtkIndent indent) override;
59 
63  virtual bool IsAvailable() { return false; } // Override in subclasses.
64 
74 
79 
84  static void SetInstance(vtkMathTextUtilities* instance);
85 
90  virtual bool GetBoundingBox(vtkTextProperty* tprop, const char* str, int dpi, int bbox[4]) = 0;
91 
95  virtual bool GetMetrics(
96  vtkTextProperty* tprop, const char* str, int dpi, vtkTextRenderer::Metrics& metrics) = 0;
97 
105  virtual bool RenderString(const char* str, vtkImageData* data, vtkTextProperty* tprop, int dpi,
106  int textDims[2] = nullptr) = 0;
107 
112  virtual bool StringToPath(const char* str, vtkPath* path, vtkTextProperty* tprop, int dpi) = 0;
113 
121  const char* str, vtkTextProperty* tprop, int targetWidth, int targetHeight, int dpi);
122 
124 
129  virtual bool GetScaleToPowerOfTwo() = 0;
130  virtual void SetScaleToPowerOfTwo(bool scale) = 0;
132 
133 protected:
136 
137 private:
139  void operator=(const vtkMathTextUtilities&) = delete;
140 
142 
145  static vtkMathTextUtilities* Instance;
146  static vtkMathTextUtilitiesCleanup Cleanup;
148 };
149 
150 #endif
topologically and geometrically regular array of data
Definition: vtkImageData.h:163
a simple class to control print indentation
Definition: vtkIndent.h:119
Abstract interface to equation rendering.
virtual bool GetScaleToPowerOfTwo()=0
Set to true if the graphics implementation requires texture image dimensions to be a power of two.
static vtkMathTextUtilities * GetInstance()
Return the singleton instance with no reference counting.
virtual int GetConstrainedFontSize(const char *str, vtkTextProperty *tprop, int targetWidth, int targetHeight, int dpi)
This function returns the font size (in points) required to fit the string in the target rectangle.
virtual bool IsAvailable()
Returns true if mathtext rendering is available.
~vtkMathTextUtilities() override
static vtkMathTextUtilities * New()
This is a singleton pattern New.
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,...
virtual bool GetMetrics(vtkTextProperty *tprop, const char *str, int dpi, vtkTextRenderer::Metrics &metrics)=0
Return the metrics for the rendered str, tprop, and dpi.
static void SetInstance(vtkMathTextUtilities *instance)
Supply a user defined instance.
virtual bool RenderString(const char *str, vtkImageData *data, vtkTextProperty *tprop, int dpi, int textDims[2]=nullptr)=0
Render the given string str into the vtkImageData data with a resolution of dpi.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
virtual void SetScaleToPowerOfTwo(bool scale)=0
Set to true if the graphics implementation requires texture image dimensions to be a power of two.
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.
abstract base class for most VTK objects
Definition: vtkObject.h:82
concrete dataset representing a path defined by Bezier curves.
Definition: vtkPath.h:36
An actor that displays text.
Definition: vtkTextActor.h:166
represent text properties.
abstract specification for Viewports
Definition: vtkViewport.h:56
@ scale
Definition: vtkX3D.h:235
@ data
Definition: vtkX3D.h:321