VTK
vtkLabeledDataMapper.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkLabeledDataMapper.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
46 #ifndef vtkLabeledDataMapper_h
47 #define vtkLabeledDataMapper_h
48 
49 #include "vtkRenderingLabelModule.h" // For export macro
50 #include "vtkMapper2D.h"
51 
52 #include <cassert> // For assert macro
53 
54 class vtkDataObject;
55 class vtkDataSet;
56 class vtkTextMapper;
57 class vtkTextProperty;
58 class vtkTransform;
59 
60 #define VTK_LABEL_IDS 0
61 #define VTK_LABEL_SCALARS 1
62 #define VTK_LABEL_VECTORS 2
63 #define VTK_LABEL_NORMALS 3
64 #define VTK_LABEL_TCOORDS 4
65 #define VTK_LABEL_TENSORS 5
66 #define VTK_LABEL_FIELD_DATA 6
67 
68 class VTKRENDERINGLABEL_EXPORT vtkLabeledDataMapper : public vtkMapper2D
69 {
70 public:
75  static vtkLabeledDataMapper *New();
76 
78  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
79 
81 
93  vtkSetStringMacro(LabelFormat);
94  vtkGetStringMacro(LabelFormat);
96 
98 
105  vtkSetMacro(LabeledComponent,int);
106  vtkGetMacro(LabeledComponent,int);
108 
110 
115  void SetFieldDataArray(int arrayIndex);
116  vtkGetMacro(FieldDataArray,int);
118 
120 
125  void SetFieldDataName(const char *arrayName);
126  vtkGetStringMacro(FieldDataName);
128 
132  virtual void SetInputData(vtkDataObject*);
133 
138  vtkDataSet *GetInput();
139 
141 
147  vtkSetMacro(LabelMode, int);
148  vtkGetMacro(LabelMode, int);
149  void SetLabelModeToLabelIds() {this->SetLabelMode(VTK_LABEL_IDS);};
150  void SetLabelModeToLabelScalars() {this->SetLabelMode(VTK_LABEL_SCALARS);};
151  void SetLabelModeToLabelVectors() {this->SetLabelMode(VTK_LABEL_VECTORS);};
152  void SetLabelModeToLabelNormals() {this->SetLabelMode(VTK_LABEL_NORMALS);};
153  void SetLabelModeToLabelTCoords() {this->SetLabelMode(VTK_LABEL_TCOORDS);};
154  void SetLabelModeToLabelTensors() {this->SetLabelMode(VTK_LABEL_TENSORS);};
156  {this->SetLabelMode(VTK_LABEL_FIELD_DATA);};
158 
160 
167  { this->SetLabelTextProperty(p, 0); }
169  { return this->GetLabelTextProperty(0); }
170  virtual void SetLabelTextProperty(vtkTextProperty *p, int type);
171  virtual vtkTextProperty* GetLabelTextProperty(int type);
173 
175 
178  void RenderOpaqueGeometry(vtkViewport* viewport, vtkActor2D* actor) VTK_OVERRIDE;
179  void RenderOverlay(vtkViewport* viewport, vtkActor2D* actor) VTK_OVERRIDE;
181 
185  void ReleaseGraphicsResources(vtkWindow *) VTK_OVERRIDE;
186 
188 
191  vtkGetObjectMacro(Transform, vtkTransform);
192  void SetTransform(vtkTransform* t);
194 
197  {
198  WORLD=0,
199  DISPLAY=1
200  };
201 
203 
207  vtkGetMacro(CoordinateSystem,int);
208  vtkSetClampMacro(CoordinateSystem,int,WORLD,DISPLAY);
209  void CoordinateSystemWorld() { this->SetCoordinateSystem( vtkLabeledDataMapper::WORLD ); }
210  void CoordinateSystemDisplay() { this->SetCoordinateSystem( vtkLabeledDataMapper::DISPLAY ); }
212 
216  vtkMTimeType GetMTime() VTK_OVERRIDE;
217 
219 
222  vtkGetMacro(NumberOfLabels, int)
224 
226 
229  void GetLabelPosition(int label, double pos[3])
230  {
231  assert("label index range" && label >= 0 && label < this->NumberOfLabels);
232  pos[0] = this->LabelPositions[3 * label];
233  pos[1] = this->LabelPositions[3 * label + 1];
234  pos[2] = this->LabelPositions[3 * label + 2];
235  }
237 
241  const char *GetLabelText(int label);
242 
243 protected:
245  ~vtkLabeledDataMapper() VTK_OVERRIDE;
246 
247  vtkDataSet *Input;
248 
249  char *LabelFormat;
250  int LabelMode;
251  int LabeledComponent;
252  int FieldDataArray;
253  char *FieldDataName;
254  int CoordinateSystem;
255 
257 
258  int NumberOfLabels;
259  int NumberOfLabelsAllocated;
260  vtkTextMapper **TextMappers;
261  double* LabelPositions;
263 
264  int FillInputPortInformation(int, vtkInformation*) VTK_OVERRIDE;
265 
266  void AllocateLabels(int numLabels);
267  void BuildLabels();
268  void BuildLabelsInternal(vtkDataSet*);
269 
270  class Internals;
271  Internals* Implementation;
272 
273 private:
274  vtkLabeledDataMapper(const vtkLabeledDataMapper&) VTK_DELETE_FUNCTION;
275  void operator=(const vtkLabeledDataMapper&) VTK_DELETE_FUNCTION;
276 };
277 
278 #endif
279 
void SetLabelModeToLabelFieldData()
Specify which data to plot: IDs, scalars, vectors, normals, texture coords, tensors, or field data.
vtkTimeStamp BuildTime
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:300
virtual void RenderOverlay(vtkViewport *, vtkActor2D *)
Definition: vtkMapper2D.h:41
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:56
void SetLabelModeToLabelTensors()
Specify which data to plot: IDs, scalars, vectors, normals, texture coords, tensors, or field data.
#define VTK_LABEL_IDS
a actor that draws 2D data
Definition: vtkActor2D.h:39
record modification and/or execution time
Definition: vtkTimeStamp.h:32
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:54
void SetLabelModeToLabelIds()
Specify which data to plot: IDs, scalars, vectors, normals, texture coords, tensors, or field data.
2D text annotation
Definition: vtkTextMapper.h:47
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:34
void CoordinateSystemDisplay()
Set/get the coordinate system used for output labels.
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkGetStringMacro(ExtensionsString)
Returns a string listing all available extensions.
represent text properties.
void SetLabelModeToLabelScalars()
Specify which data to plot: IDs, scalars, vectors, normals, texture coords, tensors, or field data.
vtkSetMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
#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:42
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:58
abstract class specifies interface for objects which render 2D actors
Definition: vtkMapper2D.h:35
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)...
Transform
Definition: ADIOSDefs.h:39