-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcpsviewer.h
225 lines (177 loc) · 7.77 KB
/
cpsviewer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
#ifndef CPSVIEWER_H
#define CPSVIEWER_H
#include <QGLWidget>
#include <QObject>
#include <OpenGl/glu.h>
#include <QMouseEvent>
#include <QWheelEvent>
#include <QKeyEvent>
#include <QQuaternion>
#include <QVector3D>
#include <QDropEvent>
#include <QGLShader>
#include <QGLShaderProgram>
#include <QGLBuffer>
#include "atlas.h"
extern Atlas prometheusModel;
class CPSviewer : public QGLWidget
{
Q_OBJECT
public:
explicit CPSviewer(QWidget *parent = 0);
~CPSviewer();
QSize minimumSizeHint() const; // Sets minimium size of view window
QSize sizeHint() const; // Sets beginning size of view window
GLuint vaoHandle;
// These functions set variables that control camera location.
void setRotation(int X, int Y, int previousX, int previousY);
void setXTranslation(float distance);
void setYTranslation(float distance);
void setZoom(float distance);
/*****************************************************************************************************************
* These functions control the color and size of atoms... doesn't actually impact the data, but is more about
* how it is displayed... the results from these functions are stored within the CPSviewer class... this class
* stores the actively viewed part of the Atlas Framework.
******************************************************************************************************************/
void deepRefresh(); // Ask CPSviewer to process some data before having OpenGL redraw.
void editAtomColor();
void editAtomRadius();
//void editBondColor();
//void editBondRadius();
// These functions handle drawing routines for the various model representations.
void drawModel();
void drawBallandStickRepresentation();
void drawDreidingRepresentation();
void drawSpaceFillingRepresentation();
void drawVectorRepresentation();
void drawEnhancedVectorRepresentation();
// These copy-cat functions handle drawing routines for the highlighted atoms.
void drawSelectedModel();
void drawSelectedBallandStickRepresentation();
void drawSelectedDreidingRepresentation();
void drawSelectedSpaceFillingRepresentation();
void drawSelectedVectorRepresentation();
void drawSelectedEnhancedVectorRepresentation();
// This function handles the ability of the viewer to support item selection within the view.
void selectObjects(int centerX, int centerY, int boxWidth, int boxHeight);
void processHits(GLint hitCount, GLuint *selectionBuffer);
void drawSelectionBox (QPoint start, QPoint current);
void useSelectionBox(int finalX, int finalY, int initialX, int initialY);
void selectMolecule();
// This function draws labels on the atoms
void drawLabels();
void locateOnScreen();
// bitmaps
void drawBitmapGrid();
void pickBitmapGrid(int x, int y);
void CharacterLookup();
protected:
// These next three are the bare bone basic functions needed to execute an OpenGL widget.
void initializeGL(); // starts up the widget
void resizeGL(int width, int height); // gets called whenever you resize the window
void paintGL(); // indicates what to draw
// These handle mouse inputs.
void mousePressEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
void wheelEvent(QWheelEvent *event);
void mouseDoubleClickEvent(QMouseEvent *event);
void mouseReleaseEvent(QMouseEvent *event);
// These functions handle Drag and Drop functionality of the viewer. Any file dragged to the view has
// its filename extracted and then Prometheus tries to load the model.
void dragEnterEvent(QDragEnterEvent *event);
void dropEvent(QDropEvent *event);
// These functions handle keyboard inputs.
void keyPressEvent(QKeyEvent *event);
void keyReleaseEvent(QKeyEvent *event);
private:
// This identifies the User's desired representation method for the displayed model.
int activeModel;
int OpenGLMethod;
int representationMethod;
int projectionMethod;
// *************************************************************************************************
// These variables control camera movement (translation, rotation, zoom) for the Prometheus Viewer.
// *************************************************************************************************
// hold's the camera's orentation by telling OpenGL where it needs to rotate after the axis reset each time a frame is drawn.
// Does not include translation information.
QQuaternion accumulatedRotation;
QQuaternion inputRotation;
bool isStartStored;
// hold's camera's (translation) position by telling OpenGL where to shift the whole model... does not include rotation information.
float xTrans;
float yTrans;
float zTrans;
QPoint lastPos; // will be used to keep track of the mouse cursor's position on screen.
QPoint initialPos; // will be used to store the position of mouse on mouse click.
QPoint finalPos; // will be used to store the position of mouse upon mouse button release.
float WheelDelta; // will be used to keep track of the mouse wheel's orentation.
// **************************************************************
// These variables control switching between Tools in Prometheus
// **************************************************************
int selectionBufferSize;
bool viewTool;
bool selectTool;
bool atomTool;
bool deleteTool;
bool measureTool;
bool incrementBOTool;
bool decrementBOTool;
bool singleSelect;
bool selectRenderMode;
bool controlIsPressed;
bool doubleClick;
bool controlAll;
bool atomBuilderMoved;
bool mousePressed;
int builderAtom;
bool bitmapMode;
int bitmapWidth;
int bitmapHeight;
QVector<int> pickedBits;
/**************************************************************************************
* These arrays hold model data, but only for what is being displayed... the Atlas
* Framework holds everything, and this structure is a copy of what's actively being
* viewed by the User.
****************************************************************************************/
QVector<float> PosX;
QVector<float> PosY;
QVector<float> PosZ;
QVector<QString> AtomNames;
QVector<int> AtomicNumbers;
QVector<QString> FFTypes;
QVector<float> PartialCharges;
QVector<float> Radii;
QVector< QVector<float> > Colors;
QVector<QVector<int> > BondList;
QVector<int> BondOrders;
QVector<float> BondLengths;
QVector<QVector<float> > BondCenters;
QVector<QVector<float> > BondNormals;
QVector<int> SelectedAtoms;
QVector<int> SelectedBonds;
// These variables hold onto data neccessary to draw labels next to every atom.
int requestedLabelStyle;
QVector<QVector<int> > onScreenPos;
public slots:
void requestShallowRefresh();
void requestDeepRefresh();
void updateProjectionMethod(int index);
// These slots take signals from the tool buttons in the MainWindow gui. These slots change the member variables viewTool, selectTool, etc
// which will then inform OpenGL about what it needs to do to provide that tool's functionality.
void useViewTool();
void useSelectTool();
void useAtomTool();
void useDeleteTool();
void useMeasureTool();
void useIncrementBOTool();
void useDecrementBOTool();
// These slots take signals from various parts of the GUI and are used set options.
void requestBuildElementChange(int atomicNumber);
void requestLabelStyle(int label);
void setBitmapMode(bool isChecked);
void setBitGrid(int width, int height);
void printBitmap();
signals:
void dragAndDropFilename(QString filename);
};
#endif // CPSVIEWER_H