VTK  9.7.20261203
vtkAnariOverlays.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
3
24
25#ifndef vtkAnariOverlays_h
26#define vtkAnariOverlays_h
27
28#include "vtkRenderingAnariCoreModule.h" // For export macro
29#include "vtkSystemIncludes.h" // For VTK_ARIAL
30
31#include <array> // For std::array
32#include <cstdint> // For std::uint8_t
33#include <functional> // For std::function
34#include <optional> // For std::optional
35#include <string> // For std::string
36#include <string_view> // For std::string_view
37#include <vector> // For std::vector
38
39namespace vtkAnariOverlays
40{
41VTK_ABI_NAMESPACE_BEGIN
42
49constexpr int ReferenceDPI = 72;
50
57{
58 int FullWidth = 0;
59 int FullHeight = 0;
60 int OffsetX = 0; // tile origin within the full viewport, in pixels
61 int OffsetY = 0;
62};
63
68{
69 std::uint8_t* Data = nullptr;
70 int Width = 0;
71 int Height = 0;
73};
74
76{
77 float R = 0.f;
78 float G = 0.f;
79 float B = 0.f;
80 float A = 1.f;
81};
82
84{
85 RGBAColor Color{ 1.f, 1.f, 1.f, 1.f };
86 float Opacity = 1.f;
87 float PixelSize = 14.f; // before the context's DPIScale is applied
88 bool Bold = false;
89 bool Italic = false;
90 int FontFamily = VTK_ARIAL; // VTK_ARIAL, VTK_COURIER, VTK_TIMES or VTK_FONT_FILE
91 std::string FontFile; // used with VTK_FONT_FILE
92 bool Shadow = false;
93 RGBAColor ShadowColor{ 0.f, 0.f, 0.f, 1.f };
94 std::array<int, 2> ShadowOffset{ 1, -1 }; // pixels, y up
95};
96
103{
104 int Width = 0;
105 int Height = 0;
106 std::vector<std::uint8_t> Coverage; // Width * Height, row 0 at the top
107};
108
115 std::function<GlyphRun(std::string_view text, const TextStyle& style, float pixelSize)>;
116
118{
120 // Rasterizes text; empty uses FreeTypeGlyphRun. Tests substitute a provider
121 // with known glyph boxes so layout checks don't depend on the font.
123 float DPIScale = 1.f; // multiplies text sizes, line widths and margins
124};
125
126//------------------------------------------------------------------------------
127// Text
128
134GlyphRun FreeTypeGlyphRun(std::string_view text, const TextStyle& style, float pixelSize);
135
136VTK_ABI_NAMESPACE_END
137} // namespace vtkAnariOverlays
138
139#endif
140// VTK-HeaderTest-Exclude: vtkAnariOverlays.h
GlyphRun FreeTypeGlyphRun(std::string_view text, const TextStyle &style, float pixelSize)
The default glyph provider: rasterizes text with vtkFreeTypeTools, using the style's font family,...
std::function< GlyphRun(std::string_view text, const TextStyle &style, float pixelSize)> GlyphProvider
Rasterizes text into a coverage bitmap.
constexpr int ReferenceDPI
The DPI at which overlays are drawn unscaled.
An 8-bit coverage bitmap for a run of text, trimmed to its drawn pixels, row 0 at the TOP.
std::vector< std::uint8_t > Coverage
A tightly packed RGBA8 image.
std::array< int, 2 > ShadowOffset
Where an image sits inside the full logical viewport.
#define VTK_ARIAL