source: trunk/packages/vizservers/vtkvis/RpVtkDataSet.h @ 2507

Last change on this file since 2507 was 2478, checked in by ldelgass, 13 years ago

Add dataset bounding box outline color command. Legend - if no title/labels
are requested, try to make color bar fill the legend area (not currently pixel
exact because of coordinate system conversions and rounding in
vtkScalarBarActor)

  • Property svn:eol-style set to native
File size: 2.8 KB
Line 
1/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2/*
3 * Copyright (C) 2011, Purdue Research Foundation
4 *
5 * Author: Leif Delgass <ldelgass@purdue.edu>
6 */
7
8#ifndef __RAPPTURE_VTKVIS_DATASET_H__
9#define __RAPPTURE_VTKVIS_DATASET_H__
10
11#include <vtkSmartPointer.h>
12#include <vtkDataSet.h>
13#include <vtkDataSetReader.h>
14#include <vtkProp.h>
15#include <vtkActor.h>
16#include <vtkOutlineFilter.h>
17#include <vtkPolyDataMapper.h>
18
19#include <string>
20#include <vector>
21
22namespace Rappture {
23namespace VtkVis {
24
25/**
26 * \brief VTK DataSet wrapper
27 */
28class DataSet {
29public:
30    enum PrincipalPlane {
31        PLANE_XY,
32        PLANE_ZY,
33        PLANE_XZ
34    };
35    DataSet(const std::string& name);
36    virtual ~DataSet();
37
38    bool setDataFile(const char *filename);
39
40    bool setData(char *data, int nbytes);
41
42    bool setData(vtkDataSetReader *reader);
43
44    bool setData(vtkDataSet *ds);
45
46    vtkDataSet *copyData(vtkDataSet *ds);
47
48    bool isXY() const;
49
50    int numDimensions() const;
51
52    bool is2D(PrincipalPlane *plane = NULL, double *offset = NULL) const;
53
54    PrincipalPlane principalPlane() const;
55
56    const std::string& getName() const;
57
58    vtkDataSet *getVtkDataSet();
59
60    const char *getVtkType() const;
61
62    bool setActiveScalars(const char *name);
63
64    const char *getActiveScalarsName();
65
66    bool setActiveVectors(const char *name);
67
68    const char *getActiveVectorsName();
69
70    void getScalarRange(double minmax[2]) const;
71
72    void getDataRange(double minmax[2], const char *fieldName, int component = -1) const;
73
74    void getVectorRange(double minmax[2], int component = -1) const;
75
76    void getBounds(double bounds[6]) const;
77
78    void getCellSizeRange(double minmax[2], double *average);
79
80    bool getScalarValue(double x, double y, double z, double *value) const;
81
82    bool getVectorValue(double x, double y, double z, double vector[3]) const;
83
84    void setOpacity(double opacity);
85
86    /**
87     * \brief Get the opacity setting for the DataSet
88     *
89     * This method is used for record-keeping.  The renderer controls
90     * the visibility of related graphics objects.
91     */
92    inline double getOpacity()
93    {
94        return _opacity;
95    }
96
97    void setVisibility(bool state);
98
99    bool getVisibility() const;
100
101    void showOutline(bool state);
102
103    void setOutlineColor(float color[3]);
104
105    /**
106     * \brief Return the VTK prop object for the outline
107     */
108    inline vtkProp *getProp()
109    {
110        return _prop;
111    }
112
113private:
114    DataSet();
115
116    void setDefaultArrays();
117    void print() const;
118
119    void initProp();
120
121    std::string _name;
122    vtkSmartPointer<vtkDataSet> _dataSet;
123    bool _visible;
124    double _opacity;
125    double _cellSizeRange[2];
126    double _cellSizeAverage;
127    vtkSmartPointer<vtkOutlineFilter> _outlineFilter;
128    vtkSmartPointer<vtkActor> _prop;
129    vtkSmartPointer<vtkPolyDataMapper> _outlineMapper;
130};
131
132}
133}
134
135#endif
Note: See TracBrowser for help on using the repository browser.