File: vtkIconGlyphFilter.h

package info (click to toggle)
vtk7 7.1.1%2Bdfsg1-12
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 125,776 kB
  • sloc: cpp: 1,539,582; ansic: 106,521; python: 78,038; tcl: 47,013; xml: 8,142; yacc: 5,040; java: 4,439; perl: 3,132; lex: 1,926; sh: 1,500; makefile: 122; objc: 83
file content (196 lines) | stat: -rw-r--r-- 6,744 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
/*=========================================================================

  Program:   Visualization Toolkit
  Module:    vtkIconGlyphFilter.h

  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
  All rights reserved.
  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.

     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notice for more information.

=========================================================================*/
/**
 * @class   vtkIconGlyphFilter
 * @brief   Filter that generates a polydata consisting of
 * quads with texture coordinates referring to a set of icons within a sheet
 * of icons.
 *
 * vtkIconGlyphFilter takes in a vtkPointSet where each point corresponds to
 * the center of an icon. Scalar integer data must also be set to give each
 * point an icon index. This index is a zero based row major index into an
 * image that contains a grid of icons (each icon is the same size). You must
 * also specify 1) the size of the icon in the icon sheet (in pixels), 2) the
 * size of the icon sheet (in pixels), and 3) the display size of each icon
 * (again in display coordinates, or pixels).
 *
 * Various other parameters are used to control how this data is combined. If
 * UseIconSize is true then the DisplaySize is ignored. If PassScalars is true,
 * then the scalar index information is passed to the output. Also, there is an
 * optional IconScale array which, if UseIconScaling is on, will scale each icon
 * independently.
 *
 * @sa
 * vtkPolyDataAlgorithm vtkGlyph3D vtkGlyph2D
*/

#ifndef vtkIconGlyphFilter_h
#define vtkIconGlyphFilter_h

#include "vtkFiltersGeneralModule.h" // For export macro
#include "vtkPolyDataAlgorithm.h"

#define VTK_ICON_GRAVITY_TOP_RIGHT     1
#define VTK_ICON_GRAVITY_TOP_CENTER    2
#define VTK_ICON_GRAVITY_TOP_LEFT      3
#define VTK_ICON_GRAVITY_CENTER_RIGHT  4
#define VTK_ICON_GRAVITY_CENTER_CENTER 5
#define VTK_ICON_GRAVITY_CENTER_LEFT   6
#define VTK_ICON_GRAVITY_BOTTOM_RIGHT  7
#define VTK_ICON_GRAVITY_BOTTOM_CENTER 8
#define VTK_ICON_GRAVITY_BOTTOM_LEFT   9

#define VTK_ICON_SCALING_OFF 0
#define VTK_ICON_SCALING_USE_SCALING_ARRAY 1


class VTKFILTERSGENERAL_EXPORT vtkIconGlyphFilter : public vtkPolyDataAlgorithm
{
public:
  //@{
  /**
   * Standard VTK methods.
   */
  static vtkIconGlyphFilter *New();
  vtkTypeMacro(vtkIconGlyphFilter,vtkPolyDataAlgorithm);
  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
  //@}

  //@{
  /**
   * Specify the Width and Height, in pixels, of an icon in the icon sheet.
   */
  vtkSetVector2Macro(IconSize,int);
  vtkGetVectorMacro(IconSize,int,2);
  //@}

  //@{
  /**
   * Specify the Width and Height, in pixels, of an icon in the icon sheet.
   */
  vtkSetVector2Macro(IconSheetSize,int);
  vtkGetVectorMacro(IconSheetSize,int,2);
  //@}

  //@{
  /**
   * Specify the Width and Height, in pixels, of the size of the icon when it
   * is rendered. By default, the IconSize is used to set the display size
   * (i.e., UseIconSize is true by default). Note that assumes that
   * IconScaling is disabled, or if enabled, the scale of a particular icon
   * is 1.
   */
  vtkSetVector2Macro(DisplaySize,int);
  vtkGetVectorMacro(DisplaySize,int,2);
  //@}

