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_MOLECULE_H__ |
---|
9 | #define __RAPPTURE_VTKVIS_MOLECULE_H__ |
---|
10 | |
---|
11 | #include <vtkSmartPointer.h> |
---|
12 | #include <vtkLookupTable.h> |
---|
13 | #include <vtkPolyDataMapper.h> |
---|
14 | #include <vtkActor.h> |
---|
15 | #include <vtkAssembly.h> |
---|
16 | #include <vtkGlyph3D.h> |
---|
17 | |
---|
18 | #include "ColorMap.h" |
---|
19 | #include "RpVtkGraphicsObject.h" |
---|
20 | |
---|
21 | namespace Rappture { |
---|
22 | namespace VtkVis { |
---|
23 | |
---|
24 | /** |
---|
25 | * \brief Ball and stick Molecule |
---|
26 | * |
---|
27 | * The data format for this class is based on the VisIt Molecule |
---|
28 | * plot. It consists of a vtkPolyData with atom coordinates as |
---|
29 | * points and vertices and bonds as lines. A scalar array named |
---|
30 | * "element" can be included as point data to specify atomic |
---|
31 | * numbers to use in coloring (via the "elementDefault" ColorMap) |
---|
32 | * and scaling atoms. If the scalar array is not named |
---|
33 | * "element," it will be color-mapped as a standard scalar field. |
---|
34 | */ |
---|
35 | class Molecule : public VtkGraphicsObject { |
---|
36 | public: |
---|
37 | enum AtomScaling { |
---|
38 | NO_ATOM_SCALING, |
---|
39 | VAN_DER_WAALS_RADIUS, |
---|
40 | COVALENT_RADIUS, |
---|
41 | ATOMIC_RADIUS |
---|
42 | }; |
---|
43 | |
---|
44 | Molecule(); |
---|
45 | virtual ~Molecule(); |
---|
46 | |
---|
47 | virtual const char *getClassName() const |
---|
48 | { |
---|
49 | return "Molecule"; |
---|
50 | } |
---|
51 | |
---|
52 | virtual void setClippingPlanes(vtkPlaneCollection *planes); |
---|
53 | |
---|
54 | void setColorMap(ColorMap *colorMap); |
---|
55 | |
---|
56 | /** |
---|
57 | * \brief Return the ColorMap in use |
---|
58 | */ |
---|
59 | ColorMap *getColorMap() |
---|
60 | { |
---|
61 | return _colorMap; |
---|
62 | } |
---|
63 | |
---|
64 | void updateColorMap(); |
---|
65 | |
---|
66 | virtual void updateRanges(Renderer *renderer); |
---|
67 | |
---|
68 | void setAtomScaling(AtomScaling state); |
---|
69 | |
---|
70 | void setAtomRadiusScale(double scale); |
---|
71 | |
---|
72 | void setAtomVisibility(bool state); |
---|
73 | |
---|
74 | void setBondVisibility(bool state); |
---|
75 | |
---|
76 | static ColorMap *createElementColorMap(); |
---|
77 | |
---|
78 | private: |
---|
79 | virtual void initProp(); |
---|
80 | virtual void update(); |
---|
81 | |
---|
82 | static void addRadiusArray(vtkDataSet *dataSet, AtomScaling scaling, double scaleFactor); |
---|
83 | |
---|
84 | double _radiusScale; |
---|
85 | AtomScaling _atomScaling; |
---|
86 | ColorMap *_colorMap; |
---|
87 | |
---|
88 | vtkSmartPointer<vtkLookupTable> _lut; |
---|
89 | vtkSmartPointer<vtkActor> _atomProp; |
---|
90 | vtkSmartPointer<vtkActor> _bondProp; |
---|
91 | vtkSmartPointer<vtkGlyph3D> _glypher; |
---|
92 | vtkSmartPointer<vtkPolyDataMapper> _atomMapper; |
---|
93 | vtkSmartPointer<vtkPolyDataMapper> _bondMapper; |
---|
94 | }; |
---|
95 | |
---|
96 | } |
---|
97 | } |
---|
98 | |
---|
99 | #endif |
---|