VTK  9.6.20260614
vtkBatchedLabeledDataMapper.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
23
24#ifndef vtkBatchedLabeledDataMapper_h
25#define vtkBatchedLabeledDataMapper_h
26
28#include "vtkRenderingLabelModule.h" // For export macro
29#include "vtkWrappingHints.h" // For VTK_MARSHALMANUAL
30
31#include <memory> // For unique_ptr
32
33VTK_ABI_NAMESPACE_BEGIN
34class vtkDataSet;
35class vtkFloatArray;
36class vtkImageData;
37class vtkIntArray;
38class vtkPolyData;
39class vtkTextProperty;
40VTK_ABI_NAMESPACE_END
41
42VTK_ABI_NAMESPACE_BEGIN
43class VTKRENDERINGLABEL_EXPORT VTK_MARSHALMANUAL vtkBatchedLabeledDataMapper
45{
46public:
49 void PrintSelf(ostream& os, vtkIndent indent) override;
50
52
59 static constexpr int MaxTextProperties = 128;
60 static constexpr int GlyphAtlasPadding = 5;
61 static constexpr int GlyphAtlasColumnSize = 10;
63
65
72 void SetLabelTextProperty(vtkTextProperty* p, int type) override;
75
79 vtkSetStringMacro(FrameColorsName);
80 vtkGetStringMacro(FrameColorsName);
81
83
98
99
101
105 vtkSetClampMacro(TextAnchor, int, LowerLeft, Center);
106 vtkGetMacro(TextAnchor, int);
108
110
115 vtkSetVector2Macro(DisplayOffset, int);
116 vtkGetVector2Macro(DisplayOffset, int);
118
123
130
131protected:
134
136
138 void AllocateLabels(int numLabels) override;
139
141 void BuildLabels() override;
142
145
151 void MakeShaderArrays(int numCurLabels, const std::vector<std::string>&, vtkIntArray*,
152 vtkFloatArray*, const std::vector<bool>& visible);
153
158 virtual void UploadGlyphAtlas(vtkImageData* atlas);
159
163 virtual void ActivateGlyphTexture();
165
167
174 const float* GetBackgroundColors() const;
175 const int* GetFrameWidths() const;
176 const int* GetMaxGlyphHeights() const;
177 const int* GetDescenders() const;
179
185
186private:
188 void operator=(const vtkBatchedLabeledDataMapper&) = delete;
189
191 int DisplayOffset[2] = { 0, 0 };
192
193 char* FrameColorsName = nullptr;
194
195 class vtkInternals;
196 std::unique_ptr<vtkInternals> Impl;
197
198 struct vtkBatchedLabeledDataMapperFormatter;
199};
200VTK_ABI_NAMESPACE_END
201
202#endif
a actor that draws 2D data
Definition vtkActor2D.h:145
const int * GetFrameWidths() const
Accessors for backend helper use in SetMapperShaderParameters.
static constexpr int GlyphAtlasColumnSize
Compile-time limits shared by the base class and both backend shaders.
vtkTextProperty * GetLabelTextProperty() override
Set/Get the text property.
void BuildLabelsInternal(vtkDataSet *) override
Formats labels for one dataset and populates the glyph atlas and shader arrays.
void AllocateLabels(int numLabels) override
Tracks the high-water mark of labels seen so far; no per-label allocation is needed.
void ReleaseGraphicsResources(vtkWindow *) override
Releases any GPU resources held by backend subclasses.
vtkMTimeType GetMTime() override
Overridden to take into account LabelTextProperty's mtime.
const int * GetDescenders() const
Accessors for backend helper use in SetMapperShaderParameters.
virtual void DeactivateGlyphTexture()
vtkTextProperty * GetLabelTextProperty(int type) override
Set/Get the text property.
void RenderOpaqueGeometry(vtkViewport *, vtkActor2D *) override
No-op: backend subclasses override this to drive the render pipeline.
vtkPolyData * GetPreparedPolyData() const
Accessors for backend helper use in SetMapperShaderParameters.
static constexpr int GlyphAtlasPadding
Compile-time limits shared by the base class and both backend shaders.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
virtual void ActivateGlyphTexture()
Called before and after the helper renders to bind/unbind the atlas texture.
int FillInputPortInformation(int, vtkInformation *) override
Fill the input port information objects for this algorithm.
TextAnchorTypes
Anchor option for labels.
@ UpperRight
Uses the upper right corner.
@ RightEdge
Uses the right edge center.
@ LowerRight
Uses the lower right corner.
@ LowerLeft
Uses the lower left corner.
@ LowerEdge
Uses the lower edge center.
@ UpperEdge
Uses the upper edge center.
@ UpperLeft
Uses the upper left corner.
@ LeftEdge
Uses the left edge center.
~vtkBatchedLabeledDataMapper() override
vtkImageData * GetGlyphAtlas() const
Accessors for backend helper use in SetMapperShaderParameters.
void RenderOverlay(vtkViewport *, vtkActor2D *) override
No-op: all label drawing happens in RenderOpaqueGeometry.
const float * GetBackgroundColors() const
Accessors for backend helper use in SetMapperShaderParameters.
const int * GetMaxGlyphHeights() const
Accessors for backend helper use in SetMapperShaderParameters.
void BuildLabels() override
Calls the superclass pipeline, then refreshes text-property attribute arrays.
static constexpr int MaxTextProperties
Compile-time limits shared by the base class and both backend shaders.
void MakeShaderArrays(int numCurLabels, const std::vector< std::string > &, vtkIntArray *, vtkFloatArray *, const std::vector< bool > &visible)
Converts formatted label strings into per-glyph vertex attributes (glyph extents, character offsets,...
void SetLabelTextProperty(vtkTextProperty *p) override
Set/Get the text property.
static vtkBatchedLabeledDataMapper * New()
virtual void UploadGlyphAtlas(vtkImageData *atlas)
Called by BuildLabels when the glyph atlas image has been rebuilt or updated.
void SetLabelTextProperty(vtkTextProperty *p, int type) override
Set/Get the text property.
void UpdateRenderWindowDPI(int dpi)
Called by backend subclasses from RenderOpaqueGeometry to propagate the render window DPI before Buil...
abstract class to specify dataset behavior
Definition vtkDataSet.h:166
dynamic, self-adjusting array of float
topologically and geometrically regular array of data
a simple class to control print indentation
Definition vtkIndent.h:108
Store vtkAlgorithm input/output information.
dynamic, self-adjusting array of int
concrete dataset represents vertices, lines, polygons, and triangle strips
represent text properties.
abstract specification for Viewports
Definition vtkViewport.h:66
window superclass for vtkRenderWindow
Definition vtkWindow.h:61
vtkTypeUInt32 vtkMTimeType
Definition vtkType.h:318
#define VTK_MARSHALMANUAL