VTK: Rendering/Label/vtkLabeledDataMapper.h Source File

| VTK 9.3.1

vtkLabeledDataMapper.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
51 #ifndef vtkLabeledDataMapper_h
52 #define vtkLabeledDataMapper_h
53
54 #include "vtkMapper2D.h"
55 #include "vtkRenderingLabelModule.h" // For export macro
56
57 #include <cassert> // For assert macro
58
59 VTK_ABI_NAMESPACE_BEGIN
60 class vtkDataObject;
61 class vtkDataSet;
62 class vtkTextMapper;
63 class vtkTextProperty;
64 class vtkTransform;
65
66 #define VTK_LABEL_IDS 0
67 #define VTK_LABEL_SCALARS 1
68 #define VTK_LABEL_VECTORS 2
69 #define VTK_LABEL_NORMALS 3
70 #define VTK_LABEL_TCOORDS 4
71 #define VTK_LABEL_TENSORS 5
72 #define VTK_LABEL_FIELD_DATA 6
73
74 class VTKRENDERINGLABEL_EXPORT vtkLabeledDataMapper : public vtkMapper2D
75 {
76 public:
81 static vtkLabeledDataMapper* New();
82
83 vtkTypeMacro(vtkLabeledDataMapper, vtkMapper2D);
84 void PrintSelf(ostream& os, vtkIndent indent) override;
85
87
99 vtkSetStringMacro(LabelFormat);
100 vtkGetStringMacro(LabelFormat);
102
104
111 vtkSetMacro(LabeledComponent, int);
112 vtkGetMacro(LabeledComponent, int);
114
116
119 vtkSetMacro(ComponentSeparator, char);
120 vtkGetMacro(ComponentSeparator, char);
122
124
129 void SetFieldDataArray(int arrayIndex);
130 vtkGetMacro(FieldDataArray, int);
132
134
139 void SetFieldDataName(const char* arrayName);
140 vtkGetStringMacro(FieldDataName);
142
146 virtual void SetInputData(vtkDataObject*);
147
152 vtkDataSet* GetInput();
153
155
161 vtkSetMacro(LabelMode, int);
162 vtkGetMacro(LabelMode, int);
163 void SetLabelModeToLabelIds() { this->SetLabelMode(VTK_LABEL_IDS); }
164 void SetLabelModeToLabelScalars() { this->SetLabelMode(VTK_LABEL_SCALARS); }
165 void SetLabelModeToLabelVectors() { this->SetLabelMode(VTK_LABEL_VECTORS); }
166 void SetLabelModeToLabelNormals() { this->SetLabelMode(VTK_LABEL_NORMALS); }
167 void SetLabelModeToLabelTCoords() { this->SetLabelMode(VTK_LABEL_TCOORDS); }
168 void SetLabelModeToLabelTensors() { this->SetLabelMode(VTK_LABEL_TENSORS); }
169 void SetLabelModeToLabelFieldData() { this->SetLabelMode(VTK_LABEL_FIELD_DATA); }
171
173
179 virtual void SetLabelTextProperty(vtkTextProperty* p) { this->SetLabelTextProperty(p, 0); }
180 virtual vtkTextProperty* GetLabelTextProperty() { return this->GetLabelTextProperty(0); }
181 virtual void SetLabelTextProperty(vtkTextProperty* p, int type);
182 virtual vtkTextProperty* GetLabelTextProperty(int type);
184
186
189 void RenderOpaqueGeometry(vtkViewport* viewport, vtkActor2D* actor) override;
190 void RenderOverlay(vtkViewport* viewport, vtkActor2D* actor) override;
192
196 void ReleaseGraphicsResources(vtkWindow*) override;
197
199
202 vtkGetObjectMacro(Transform, vtkTransform);
203 void SetTransform(vtkTransform* t);
205
207 enum Coordinates
208 {
209 WORLD = 0,
210 DISPLAY = 1
212 };
213
215
219 vtkGetMacro(CoordinateSystem, int);
220 vtkSetClampMacro(CoordinateSystem, int, WORLD, DISPLAY);
221 void CoordinateSystemWorld() { this->SetCoordinateSystem(vtkLabeledDataMapper::WORLD); }
222 void CoordinateSystemDisplay() { this->SetCoordinateSystem(vtkLabeledDataMapper::DISPLAY); }
224
228 vtkMTimeType GetMTime() override;
229
231
234 vtkGetMacro(NumberOfLabels, int);
236
238
241 void GetLabelPosition(int label, double pos[3])
242 {
243 assert("label index range" && label >= 0 && label < this->NumberOfLabels);
244 pos[0] = this->LabelPositions[3 * label];
245 pos[1] = this->LabelPositions[3 * label + 1];
246 pos[2] = this->LabelPositions[3 * label + 2];
247 }
249
253 const char* GetLabelText(int label);
254
255 protected:
256 vtkLabeledDataMapper();
257 ~vtkLabeledDataMapper() override;
258
259 vtkDataSet* Input;
260
261 char* LabelFormat;
262 int LabelMode;
263 int LabeledComponent;
264 int FieldDataArray;
265 char* FieldDataName;
266 int CoordinateSystem;
267
268 char ComponentSeparator;
269
270 vtkTimeStamp BuildTime;
271
272 int NumberOfLabels;
273 int NumberOfLabelsAllocated;
274 vtkTextMapper** TextMappers;
275 double* LabelPositions;
276 vtkTransform* Transform;
277
278 int FillInputPortInformation(int, vtkInformation*) override;
279
280 void AllocateLabels(int numLabels);
281 void BuildLabels();
282 void BuildLabelsInternal(vtkDataSet*);
283
284 class Internals;
285 Internals* Implementation;
286
287 private:
288 vtkLabeledDataMapper(const vtkLabeledDataMapper&) = delete;
289 void operator=(const vtkLabeledDataMapper&) = delete;
290 };
291
292 VTK_ABI_NAMESPACE_END
293 #endif
vtkActor2D
a actor that draws 2D data
Definition: vtkActor2D.h:44
vtkDataObject
general representation of visualization data
Definition: vtkDataObject.h:64
vtkDataSet
abstract class to specify dataset behavior
Definition: vtkDataSet.h:62
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:38
vtkInformation
Store vtkAlgorithm input/output information.
Definition: vtkInformation.h:72
vtkLabeledDataMapper
draw text labels at dataset points
Definition: vtkLabeledDataMapper.h:75
vtkLabeledDataMapper::SetFieldDataName
void SetFieldDataName(const char *arrayName)
Set/Get the name of the field data array to label.
vtkLabeledDataMapper::SetLabelTextProperty
virtual void SetLabelTextProperty(vtkTextProperty *p, int type)
Set/Get the text property.
vtkLabeledDataMapper::Implementation
Internals * Implementation
Definition: vtkLabeledDataMapper.h:284
vtkLabeledDataMapper::RenderOpaqueGeometry
void RenderOpaqueGeometry(vtkViewport *viewport, vtkActor2D *actor) override
Draw the text to the screen at each input point.
vtkLabeledDataMapper::CoordinateSystemWorld
void CoordinateSystemWorld()
Set/get the coordinate system used for output labels.
Definition: vtkLabeledDataMapper.h:221
vtkLabeledDataMapper::vtkLabeledDataMapper
vtkLabeledDataMapper()
vtkLabeledDataMapper::BuildLabels
void BuildLabels()
vtkLabeledDataMapper::SetLabelModeToLabelIds
void SetLabelModeToLabelIds()
Specify which data to plot: IDs, scalars, vectors, normals, texture coords, tensors,...
Definition: vtkLabeledDataMapper.h:163
vtkLabeledDataMapper::SetInputData
virtual void SetInputData(vtkDataObject *)
Set the input dataset to the mapper.
vtkLabeledDataMapper::SetLabelModeToLabelVectors
void SetLabelModeToLabelVectors()
Specify which data to plot: IDs, scalars, vectors, normals, texture coords, tensors,...
Definition: vtkLabeledDataMapper.h:165
vtkLabeledDataMapper::NumberOfLabelsAllocated
int NumberOfLabelsAllocated
Definition: vtkLabeledDataMapper.h:273
vtkLabeledDataMapper::Transform
vtkTransform * Transform
Definition: vtkLabeledDataMapper.h:276
vtkLabeledDataMapper::SetLabelModeToLabelNormals
void SetLabelModeToLabelNormals()
Specify which data to plot: IDs, scalars, vectors, normals, texture coords, tensors,...
Definition: vtkLabeledDataMapper.h:166
vtkLabeledDataMapper::SetLabelModeToLabelTensors
void SetLabelModeToLabelTensors()
Specify which data to plot: IDs, scalars, vectors, normals, texture coords, tensors,...
Definition: vtkLabeledDataMapper.h:168
vtkLabeledDataMapper::GetInput
vtkDataSet * GetInput()
Use GetInputDataObject() to get the input data object for composite datasets.
vtkLabeledDataMapper::TextMappers
vtkTextMapper ** TextMappers
Definition: vtkLabeledDataMapper.h:274
vtkLabeledDataMapper::ReleaseGraphicsResources
void ReleaseGraphicsResources(vtkWindow *) override
Release any graphics resources that are being consumed by this actor.
vtkLabeledDataMapper::AllocateLabels
void AllocateLabels(int numLabels)
vtkLabeledDataMapper::SetLabelTextProperty
virtual void SetLabelTextProperty(vtkTextProperty *p)
Set/Get the text property.
Definition: vtkLabeledDataMapper.h:179
vtkLabeledDataMapper::FillInputPortInformation
int FillInputPortInformation(int, vtkInformation *) override
Fill the input port information objects for this algorithm.
vtkLabeledDataMapper::SetLabelModeToLabelTCoords
void SetLabelModeToLabelTCoords()
Specify which data to plot: IDs, scalars, vectors, normals, texture coords, tensors,...
Definition: vtkLabeledDataMapper.h:167
vtkLabeledDataMapper::ComponentSeparator
char ComponentSeparator
Definition: vtkLabeledDataMapper.h:268
vtkLabeledDataMapper::SetLabelModeToLabelScalars
void SetLabelModeToLabelScalars()
Specify which data to plot: IDs, scalars, vectors, normals, texture coords, tensors,...
Definition: vtkLabeledDataMapper.h:164
vtkLabeledDataMapper::SetFieldDataArray
void SetFieldDataArray(int arrayIndex)
Set/Get the field data array to label.
vtkLabeledDataMapper::LabeledComponent
int LabeledComponent
Definition: vtkLabeledDataMapper.h:263
vtkLabeledDataMapper::GetLabelTextProperty
virtual vtkTextProperty * GetLabelTextProperty()
Set/Get the text property.
Definition: vtkLabeledDataMapper.h:180
vtkLabeledDataMapper::LabelFormat
char * LabelFormat
Definition: vtkLabeledDataMapper.h:261
vtkLabeledDataMapper::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkLabeledDataMapper::SetLabelModeToLabelFieldData
void SetLabelModeToLabelFieldData()
Specify which data to plot: IDs, scalars, vectors, normals, texture coords, tensors,...
Definition: vtkLabeledDataMapper.h:169
vtkLabeledDataMapper::FieldDataArray
int FieldDataArray
Definition: vtkLabeledDataMapper.h:264
vtkLabeledDataMapper::GetMTime
vtkMTimeType GetMTime() override
Return the modified time for this object.
vtkLabeledDataMapper::FieldDataName
char * FieldDataName
Definition: vtkLabeledDataMapper.h:265
vtkLabeledDataMapper::LabelPositions
double * LabelPositions
Definition: vtkLabeledDataMapper.h:275
vtkLabeledDataMapper::NumberOfLabels
int NumberOfLabels
Definition: vtkLabeledDataMapper.h:272
vtkLabeledDataMapper::CoordinateSystem
int CoordinateSystem
Definition: vtkLabeledDataMapper.h:266
vtkLabeledDataMapper::RenderOverlay
void RenderOverlay(vtkViewport *viewport, vtkActor2D *actor) override
Draw the text to the screen at each input point.
vtkLabeledDataMapper::~vtkLabeledDataMapper
~vtkLabeledDataMapper() override
vtkLabeledDataMapper::Input
vtkDataSet * Input
Definition: vtkLabeledDataMapper.h:259
vtkLabeledDataMapper::GetLabelTextProperty
virtual vtkTextProperty * GetLabelTextProperty(int type)
Set/Get the text property.
vtkLabeledDataMapper::New
static vtkLabeledDataMapper * New()
Instantiate object with %%-#6.3g label format.
vtkLabeledDataMapper::LabelMode
int LabelMode
Definition: vtkLabeledDataMapper.h:262
vtkLabeledDataMapper::SetTransform
void SetTransform(vtkTransform *t)
The transform to apply to the labels before mapping to 2D.
vtkLabeledDataMapper::BuildTime
vtkTimeStamp BuildTime
Definition: vtkLabeledDataMapper.h:270
vtkLabeledDataMapper::BuildLabelsInternal
void BuildLabelsInternal(vtkDataSet *)
vtkLabeledDataMapper::GetLabelPosition
void GetLabelPosition(int label, double pos[3])
Return the position of the requested label.
Definition: vtkLabeledDataMapper.h:241
vtkLabeledDataMapper::CoordinateSystemDisplay
void CoordinateSystemDisplay()
Set/get the coordinate system used for output labels.
Definition: vtkLabeledDataMapper.h:222
vtkLabeledDataMapper::Coordinates
Coordinates
Coordinate systems that output dataset may use.
Definition: vtkLabeledDataMapper.h:208
vtkLabeledDataMapper::DISPLAY
@ DISPLAY
Output 2-D display coordinates for each label anchor (3 components but only 2 are significant).
Definition: vtkLabeledDataMapper.h:210
vtkLabeledDataMapper::WORLD
@ WORLD
Output 3-D world-space coordinates for each label anchor.
Definition: vtkLabeledDataMapper.h:209
vtkLabeledDataMapper::GetLabelText
const char * GetLabelText(int label)
Return the text for the requested label.
vtkMapper2D
abstract class specifies interface for objects which render 2D actors
Definition: vtkMapper2D.h:25
vtkTextMapper
2D text annotation
Definition: vtkTextMapper.h:49
vtkTextProperty
represent text properties.
Definition: vtkTextProperty.h:35
vtkTimeStamp
record modification and/or execution time
Definition: vtkTimeStamp.h:34
vtkTransform
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:59
vtkViewport
abstract specification for Viewports
Definition: vtkViewport.h:54
vtkWindow
window superclass for vtkRenderWindow
Definition: vtkWindow.h:37
vtkX3D::Transform
@ Transform
Definition: vtkX3D.h:41
vtkX3D::type
@ type
Definition: vtkX3D.h:516
VTK_LABEL_TENSORS
#define VTK_LABEL_TENSORS
Definition: vtkLabeledDataMapper.h:71
VTK_LABEL_TCOORDS
#define VTK_LABEL_TCOORDS
Definition: vtkLabeledDataMapper.h:70
VTK_LABEL_VECTORS
#define VTK_LABEL_VECTORS
Definition: vtkLabeledDataMapper.h:68
VTK_LABEL_SCALARS
#define VTK_LABEL_SCALARS
Definition: vtkLabeledDataMapper.h:67
VTK_LABEL_FIELD_DATA
#define VTK_LABEL_FIELD_DATA
Definition: vtkLabeledDataMapper.h:72
VTK_LABEL_IDS
#define VTK_LABEL_IDS
Definition: vtkLabeledDataMapper.h:66
VTK_LABEL_NORMALS
#define VTK_LABEL_NORMALS
Definition: vtkLabeledDataMapper.h:69
vtkMapper2D.h
vtkMTimeType
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:270