VTK  9.3.0
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
42 #ifndef vtkLabeledDataMapper_h
43 #define vtkLabeledDataMapper_h
44 
45 #include "vtkMapper2D.h"
46 #include "vtkRenderingLabelModule.h" // For export macro
47 
48 #include <cassert> // For assert macro
49 
50 VTK_ABI_NAMESPACE_BEGIN
51 class vtkDataObject;
52 class vtkDataSet;
53 class vtkTextMapper;
54 class vtkTextProperty;
55 class vtkTransform;
56 
57 #define VTK_LABEL_IDS 0
58 #define VTK_LABEL_SCALARS 1
59 #define VTK_LABEL_VECTORS 2
60 #define VTK_LABEL_NORMALS 3
61 #define VTK_LABEL_TCOORDS 4
62 #define VTK_LABEL_TENSORS 5
63 #define VTK_LABEL_FIELD_DATA 6
64 
65 class VTKRENDERINGLABEL_EXPORT vtkLabeledDataMapper : public vtkMapper2D
66 {
67 public:
73 
75  void PrintSelf(ostream& os, vtkIndent indent) override;
76 
78 
90  vtkSetStringMacro(LabelFormat);
91  vtkGetStringMacro(LabelFormat);
93 
95 
102  vtkSetMacro(LabeledComponent, int);
103  vtkGetMacro(LabeledComponent, int);
105 
107 
110  vtkSetMacro(ComponentSeparator, char);
111  vtkGetMacro(ComponentSeparator, char);
113 
115 
120  void SetFieldDataArray(int arrayIndex);
121  vtkGetMacro(FieldDataArray, int);
123 
125 
130  void SetFieldDataName(const char* arrayName);
131  vtkGetStringMacro(FieldDataName);
133 
137  virtual void SetInputData(vtkDataObject*);
138 
144 
146 
152  vtkSetMacro(LabelMode, int);
153  vtkGetMacro(LabelMode, int);
154  void SetLabelModeToLabelIds() { this->SetLabelMode(VTK_LABEL_IDS); }
155  void SetLabelModeToLabelScalars() { this->SetLabelMode(VTK_LABEL_SCALARS); }
156  void SetLabelModeToLabelVectors() { this->SetLabelMode(VTK_LABEL_VECTORS); }
157  void SetLabelModeToLabelNormals() { this->SetLabelMode(VTK_LABEL_NORMALS); }
158  void SetLabelModeToLabelTCoords() { this->SetLabelMode(VTK_LABEL_TCOORDS); }
159  void SetLabelModeToLabelTensors() { this->SetLabelMode(VTK_LABEL_TENSORS); }
160  void SetLabelModeToLabelFieldData() { this->SetLabelMode(VTK_LABEL_FIELD_DATA); }
162 
164 
175 
177 
180  void RenderOpaqueGeometry(vtkViewport* viewport, vtkActor2D* actor) override;
181  void RenderOverlay(vtkViewport* viewport, vtkActor2D* actor) override;
183 
188 
190 
193  vtkGetObjectMacro(Transform, vtkTransform);
196 
199  {
200  WORLD = 0,
201  DISPLAY = 1
203  };
204 
206 
210  vtkGetMacro(CoordinateSystem, int);
211  vtkSetClampMacro(CoordinateSystem, int, WORLD, DISPLAY);
212  void CoordinateSystemWorld() { this->SetCoordinateSystem(vtkLabeledDataMapper::WORLD); }
213  void CoordinateSystemDisplay() { this->SetCoordinateSystem(vtkLabeledDataMapper::DISPLAY); }
215 
219  vtkMTimeType GetMTime() override;
220 
222 
225  vtkGetMacro(NumberOfLabels, int);
227 
229 
232  void GetLabelPosition(int label, double pos[3])
233  {
234  assert("label index range" && label >= 0 && label < this->NumberOfLabels);
235  pos[0] = this->LabelPositions[3 * label];
236  pos[1] = this->LabelPositions[3 * label + 1];
237  pos[2] = this->LabelPositions[3 * label + 2];
238  }
240 
244  const char* GetLabelText(int label);
245 
246 protected:
249 
251 
252  char* LabelFormat;
258 
260 
262 
266  double* LabelPositions;
268 
270 
271  void AllocateLabels(int numLabels);
272  void BuildLabels();
274 
275  class Internals;
276  Internals* Implementation;
277 
278 private:
280  void operator=(const vtkLabeledDataMapper&) = delete;
281 };
282 
283 VTK_ABI_NAMESPACE_END
284 #endif
a actor that draws 2D data
Definition: vtkActor2D.h:35
general representation of visualization data
Definition: vtkDataObject.h:55
abstract class to specify dataset behavior
Definition: vtkDataSet.h:53
a simple class to control print indentation
Definition: vtkIndent.h:29
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
Definition: vtkTextMapper.h:40
represent text properties.
record modification and/or execution time
Definition: vtkTimeStamp.h:25
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:50
abstract specification for Viewports
Definition: vtkViewport.h:45
window superclass for vtkRenderWindow
Definition: vtkWindow.h:28
@ 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