1 | /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ |
---|
2 | /* |
---|
3 | * Copyright (C) 2004-2012 HUBzero Foundation, LLC |
---|
4 | * |
---|
5 | * Author: Leif Delgass <ldelgass@purdue.edu> |
---|
6 | */ |
---|
7 | |
---|
8 | #ifndef VTKVIS_GLYPHS_H |
---|
9 | #define VTKVIS_GLYPHS_H |
---|
10 | |
---|
11 | #include <vector> |
---|
12 | |
---|
13 | #include <vtkSmartPointer.h> |
---|
14 | #include <vtkProp.h> |
---|
15 | #include <vtkActor.h> |
---|
16 | #include <vtkVersion.h> |
---|
17 | #include <vtkGlyph3DMapper.h> |
---|
18 | #include <vtkMaskPoints.h> |
---|
19 | #include <vtkLookupTable.h> |
---|
20 | #include <vtkPlaneCollection.h> |
---|
21 | |
---|
22 | #include "GraphicsObject.h" |
---|
23 | #include "ColorMap.h" |
---|
24 | |
---|
25 | namespace VtkVis { |
---|
26 | |
---|
27 | /** |
---|
28 | * \brief Oriented and scaled 3D glyph shapes |
---|
29 | * |
---|
30 | * The DataSet must have vectors and/or scalars |
---|
31 | */ |
---|
32 | class Glyphs : public GraphicsObject { |
---|
33 | public: |
---|
34 | enum GlyphShape { |
---|
35 | ARROW, |
---|
36 | CONE, |
---|
37 | CUBE, |
---|
38 | CYLINDER, |
---|
39 | DODECAHEDRON, |
---|
40 | ICOSAHEDRON, |
---|
41 | LINE, |
---|
42 | OCTAHEDRON, |
---|
43 | POINT, |
---|
44 | SPHERE, |
---|
45 | TETRAHEDRON |
---|
46 | }; |
---|
47 | enum ScalingMode { |
---|
48 | SCALE_BY_SCALAR, |
---|
49 | SCALE_BY_VECTOR_MAGNITUDE, |
---|
50 | SCALE_BY_VECTOR_COMPONENTS, |
---|
51 | SCALING_OFF |
---|
52 | }; |
---|
53 | enum ColorMode { |
---|
54 | COLOR_BY_SCALAR, |
---|
55 | COLOR_BY_VECTOR_MAGNITUDE, |
---|
56 | COLOR_BY_VECTOR_X, |
---|
57 | COLOR_BY_VECTOR_Y, |
---|
58 | COLOR_BY_VECTOR_Z, |
---|
59 | COLOR_CONSTANT |
---|
60 | }; |
---|
61 | |
---|
62 | Glyphs(GlyphShape shape); |
---|
63 | virtual ~Glyphs(); |
---|
64 | |
---|
65 | virtual const char *getClassName() const |
---|
66 | { |
---|
67 | return "Glyphs"; |
---|
68 | } |
---|
69 | |
---|
70 | virtual void setDataSet(DataSet *dataSet, |
---|
71 | Renderer *renderer); |
---|
72 | |
---|
73 | virtual void setClippingPlanes(vtkPlaneCollection *planes); |
---|
74 | |
---|
75 | void setQuality(double quality); |
---|
76 | |
---|
77 | void setOrient(bool state); |
---|
78 | |
---|
79 | void setOrientMode(bool mode, const char *name); |
---|
80 | |
---|
81 | void setScalingMode(ScalingMode mode, const char *name, double range[2]); |
---|
82 | |
---|
83 | void setColorMode(ColorMode mode, const char *name, double range[2] = NULL); |
---|
84 | |
---|
85 | void setScalingMode(ScalingMode mode); |
---|
86 | |
---|
87 | void setNormalizeScale(bool normalize); |
---|
88 | |
---|
89 | void setColorMode(ColorMode mode); |
---|
90 | |
---|
91 | void setGlyphShape(GlyphShape shape); |
---|
92 | |
---|
93 | void setScaleFactor(double scale); |
---|
94 | |
---|
95 | void setMaximumNumberOfGlyphs(int max, bool random = true, |
---|
96 | int offset = 0, int ratio = 1); |
---|
97 | |
---|
98 | void setColorMap(ColorMap *colorMap); |
---|
99 | |
---|
100 | /** |
---|
101 | * \brief Return the ColorMap in use |
---|
102 | */ |
---|
103 | ColorMap *getColorMap() |
---|
104 | { |
---|
105 | return _colorMap; |
---|
106 | } |
---|
107 | |
---|
108 | void updateColorMap(); |
---|
109 | |
---|
110 | virtual void updateRanges(Renderer *renderer); |
---|
111 | |
---|
112 | private: |
---|
113 | Glyphs(); |
---|
114 | virtual void update(); |
---|
115 | static inline double min2(double a, double b) |
---|
116 | { |
---|
117 | return ((a < b) ? a : b); |
---|
118 | } |
---|
119 | static inline double max2(double a, double b) |
---|
120 | { |
---|
121 | return ((a > b) ? a : b); |
---|
122 | } |
---|
123 | |
---|
124 | GlyphShape _glyphShape; |
---|
125 | ScalingMode _scalingMode; |
---|
126 | std::string _scalingFieldName; |
---|
127 | double _scalingFieldRange[2]; |
---|
128 | double _dataScale; |
---|
129 | double _scaleFactor; |
---|
130 | bool _normalizeScale; |
---|
131 | ColorMap *_colorMap; |
---|
132 | ColorMode _colorMode; |
---|
133 | std::string _colorFieldName; |
---|
134 | double _colorFieldRange[2]; |
---|
135 | double _vectorMagnitudeRange[2]; |
---|
136 | double _vectorComponentRange[3][2]; |
---|
137 | Renderer *_renderer; |
---|
138 | |
---|
139 | vtkSmartPointer<vtkLookupTable> _lut; |
---|
140 | vtkSmartPointer<vtkPolyDataAlgorithm> _glyphSource; |
---|
141 | vtkSmartPointer<vtkGlyph3DMapper> _glyphMapper; |
---|
142 | vtkSmartPointer<vtkMaskPoints> _maskPoints; |
---|
143 | }; |
---|
144 | |
---|
145 | } |
---|
146 | |
---|
147 | #endif |
---|