VTK  9.3.20240327
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
111 #ifndef vtkLabeledDataMapper_h
112 #define vtkLabeledDataMapper_h
113 
114 #include "vtkMapper2D.h"
115 #include "vtkRenderingLabelModule.h" // For export macro
116 
117 #include <cassert> // For assert macro
118 
119 VTK_ABI_NAMESPACE_BEGIN
120 class vtkDataObject;
121 class vtkDataSet;
122 class vtkTextMapper;
123 class vtkTextProperty;
124 class vtkTransform;
125 
126 #define VTK_LABEL_IDS 0
127 #define VTK_LABEL_SCALARS 1
128 #define VTK_LABEL_VECTORS 2
129 #define VTK_LABEL_NORMALS 3
130 #define VTK_LABEL_TCOORDS 4
131 #define VTK_LABEL_TENSORS 5
132 #define VTK_LABEL_FIELD_DATA 6
133 
134 class VTKRENDERINGLABEL_EXPORT vtkLabeledDataMapper : public vtkMapper2D
135 {
136 public:
142 
144  void PrintSelf(ostream& os, vtkIndent indent) override;
145 
147 
159  vtkSetStringMacro(LabelFormat);
160  vtkGetStringMacro(LabelFormat);
162 
164 
171  vtkSetMacro(LabeledComponent, int);
172  vtkGetMacro(LabeledComponent, int);
174 
176 
179  vtkSetMacro(ComponentSeparator, char);
180  vtkGetMacro(ComponentSeparator, char);
182 
184 
189  void SetFieldDataArray(int arrayIndex);
190  vtkGetMacro(FieldDataArray, int);
192 
194 
199  void SetFieldDataName(const char* arrayName);
200  vtkGetStringMacro(FieldDataName);
202 
206  virtual void SetInputData(vtkDataObject*);
207 
213 
215 
221  vtkSetMacro(LabelMode, int);
222  vtkGetMacro(LabelMode, int);
223  void SetLabelModeToLabelIds() { this->SetLabelMode(VTK_LABEL_IDS); }
224  void SetLabelModeToLabelScalars() { this->SetLabelMode(VTK_LABEL_SCALARS); }
225  void SetLabelModeToLabelVectors() { this->SetLabelMode(VTK_LABEL_VECTORS); }
226  void SetLabelModeToLabelNormals() { this->SetLabelMode(VTK_LABEL_NORMALS); }
227  void SetLabelModeToLabelTCoords() { this->SetLabelMode(VTK_LABEL_TCOORDS); }
228  void SetLabelModeToLabelTensors() { this->SetLabelMode(VTK_LABEL_TENSORS); }
229  void SetLabelModeToLabelFieldData() { this->SetLabelMode(VTK_LABEL_FIELD_DATA); }
231 
233 
244 
246 
249  void RenderOpaqueGeometry(vtkViewport* viewport, vtkActor2D* actor) override;
250  void RenderOverlay(vtkViewport* viewport, vtkActor2D* actor) override;
252 
257 
259 
262  vtkGetObjectMacro(Transform, vtkTransform);
265 
268  {
269  WORLD = 0,
270  DISPLAY = 1
272  };
273 
275 
279  vtkGetMacro(CoordinateSystem, int);
280  vtkSetClampMacro(CoordinateSystem, int, WORLD, DISPLAY);
281  void CoordinateSystemWorld() { this->SetCoordinateSystem(vtkLabeledDataMapper::WORLD); }
282  void CoordinateSystemDisplay() { this->SetCoordinateSystem(vtkLabeledDataMapper::DISPLAY); }
284 
288  vtkMTimeType GetMTime() override;
289 
291 
294  vtkGetMacro(NumberOfLabels, int);
296 
298 
301  void GetLabelPosition(int label, double pos[3])
302  {
303  assert("label index range" && label >= 0 && label < this->NumberOfLabels);
304  pos[0] = this->LabelPositions[3 * label];
305  pos[1] = this->LabelPositions[3 * label + 1];
306  pos[2] = this->LabelPositions[3 * label + 2];
307  }
309 
313  const char* GetLabelText(int label);
314 
315 protected:
318 
320 
321  char* LabelFormat;
327 
329 
331 
335  double* LabelPositions;
337 
339 
340  void AllocateLabels(int numLabels);
341  void BuildLabels();
343 
344  class Internals;
345  Internals* Implementation;
346 
347 private:
349  void operator=(const vtkLabeledDataMapper&) = delete;
350 };
351 
352 VTK_ABI_NAMESPACE_END
353 #endif
a actor that draws 2D data
Definition: vtkActor2D.h:144
general representation of visualization data
abstract class to specify dataset behavior
Definition: vtkDataSet.h:165
a simple class to control print indentation
Definition: vtkIndent.h:108
Store vtkAlgorithm input/output information.
draw text labels at dataset points
void SetFieldDataName(const char *arrayName)
Set/Get the name of the field data array to label.
virtual void SetLabelTextProperty(vtkTextProperty *p, int type)
Set/Get the text property.
void RenderOpaqueGeometry(vtkViewport *viewport, vtkActor2D *actor) override
Draw the text to the screen at each input point.
void CoordinateSystemWorld()
Set/get the coordinate system used for output labels.
void SetLabelModeToLabelIds()
Specify which data to plot: IDs, scalars, vectors, normals, texture coords, tensors,...
virtual void SetInputData(vtkDataObject *)
Set the input dataset to the mapper.
void SetLabelModeToLabelVectors()
Specify which data to plot: IDs, scalars, vectors, normals, texture coords, tensors,...
void SetLabelModeToLabelNormals()
Specify which data to plot: IDs, scalars, vectors, normals, texture coords, tensors,...
void SetLabelModeToLabelTensors()
Specify which data to plot: IDs, scalars, vectors, normals, texture coords, tensors,...
vtkDataSet * GetInput()
Use GetInputDataObject() to get the input data object for composite datasets.
vtkTextMapper ** TextMappers
void ReleaseGraphicsResources(vtkWindow *) override
Release any graphics resources that are being consumed by this actor.
void AllocateLabels(int numLabels)
virtual void SetLabelTextProperty(vtkTextProperty *p)
Set/Get the text property.
int FillInputPortInformation(int, vtkInformation *) override
Fill the input port information objects for this algorithm.
void SetLabelModeToLabelTCoords()
Specify which data to plot: IDs, scalars, vectors, normals, texture coords, tensors,...
void SetLabelModeToLabelScalars()
Specify which data to plot: IDs, scalars, vectors, normals, texture coords, tensors,...
void SetFieldDataArray(int arrayIndex)
Set/Get the field data array to label.
virtual vtkTextProperty * GetLabelTextProperty()
Set/Get the text property.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void SetLabelModeToLabelFieldData()
Specify which data to plot: IDs, scalars, vectors, normals, texture coords, tensors,...
vtkMTimeType GetMTime() override
Return the modified time for this object.
void RenderOverlay(vtkViewport *viewport, vtkActor2D *actor) override
Draw the text to the screen at each input point.
~vtkLabeledDataMapper() override
virtual vtkTextProperty * GetLabelTextProperty(int type)
Set/Get the text property.
static vtkLabeledDataMapper * New()
Instantiate object with %%-#6.3g label format.
void SetTransform(vtkTransform *t)
The transform to apply to the labels before mapping to 2D.
void BuildLabelsInternal(vtkDataSet *)
void GetLabelPosition(int label, double pos[3])
Return the position of the requested label.
void CoordinateSystemDisplay()
Set/get the coordinate system used for output labels.
Coordinates
Coordinate systems that output dataset may use.
@ DISPLAY
Output 2-D display coordinates for each label anchor (3 components but only 2 are significant).
@ WORLD
Output 3-D world-space coordinates for each label anchor.
const char * GetLabelText(int label)
Return the text for the requested label.
abstract class specifies interface for objects which render 2D actors
Definition: vtkMapper2D.h:25
2D text annotation
represent text properties.
record modification and/or execution time
Definition: vtkTimeStamp.h:44
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:159
abstract specification for Viewports
Definition: vtkViewport.h:64
window superclass for vtkRenderWindow
Definition: vtkWindow.h:47
@ Transform
Definition: vtkX3D.h:41
@ type
Definition: vtkX3D.h:516
#define VTK_LABEL_TENSORS
#define VTK_LABEL_TCOORDS
#define VTK_LABEL_VECTORS
#define VTK_LABEL_SCALARS
#define VTK_LABEL_FIELD_DATA
#define VTK_LABEL_IDS
#define VTK_LABEL_NORMALS
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:270