VTK: Rendering/FreeType/vtkMathTextUtilities.h Source File

| VTK 9.3.1

vtkMathTextUtilities.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
15 #ifndef vtkMathTextUtilities_h
16 #define vtkMathTextUtilities_h
17
18 #include "vtkObject.h"
19 #include "vtkRenderingFreeTypeModule.h" // For export macro
20 #include "vtkTextRenderer.h" // for metrics
21
22 VTK_ABI_NAMESPACE_BEGIN
23 class vtkImageData;
24 class vtkPath;
25 class vtkTextProperty;
26 class vtkTextActor;
27 class vtkViewport;
28
29 //----------------------------------------------------------------------------
30 // Singleton cleanup
31
32 class VTKRENDERINGFREETYPE_EXPORT vtkMathTextUtilitiesCleanup
33 {
34 public:
35 vtkMathTextUtilitiesCleanup();
36 ~vtkMathTextUtilitiesCleanup();
37
38 private:
39 vtkMathTextUtilitiesCleanup(const vtkMathTextUtilitiesCleanup& other) = delete;
40 vtkMathTextUtilitiesCleanup& operator=(const vtkMathTextUtilitiesCleanup& rhs) = delete;
41 };
42
43 class VTKRENDERINGFREETYPE_EXPORT vtkMathTextUtilities : public vtkObject
44 {
45 public:
46 vtkTypeMacro(vtkMathTextUtilities, vtkObject);
47 void PrintSelf(ostream& os, vtkIndent indent) override;
48
52 virtual bool IsAvailable() { return false; } // Override in subclasses.
53
62 static vtkMathTextUtilities* New();
63
67 static vtkMathTextUtilities* GetInstance();
68
73 static void SetInstance(vtkMathTextUtilities* instance);
74
79 virtual bool GetBoundingBox(vtkTextProperty* tprop, const char* str, int dpi, int bbox[4]) = 0;
80
84 virtual bool GetMetrics(
85 vtkTextProperty* tprop, const char* str, int dpi, vtkTextRenderer::Metrics& metrics) = 0;
86
94 virtual bool RenderString(const char* str, vtkImageData* data, vtkTextProperty* tprop, int dpi,
95 int textDims[2] = nullptr) = 0;
96
101 virtual bool StringToPath(const char* str, vtkPath* path, vtkTextProperty* tprop, int dpi) = 0;
102
109 virtual int GetConstrainedFontSize(
110 const char* str, vtkTextProperty* tprop, int targetWidth, int targetHeight, int dpi);
111
113
118 virtual bool GetScaleToPowerOfTwo() = 0;
119 virtual void SetScaleToPowerOfTwo(bool scale) = 0;
121
122 protected:
123 vtkMathTextUtilities();
124 ~vtkMathTextUtilities() override;
125
126 private:
127 vtkMathTextUtilities(const vtkMathTextUtilities&) = delete;
128 void operator=(const vtkMathTextUtilities&) = delete;
129
131
134 static vtkMathTextUtilities* Instance;
135 static vtkMathTextUtilitiesCleanup Cleanup;
137 };
138
139 VTK_ABI_NAMESPACE_END
140 #endif
vtkImageData
topologically and geometrically regular array of data
Definition: vtkImageData.h:52
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:38
vtkMathTextUtilitiesCleanup
Definition: vtkMathTextUtilities.h:33
vtkMathTextUtilitiesCleanup::~vtkMathTextUtilitiesCleanup
~vtkMathTextUtilitiesCleanup()
vtkMathTextUtilitiesCleanup::vtkMathTextUtilitiesCleanup
vtkMathTextUtilitiesCleanup()
vtkMathTextUtilities
Abstract interface to equation rendering.
Definition: vtkMathTextUtilities.h:44
vtkMathTextUtilities::GetScaleToPowerOfTwo
virtual bool GetScaleToPowerOfTwo()=0
Set to true if the graphics implementation requires texture image dimensions to be a power of two.
vtkMathTextUtilities::GetInstance
static vtkMathTextUtilities * GetInstance()
Return the singleton instance with no reference counting.
vtkMathTextUtilities::GetConstrainedFontSize
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.
vtkMathTextUtilities::IsAvailable
virtual bool IsAvailable()
Returns true if mathtext rendering is available.
Definition: vtkMathTextUtilities.h:52
vtkMathTextUtilities::~vtkMathTextUtilities
~vtkMathTextUtilities() override
vtkMathTextUtilities::New
static vtkMathTextUtilities * New()
This is a singleton pattern New.
vtkMathTextUtilities::GetBoundingBox
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,...
vtkMathTextUtilities::GetMetrics
virtual bool GetMetrics(vtkTextProperty *tprop, const char *str, int dpi, vtkTextRenderer::Metrics &metrics)=0
Return the metrics for the rendered str, tprop, and dpi.
vtkMathTextUtilities::SetInstance
static void SetInstance(vtkMathTextUtilities *instance)
Supply a user defined instance.
vtkMathTextUtilities::RenderString
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.
vtkMathTextUtilities::vtkMathTextUtilities
vtkMathTextUtilities()
vtkMathTextUtilities::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkMathTextUtilities::SetScaleToPowerOfTwo
virtual void SetScaleToPowerOfTwo(bool scale)=0
Set to true if the graphics implementation requires texture image dimensions to be a power of two.
vtkMathTextUtilities::StringToPath
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.
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:61
vtkPath
concrete dataset representing a path defined by Bezier curves.
Definition: vtkPath.h:34
vtkTextActor
An actor that displays text.
Definition: vtkTextActor.h:55
vtkTextProperty
represent text properties.
Definition: vtkTextProperty.h:35
vtkViewport
abstract specification for Viewports
Definition: vtkViewport.h:54
vtkX3D::scale
@ scale
Definition: vtkX3D.h:229
vtkX3D::data
@ data
Definition: vtkX3D.h:315
vtkTextRenderer::Metrics
Definition: vtkTextRenderer.h:74
vtkObject.h
vtkTextRenderer.h