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
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:
72  static vtkLabeledDataMapper* New();
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 
143  vtkDataSet* GetInput();
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 
172  virtual void SetLabelTextProperty(vtkTextProperty* p, int type);
173  virtual vtkTextProperty* GetLabelTextProperty(int type);
175 
177 
180  void RenderOpaqueGeometry(vtkViewport* viewport, vtkActor2D* actor) override;
181  void RenderOverlay(vtkViewport* viewport, vtkActor2D* actor) override;
183 
187  void ReleaseGraphicsResources(vtkWindow*) override;
188 
190 
193  vtkGetObjectMacro(Transform, vtkTransform);
194  void SetTransform(vtkTransform* t);
196 
199  {
200  WORLD = 0,
201  DISPLAY = 1
202  };
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:
248  ~vtkLabeledDataMapper() override;
249 
251 
252  char* LabelFormat;
258 
260 
262 
266  double* LabelPositions;
268 
269  int FillInputPortInformation(int, vtkInformation*) override;
270 
271  void AllocateLabels(int numLabels);
272  void BuildLabels();
273  void BuildLabelsInternal(vtkDataSet*);
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
void SetLabelModeToLabelFieldData()
Specify which data to plot: IDs, scalars, vectors, normals, texture coords, tensors, or field data.
void CoordinateSystemWorld()
Set/get the coordinate system used for output labels.
#define VTK_LABEL_NORMALS
#define VTK_LABEL_VECTORS
void SetLabelModeToLabelTCoords()
Specify which data to plot: IDs, scalars, vectors, normals, texture coords, tensors, or field data.
Store vtkAlgorithm input/output information.
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:270
virtual void RenderOverlay(vtkViewport *, vtkActor2D *)
Definition: vtkMapper2D.h:30
abstract specification for Viewports
Definition: vtkViewport.h:44
vtkMTimeType GetMTime() override
Override Modifiedtime as we have added Clipping planes.
Output 3-D world-space coordinates for each label anchor.
abstract class to specify dataset behavior
Definition: vtkDataSet.h:52
void SetLabelModeToLabelTensors()
Specify which data to plot: IDs, scalars, vectors, normals, texture coords, tensors, or field data.
#define VTK_LABEL_IDS
vtkTextMapper ** TextMappers
void GetLabelPosition(int label, double pos[3])
Return the position of the requested label.
a actor that draws 2D data
Definition: vtkActor2D.h:34
record modification and/or execution time
Definition: vtkTimeStamp.h:24
Coordinates
Coordinate systems that output dataset may use.
#define VTK_LABEL_SCALARS
#define VTK_LABEL_TCOORDS
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:49
void SetLabelModeToLabelIds()
Specify which data to plot: IDs, scalars, vectors, normals, texture coords, tensors, or field data.
2D text annotation
Definition: vtkTextMapper.h:39
draw text labels at dataset points
void SetLabelModeToLabelVectors()
Specify which data to plot: IDs, scalars, vectors, normals, texture coords, tensors, or field data.
window superclass for vtkRenderWindow
Definition: vtkWindow.h:27
void CoordinateSystemDisplay()
Set/get the coordinate system used for output labels.
a simple class to control print indentation
Definition: vtkIndent.h:28
represent text properties.
void SetLabelModeToLabelScalars()
Specify which data to plot: IDs, scalars, vectors, normals, texture coords, tensors, or field data.
virtual int FillInputPortInformation(int port, vtkInformation *info)
Fill the input port information objects for this algorithm.
#define VTK_LABEL_TENSORS
#define VTK_LABEL_FIELD_DATA
void SetLabelModeToLabelNormals()
Specify which data to plot: IDs, scalars, vectors, normals, texture coords, tensors, or field data.
virtual void ReleaseGraphicsResources(vtkWindow *)
Release any graphics resources that are being consumed by this mapper.
virtual vtkTextProperty * GetLabelTextProperty()
Set/Get the text property.
static vtkAlgorithm * New()
virtual void RenderOpaqueGeometry(vtkViewport *, vtkActor2D *)
Definition: vtkMapper2D.h:31
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
general representation of visualization data
Definition: vtkDataObject.h:54
abstract class specifies interface for objects which render 2D actors
Definition: vtkMapper2D.h:24
virtual void SetLabelTextProperty(vtkTextProperty *p)
Set/Get the text property.
Output 2-D display coordinates for each label anchor (3 components but only 2 are significant)...