VTK  9.7.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 "vtkLabeledDatatypeDefinitions.h" // For Data type Definitions
46 #include "vtkMapper2D.h"
47 #include "vtkRenderingLabelModule.h" // For export macro
48 #include "vtkSmartPointer.h" // For vtkSmartPointer
49 #include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
50 
51 #include <cassert> // For assert macro
52 #include <memory> // For std::unique_ptr
53 #include <vector> // For std::vector
54 
55 VTK_ABI_NAMESPACE_BEGIN
56 class vtkDataArray;
57 class vtkDataObject;
58 class vtkDataSet;
60 class vtkIntArray;
61 class vtkStringArray;
63 class vtkTextMapper;
64 class vtkTextProperty;
65 class vtkTransform;
66 
67 class VTKRENDERINGLABEL_EXPORT VTK_MARSHALAUTO vtkLabeledDataMapper : public vtkMapper2D
68 {
69 public:
74  static vtkLabeledDataMapper* New();
75 
77  void PrintSelf(ostream& os, vtkIndent indent) override;
78 
80 
91  vtkSetStringMacro(LabelFormat);
92  vtkGetStringMacro(LabelFormat);
94 
96 
103  vtkSetMacro(LabeledComponent, int);
104  vtkGetMacro(LabeledComponent, int);
106 
108 
111  vtkSetMacro(ComponentSeparator, char);
112  vtkGetMacro(ComponentSeparator, char);
114 
116 
121  vtkSetClampMacro(FieldDataArray, int, 0, VTK_INT_MAX);
122  vtkGetMacro(FieldDataArray, int);
124 
126 
131  vtkSetStringMacro(FieldDataName)
132  vtkGetStringMacro(FieldDataName);
134 
138  virtual void SetInputData(vtkDataObject*);
139 
144  vtkDataSet* GetInput();
145 
147 
153  vtkSetMacro(LabelMode, int);
154  vtkGetMacro(LabelMode, int);
155  void SetLabelModeToLabelIds() { this->SetLabelMode(VTK_LABEL_IDS); }
156  void SetLabelModeToLabelScalars() { this->SetLabelMode(VTK_LABEL_SCALARS); }
157  void SetLabelModeToLabelVectors() { this->SetLabelMode(VTK_LABEL_VECTORS); }
158  void SetLabelModeToLabelNormals() { this->SetLabelMode(VTK_LABEL_NORMALS); }
159  void SetLabelModeToLabelTCoords() { this->SetLabelMode(VTK_LABEL_TCOORDS); }
160  void SetLabelModeToLabelTensors() { this->SetLabelMode(VTK_LABEL_TENSORS); }
161  void SetLabelModeToLabelFieldData() { this->SetLabelMode(VTK_LABEL_FIELD_DATA); }
163 
165 
173  virtual void SetLabelTextProperty(vtkTextProperty* p, int type);
174  virtual vtkTextProperty* GetLabelTextProperty(int type);
176 
178 
181  void RenderOpaqueGeometry(vtkViewport* viewport, vtkActor2D* actor) override;
182  void RenderOverlay(vtkViewport* viewport, vtkActor2D* actor) override;
184 
188  void ReleaseGraphicsResources(vtkWindow*) override;
189 
191 
194  vtkGetObjectMacro(Transform, vtkTransform);
195  void SetTransform(vtkTransform* t);
197 
200  {
201  WORLD = 0,
202  DISPLAY = 1
203  };
205 
207 
211  vtkGetMacro(CoordinateSystem, int);
212  vtkSetClampMacro(CoordinateSystem, int, WORLD, DISPLAY);
213  void CoordinateSystemWorld() { this->SetCoordinateSystem(vtkLabeledDataMapper::WORLD); }
214  void CoordinateSystemDisplay() { this->SetCoordinateSystem(vtkLabeledDataMapper::DISPLAY); }
216 
220  vtkMTimeType GetMTime() override;
221 
223 
226  vtkGetMacro(NumberOfLabels, int);
228 
230 
233  void GetLabelPosition(int label, double pos[3])
234  {
235  assert("label index range" && label >= 0 && label < this->NumberOfLabels);
236  pos[0] = this->LabelPositions[3 * label];
237  pos[1] = this->LabelPositions[3 * label + 1];
238  pos[2] = this->LabelPositions[3 * label + 2];
239  }
241 
245  const char* GetLabelText(int label);
246 
247 protected:
249  ~vtkLabeledDataMapper() override;
250 
252 
253  char* LabelFormat;
259 
261 
263 
266  std::vector<vtkSmartPointer<vtkTextMapper>> TextMappers;
267  std::vector<double> LabelPositions;
269 
270  int FillInputPortInformation(int, vtkInformation*) override;
271 
272  virtual void AllocateLabels(int numLabels);
273  virtual void BuildLabels();
274  virtual void BuildLabelsInternal(vtkDataSet*);
275 
281  vtkLabeledFormatterInput ResolveLabeledFormatterInput(
282  vtkDataSetAttributes* pd, int numItems, vtkDataObject* inputObj);
283 
284  class Internals;
285  std::unique_ptr<Internals> Implementation;
286 
287 private:
289  void operator=(const vtkLabeledDataMapper&) = delete;
290 
291  struct vtkLabeledDataMapperFormatter;
292 };
293 
294 VTK_ABI_NAMESPACE_END
295 #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.
Resolved label input for one dataset/graph, produced by vtkLabeledDataMapper::ResolveLabeledFormatter...
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:318
virtual void RenderOverlay(vtkViewport *, vtkActor2D *)
Definition: vtkMapper2D.h:31
abstract specification for Viewports
Definition: vtkViewport.h:46
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:56
void SetLabelModeToLabelTensors()
Specify which data to plot: IDs, scalars, vectors, normals, texture coords, tensors, or field data.
#define VTK_INT_MAX
Definition: vtkType.h:192
void GetLabelPosition(int label, double pos[3])
Return the position of the requested label.
a actor that draws 2D data
Definition: vtkActor2D.h:35
record modification and/or execution time
Definition: vtkTimeStamp.h:24
#define VTK_LABEL_IDS
std::unique_ptr< Internals > Implementation
a vtkAbstractArray subclass for strings
Coordinates
Coordinate systems that output dataset may use.
std::vector< vtkSmartPointer< vtkTextMapper > > TextMappers
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:50
std::vector< double > LabelPositions
#define VTK_LABEL_TCOORDS
2D text annotation
Definition: vtkTextMapper.h:39
draw text labels at dataset points
#define VTK_LABEL_NORMALS
void SetLabelModeToLabelVectors()
Specify which data to plot: IDs, scalars, vectors, normals, texture coords, tensors, or field data.
window superclass for vtkRenderWindow
Definition: vtkWindow.h:41
void CoordinateSystemDisplay()
Set/get the coordinate system used for output labels.
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:35
#define VTK_LABEL_TENSORS
#define VTK_LABEL_SCALARS
a simple class to control print indentation
Definition: vtkIndent.h:28
#define VTK_LABEL_FIELD_DATA
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:44
represent and manipulate attribute data in a dataset
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_VECTORS
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()
#define VTK_MARSHALAUTO
virtual void RenderOpaqueGeometry(vtkViewport *, vtkActor2D *)
Definition: vtkMapper2D.h:32
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:55
abstract class specifies interface for objects which render 2D actors
Definition: vtkMapper2D.h:25
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)...