AmbientOcclusion
Molecule.h
Go to the documentation of this file.
1 #ifndef MOLECULE_H
2 #define MOLECULE_H
3 
4 #include <vector>
5 #include <QVector4D>
6 #include <string>
7 #include <qmath.h>
8 
9 #include <QOpenGLBuffer>
10 #include <QOpenGLVertexArrayObject>
11 #include <QOpenGLShaderProgram>
12 #include <map>
13 #include <vector>
14 
15 #include "SceneObject.h"
16 #include "Params.h"
17 
22 enum DRAW_TYPE {
23  COLOR = 0, EDGES = 1, HALOS = 2, SHADOW_MAP = 3, OCCLUSION_MAP = 4
24 };
25 
29 struct Atom {
30 
34  QVector3D color;
35 
39  QVector3D chainColor;
40 
45 
50 
54  QVector3D position;
55 
59  std::string name;
60 
65 };
66 
70 class Molecule : public SceneObject
71 {
72 
73 public:
74 
75  Molecule(QMatrix4x4 _modelMatrix);
76  ~Molecule();
77 
86  void initGL(QOpenGLShaderProgram *mainShader, QOpenGLShaderProgram*shadowMapShader,QOpenGLShaderProgram* ambientOcclusionMapShader, QOpenGLShaderProgram * edgeShader, QOpenGLShaderProgram *haloShader);
87 
92  void draw(DRAW_TYPE type);
93 
99  QVector3D findColor(std::string atomName);
100 
107  float findRadius(std::string atomName, RadiusEnum radiusType);
108 
114  QVector3D findChainColor(int chainID);
115 
120  QVector3D findMoleculeCenter();
121 
128  void centerMolecule(QVector3D center);
129 
134  float getBoundingSphereRadius();
135 
139  std::vector<Atom> *atoms;
140 
146  QVector3D findCameraTranslation();
147 
148 private:
152  std::map<std::string, QVector3D> *atomColorMap;
153 
157  std::vector<QVector3D> *chainColorMap;
158 
162  std::map<std::string, float> *covalentRadiusMap;
163 
167  std::map<std::string, float> *vanDerWaalsRadiusMap;
168 
172  QOpenGLVertexArrayObject vao;
173 
177  QOpenGLVertexArrayObject haloVAO;
178 
182  QOpenGLVertexArrayObject edgeVAO;
183 
187  QOpenGLVertexArrayObject shadowMapVAO;
188 
192  QOpenGLVertexArrayObject occlusionMapVAO;
193 
197  QOpenGLBuffer vertexBuffer;
198 
202  QOpenGLBuffer atomColorBuffer;
203 
207  QOpenGLBuffer chainColorBuffer;
208 
212  QOpenGLBuffer vanDerWaalsRadiusBuffer;
213 
217  QOpenGLBuffer covalentRadiusBuffer;
218 
222  QOpenGLBuffer quadBuffer;
223 
224  // Initialization of color and radius maps
228  void initAtomColorMap();
229 
233  void initChainColorMap();
234 
238  void initCovalentRadiusMap();
239 
243  void initVanDerWaalsRadiusMap();
244 
248  float boundingSphereRadius;
249 };
250 
251 #endif // MOLECULE_H
QVector3D findCameraTranslation()
findCameraTranslation
Definition: Molecule.cpp:376
The Atom struct - structure which encapsulated and simlates an atom, an elementary component of a mol...
Definition: Molecule.h:29
The Molecule class - This class represents a molecule. It consists of atoms and bonds.
Definition: Molecule.h:70
Definition: Molecule.h:23
float vanDerWaalsRadius
vanDerWaalsRadius - stores the vanDerWaals atomar radius
Definition: Molecule.h:49
RadiusEnum
The RadiusEnum enum - enumeration specifies the two possible types of radii, which the application vi...
Definition: Params.h:14
float distanceCameraTranslate
distanceCameraTranslate - distance by which the camera needs to be translated from center of model...
Definition: Molecule.h:64
void centerMolecule(QVector3D center)
centerMolecule - Resets the molecule to the center in world space (0, 0 ,0). This method must be call...
Definition: Molecule.cpp:368
QVector3D findColor(std::string atomName)
findColor
Definition: Molecule.cpp:314
Definition: Molecule.h:23
void draw(DRAW_TYPE type)
draw - Draws the corresponding VBO to the screen
Definition: Molecule.cpp:42
QVector3D chainColor
chainColor - Atom color specific to the chain it belongs to
Definition: Molecule.h:39
DRAW_TYPE
The DRAW_TYPE enum - enumeration which encapsulates the divers types of drawing used by the applicati...
Definition: Molecule.h:22
~Molecule()
Definition: Molecule.cpp:25
QVector3D findChainColor(int chainID)
findChainColor
Definition: Molecule.cpp:326
QVector3D findMoleculeCenter()
findMoleculeCenter
Definition: Molecule.cpp:354
Molecule(QMatrix4x4 _modelMatrix)
Definition: Molecule.cpp:6
QVector3D position
position - Describes the position of the sphere in model space
Definition: Molecule.h:54
Definition: Molecule.h:23
Definition: SceneObject.h:8
float covalentRadius
covalentRadius - stores the covalent atomar radius
Definition: Molecule.h:44
float getBoundingSphereRadius()
getBoundingSphereRadius
Definition: Molecule.cpp:395
void initGL(QOpenGLShaderProgram *mainShader, QOpenGLShaderProgram *shadowMapShader, QOpenGLShaderProgram *ambientOcclusionMapShader, QOpenGLShaderProgram *edgeShader, QOpenGLShaderProgram *haloShader)
initGL - Initializes the communication with opengl
Definition: Molecule.cpp:86
Definition: Molecule.h:23
std::vector< Atom > * atoms
atoms - Contains information of all atoms-> Stores all the atoms in this molecule.
Definition: Molecule.h:139
QVector3D color
color - specific Atom color
Definition: Molecule.h:34
std::string name
name - Stores the name of the molecule
Definition: Molecule.h:59
float findRadius(std::string atomName, RadiusEnum radiusType)
findRadius
Definition: Molecule.cpp:334
Definition: Molecule.h:23