source: branches/blt4/packages/vizservers/vtkvis/Contour2D.h @ 3892

Last change on this file since 3892 was 3892, checked in by gah, 11 years ago
File size: 2.6 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 VTKVIS_CONTOUR2D_H
9#define VTKVIS_CONTOUR2D_H
10
11#include <vtkSmartPointer.h>
12#include <vtkContourFilter.h>
13#include <vtkPolyDataMapper.h>
14#include <vtkActor.h>
15#include <vtkPlaneCollection.h>
16#include <vtkLookupTable.h>
17
18#include <vector>
19
20#include "ColorMap.h"
21#include "GraphicsObject.h"
22
23namespace VtkVis {
24
25/**
26 * \brief 2D Contour lines (isolines)
27 */
28class Contour2D : public GraphicsObject {
29public:
30    enum ColorMode {
31        COLOR_BY_SCALAR,
32        COLOR_BY_VECTOR_MAGNITUDE,
33        COLOR_BY_VECTOR_X,
34        COLOR_BY_VECTOR_Y,
35        COLOR_BY_VECTOR_Z,
36        COLOR_CONSTANT
37    };
38
39    Contour2D(int numContours);
40
41    Contour2D(const std::vector<double>& contours);
42
43    virtual ~Contour2D();
44
45    virtual const char *getClassName() const
46    {
47        return "Contour2D";
48    }
49
50    virtual void setDataSet(DataSet *dataSet,
51                            Renderer *renderer);
52
53    virtual void setClippingPlanes(vtkPlaneCollection *planes);
54
55    void setContourField(const char *name);
56
57    void setNumContours(int numContours);
58
59    void setContourList(const std::vector<double>& contours);
60
61    int getNumContours() const;
62
63    const std::vector<double>& getContourList() const;
64
65    void setColorMode(ColorMode mode, DataSet::DataAttributeType type,
66                      const char *name, double range[2] = NULL);
67
68    void setColorMode(ColorMode mode,
69                      const char *name, double range[2] = NULL);
70
71    void setColorMode(ColorMode mode);
72
73    void setColorMap(ColorMap *colorMap);
74
75    /**
76     * \brief Return the ColorMap in use
77     */
78    ColorMap *getColorMap()
79    {
80        return _colorMap;
81    }
82
83    void updateColorMap();
84
85    virtual void updateRanges(Renderer *renderer);
86
87    virtual void setColor(float color[3])
88    {
89        GraphicsObject::setColor(color);
90        GraphicsObject::setEdgeColor(color);
91    }
92
93    virtual void setEdgeColor(float color[3])
94    {
95        setColor(color);
96    }
97
98private:
99    Contour2D();
100
101    virtual void update();
102
103    int _numContours;
104    std::vector<double> _contours;
105
106    bool _pipelineInitialized;
107
108    ColorMap *_colorMap;
109    ColorMode _colorMode;
110    std::string _colorFieldName;
111    DataSet::DataAttributeType _colorFieldType;
112    double _colorFieldRange[2];
113    double _vectorMagnitudeRange[2];
114    double _vectorComponentRange[3][2];
115    Renderer *_renderer;
116
117    vtkSmartPointer<vtkLookupTable> _lut;
118    vtkSmartPointer<vtkContourFilter> _contourFilter;
119    vtkSmartPointer<vtkPolyDataMapper> _mapper;
120};
121
122}
123
124#endif
Note: See TracBrowser for help on using the repository browser.