43 #ifndef vtkTextRenderer_h
44 #define vtkTextRenderer_h
47 #include "vtkRenderingCoreModule.h"
59 class RegularExpression;
160 vtkSetMacro(DefaultBackend,
int);
161 vtkGetMacro(DefaultBackend,
int);
189 return this->GetBoundingBoxInternal(tprop, str, bbox, dpi, backend);
192 int backend = Default)
194 return this->GetBoundingBoxInternal(tprop, str, bbox, dpi, backend);
205 int backend = Default)
207 return this->GetMetricsInternal(tprop, str, metrics, dpi, backend);
210 int backend = Default)
212 return this->GetMetricsInternal(tprop, str, metrics, dpi, backend);
232 int textDims[2],
int dpi,
int backend = Default)
234 return this->RenderStringInternal(tprop, str,
data, textDims, dpi, backend);
237 int textDims[2],
int dpi,
int backend = Default)
239 return this->RenderStringInternal(tprop, str,
data, textDims, dpi, backend);
251 int targetHeight,
int dpi,
int backend = Default)
253 return this->GetConstrainedFontSizeInternal(
254 str, tprop, targetWidth, targetHeight, dpi, backend);
257 int targetHeight,
int dpi,
int backend = Default)
259 return this->GetConstrainedFontSizeInternal(
260 str, tprop, targetWidth, targetHeight, dpi, backend);
275 return this->StringToPathInternal(tprop, str, path, dpi, backend);
278 int backend = Default)
280 return this->StringToPathInternal(tprop, str, path, dpi, backend);
309 Metrics& metrics,
int dpi,
int backend) = 0;
315 int targetWidth,
int targetHeight,
int dpi,
int backend) = 0;
317 int targetWidth,
int targetHeight,
int dpi,
int backend) = 0;
topologically and geometrically regular array of data
a simple class to control print indentation
abstract base class for most VTK objects
concrete dataset representing a path defined by Bezier curves.
Wrapper around std::string to keep symbols short.
represent text properties.
~vtkTextRendererCleanup()
Interface for generating images and path data from string data, using multiple backends.
int DefaultBackend
The backend to use when none is specified.
virtual int GetConstrainedFontSizeInternal(const vtkStdString &str, vtkTextProperty *tprop, int targetWidth, int targetHeight, int dpi, int backend)=0
bool RenderString(vtkTextProperty *tprop, const vtkUnicodeString &str, vtkImageData *data, int textDims[2], int dpi, int backend=Default)
bool StringToPath(vtkTextProperty *tprop, const vtkStdString &str, vtkPath *path, int dpi, int backend=Default)
Given a text property and a string, this function populates the vtkPath path with the outline of the ...
virtual int DetectBackend(const vtkUnicodeString &str)
virtual bool MathTextIsSupported()
virtual bool GetMetricsInternal(vtkTextProperty *tprop, const vtkUnicodeString &str, Metrics &metrics, int dpi, int backend)=0
static vtkTextRenderer * GetInstance()
Return the singleton instance with no reference counting.
static void SetInstance(vtkTextRenderer *instance)
Set the singleton instance.
int GetConstrainedFontSize(const vtkStdString &str, vtkTextProperty *tprop, int targetWidth, int targetHeight, int dpi, int backend=Default)
This function returns the font size (in points) and sets the size in tprop that is required to fit th...
bool StringToPath(vtkTextProperty *tprop, const vtkUnicodeString &str, vtkPath *path, int dpi, int backend=Default)
bool RenderString(vtkTextProperty *tprop, const vtkStdString &str, vtkImageData *data, int textDims[2], int dpi, int backend=Default)
Given a text property and a string, this function initializes the vtkImageData *data and renders it i...
virtual bool GetBoundingBoxInternal(vtkTextProperty *tprop, const vtkUnicodeString &str, int bbox[4], int dpi, int backend)=0
bool GetBoundingBox(vtkTextProperty *tprop, const vtkStdString &str, int bbox[4], int dpi, int backend=Default)
Given a text property and a string, get the bounding box {xmin, xmax, ymin, ymax} of the rendered str...
virtual void CleanUpFreeTypeEscapes(vtkUnicodeString &str)
static vtkTextRenderer * New()
This is a singleton pattern New.
static vtkTextRendererCleanup Cleanup
void SetScaleToPowerOfTwo(bool scale)
Set to true if the graphics implementation requires texture image dimensions to be a power of two.
virtual bool StringToPathInternal(vtkTextProperty *tprop, const vtkUnicodeString &str, vtkPath *path, int dpi, int backend)=0
virtual void SetScaleToPowerOfTwoInternal(bool scale)=0
static vtkTextRenderer * Instance
The singleton instance and the singleton cleanup instance.
vtksys::RegularExpression * MathTextRegExp
virtual bool GetBoundingBoxInternal(vtkTextProperty *tprop, const vtkStdString &str, int bbox[4], int dpi, int backend)=0
Virtual methods for concrete implementations of the public methods.
virtual bool RenderStringInternal(vtkTextProperty *tprop, const vtkStdString &str, vtkImageData *data, int textDims[2], int dpi, int backend)=0
Backend
Available backends.
virtual bool RenderStringInternal(vtkTextProperty *tprop, const vtkUnicodeString &str, vtkImageData *data, int textDims[2], int dpi, int backend)=0
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
bool GetMetrics(vtkTextProperty *tprop, const vtkUnicodeString &str, Metrics &metrics, int dpi, int backend=Default)
virtual bool FreeTypeIsSupported()
Test for availability of various backends.
virtual bool GetMetricsInternal(vtkTextProperty *tprop, const vtkStdString &str, Metrics &metrics, int dpi, int backend)=0
vtksys::RegularExpression * MathTextRegExp2
bool GetMetrics(vtkTextProperty *tprop, const vtkStdString &str, Metrics &metrics, int dpi, int backend=Default)
Given a text property and a string, get some metrics for the rendered string.
virtual bool StringToPathInternal(vtkTextProperty *tprop, const vtkStdString &str, vtkPath *path, int dpi, int backend)=0
virtual void CleanUpFreeTypeEscapes(vtkStdString &str)
Replace all instances of "\$" with "$".
virtual int DetectBackend(const vtkStdString &str)
Determine the appropriate back end needed to render the given string.
int GetConstrainedFontSize(const vtkUnicodeString &str, vtkTextProperty *tprop, int targetWidth, int targetHeight, int dpi, int backend=Default)
virtual int GetConstrainedFontSizeInternal(const vtkUnicodeString &str, vtkTextProperty *tprop, int targetWidth, int targetHeight, int dpi, int backend)=0
~vtkTextRenderer() override
bool GetBoundingBox(vtkTextProperty *tprop, const vtkUnicodeString &str, int bbox[4], int dpi, int backend=Default)
String class that stores Unicode text.
Some derived classes for the different vectors commonly used.
vtkVector2i Descent
Vectors representing the rotated ascent and descent of the text.
vtkVector2i Ascent
Vectors representing the rotated ascent and descent of the text.
Metrics()
Construct a Metrics object with all members initialized to 0.
vtkVector2i TopLeft
The corners of the rendered text (or background, if applicable), in pixels.
vtkTuple< int, 4 > BoundingBox
The axis-aligned bounding box of the rendered text and background, in pixels.