source: trunk/packages/vizservers/vtkvis/RpGlyphs.h @ 3195

Last change on this file since 3195 was 3195, checked in by ldelgass, 11 years ago

Require VTK >= 5.8

  • Property svn:eol-style set to native
File size: 3.0 KB
Line 
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 __RAPPTURE_VTKVIS_GLYPHS_H__
9#define __RAPPTURE_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 <vtkLookupTable.h>
19#include <vtkPlaneCollection.h>
20
21#include "RpVtkGraphicsObject.h"
22#include "ColorMap.h"
23
24namespace Rappture {
25namespace VtkVis {
26
27/**
28 * \brief Oriented and scaled 3D glyph shapes
29 *
30 * The DataSet must have vectors and/or scalars
31 */
32class Glyphs : public VtkGraphicsObject {
33public:
34    enum GlyphShape {
35        ARROW,
36        CONE,
37        CUBE,
38        CYLINDER,
39        DODECAHEDRON,
40        ICOSAHEDRON,
41        LINE,
42        OCTAHEDRON,
43        SPHERE,
44        TETRAHEDRON
45    };
46    enum ScalingMode {
47        SCALE_BY_SCALAR,
48        SCALE_BY_VECTOR_MAGNITUDE,
49        SCALE_BY_VECTOR_COMPONENTS,
50        SCALING_OFF
51    };
52    enum ColorMode {
53        COLOR_BY_SCALAR,
54        COLOR_BY_VECTOR_MAGNITUDE,
55        COLOR_BY_VECTOR_X,
56        COLOR_BY_VECTOR_Y,
57        COLOR_BY_VECTOR_Z,
58        COLOR_CONSTANT
59    };
60
61    Glyphs(GlyphShape shape);
62    virtual ~Glyphs();
63
64    virtual const char *getClassName() const
65    {
66        return "Glyphs";
67    }
68
69    virtual void setDataSet(DataSet *dataSet,
70                            Renderer *renderer);
71
72    virtual void setClippingPlanes(vtkPlaneCollection *planes);
73
74    void setQuality(double quality);
75
76    void setOrient(bool state);
77
78    void setOrientMode(bool mode, const char *name);
79
80    void setScalingMode(ScalingMode mode, const char *name, double range[2]);
81
82    void setColorMode(ColorMode mode, const char *name, double range[2]);
83
84    void setScalingMode(ScalingMode mode);
85
86    void setNormalizeScale(bool normalize);
87
88    void setColorMode(ColorMode mode);
89
90    void setGlyphShape(GlyphShape shape);
91
92    void setScaleFactor(double scale);
93
94    void setColorMap(ColorMap *colorMap);
95
96    /**
97     * \brief Return the ColorMap in use
98     */
99    ColorMap *getColorMap()
100    {
101        return _colorMap;
102    }
103
104    void updateColorMap();
105
106    virtual void updateRanges(Renderer *renderer);
107
108private:
109    Glyphs();
110    virtual void update();
111    static inline double min2(double a, double b)
112    {
113        return ((a < b) ? a : b);
114    }
115    static inline double max2(double a, double b)
116    {
117        return ((a > b) ? a : b);
118    }
119
120    GlyphShape _glyphShape;
121    ScalingMode _scalingMode;
122    std::string _scalingFieldName;
123    double _scalingFieldRange[2];
124    double _dataScale;
125    double _scaleFactor;
126    bool _normalizeScale;
127    ColorMap *_colorMap;
128    ColorMode _colorMode;
129    std::string _colorFieldName;
130    double _colorFieldRange[2];
131    double _vectorMagnitudeRange[2];
132    double _vectorComponentRange[3][2];
133    Renderer *_renderer;
134
135    vtkSmartPointer<vtkLookupTable> _lut;
136    vtkSmartPointer<vtkPolyDataAlgorithm> _glyphSource;
137    vtkSmartPointer<vtkGlyph3DMapper> _glyphMapper;
138};
139
140}
141}
142
143#endif
Note: See TracBrowser for help on using the repository browser.