  //@{
  /**
   * Specify whether the Quad generated to place the icon on will be either
   * the dimensions specified by IconSize or the DisplaySize.
   */
  vtkSetMacro(UseIconSize,bool);
  vtkGetMacro(UseIconSize,bool);
  vtkBooleanMacro(UseIconSize, bool);
  //@}

  //@{
  /**
   * Specify how to specify individual icons. By default, icon scaling
   * is off, but if it is on, then the filter looks for an array named
   * "IconScale" to control individual icon size.
   */
  vtkSetMacro(IconScaling,int);
  vtkGetMacro(IconScaling,int);
  void SetIconScalingToScalingOff() {this->SetIconScaling(VTK_ICON_SCALING_OFF);}
  void SetIconScalingToScalingArray()
    {this->SetIconScaling(VTK_ICON_SCALING_USE_SCALING_ARRAY);}
  //@}

  //@{
  /**
   * Specify whether to pass the scalar icon index to the output. By
   * default this is not passed since it can affect color during the
   * rendering process. Note that all other point data is passed to
   * the output regardless of the value of this flag.
   */
  vtkSetMacro(PassScalars,bool);
  vtkGetMacro(PassScalars,bool);
  vtkBooleanMacro(PassScalars,bool);
  //@}

  //@{
  /**
   * Specify if the input points define the center of the icon quad or one of
   * top right corner, top center, top left corner, center right, center, center
   * center left, bottom right corner, bottom center or bottom left corner.
   */
  vtkSetMacro(Gravity, int);
  vtkGetMacro(Gravity, int);
  void SetGravityToTopRight() {this->SetGravity(VTK_ICON_GRAVITY_TOP_RIGHT);};
  void SetGravityToTopCenter() {this->SetGravity(VTK_ICON_GRAVITY_TOP_CENTER);};
  void SetGravityToTopLeft() {this->SetGravity(VTK_ICON_GRAVITY_TOP_LEFT);};
  void SetGravityToCenterRight() {this->SetGravity(VTK_ICON_GRAVITY_CENTER_RIGHT);};
  void SetGravityToCenterCenter() {this->SetGravity(VTK_ICON_GRAVITY_CENTER_CENTER);};
  void SetGravityToCenterLeft() {this->SetGravity(VTK_ICON_GRAVITY_CENTER_LEFT);};
  void SetGravityToBottomRight() {this->SetGravity(VTK_ICON_GRAVITY_BOTTOM_RIGHT);};
  void SetGravityToBottomCenter() {this->SetGravity(VTK_ICON_GRAVITY_BOTTOM_CENTER);};
  void SetGravityToBottomLeft() {this->SetGravity(VTK_ICON_GRAVITY_BOTTOM_LEFT);};
  //@}

  //@{
  /**
   * Specify an offset (in pixels or display coordinates) that offsets the icons
   * from their generating points.
   */
  vtkSetVector2Macro(Offset,int);
  vtkGetVectorMacro(Offset,int,2);
  //@}

protected:
  vtkIconGlyphFilter();
  ~vtkIconGlyphFilter() VTK_OVERRIDE;

  int RequestData(vtkInformation *,
                  vtkInformationVector **,
                  vtkInformationVector *) VTK_OVERRIDE;

  int IconSize[2]; // Size in pixels of an icon in an icon sheet
  int IconSheetSize[2]; // Size in pixels of the icon sheet
  int DisplaySize[2]; // Size in pixels of the icon when displayed

  int  Gravity;
  bool UseIconSize;
  int  IconScaling;
  bool PassScalars;
  int Offset[2];

private:
  vtkIconGlyphFilter(const vtkIconGlyphFilter&) VTK_DELETE_FUNCTION;
  void operator=(const vtkIconGlyphFilter&) VTK_DELETE_FUNCTION;

  void IconConvertIndex(int id, int & j, int & k);
};

inline void vtkIconGlyphFilter::IconConvertIndex(int id, int & j, int & k)
{
  int dimX = this->IconSheetSize[0]/this->IconSize[0];
  int dimY = this->IconSheetSize[1]/this->IconSize[1];

  j = id - dimX * static_cast<int>(id/dimX);
  k = dimY - static_cast<int>(id/dimX) - 1;
}

#endif