Debian Codegraph @

chgl.h

raw symbols SCIP
1
2 /****************************************************************************
3 **
4 ** Copyright (C) 2011 Christian B. Huebschle & George M. Sheldrick
5 ** All rights reserved.
6 ** Contact: [email protected]
7 **
8 ** This file is part of the ShelXle
9 **
10 ** This file may be used under the terms of the GNU Lesser
11 ** General Public License version 2.1 as published by the Free Software
12 ** Foundation and appearing in the file COPYING included in the
13 ** packaging of this file. Please review the following information to
14 ** ensure the GNU Lesser General Public License version 2.1 requirements
15 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
16 **
17 **
18 ****************************************************************************/
19 #ifndef CHGL_H
20 #define CHGL_H
21
22 #include <QOpenGLWidget>
23 #include <QToolButton>
24 #include <QCheckBox>
25 #include <QComboBox>
26 #include <QDoubleSpinBox>
27 #include <QSpinBox>
28 #include <QLabel>
29 #include <QApplication>
30 #include <QGridLayout>
31 #include "molecule.h"
32 //#include "fourxle.h"
33 #ifndef MAXSELECT
34 #define MAXSELECT 300001
35 #endif
36
37 #define HIDE_REASON_SELECT 1
38 #define HIDE_REASON_THIS_FRAGMENT 2
39 #define HIDE_REASON_OTHER_FRAGMENT 4
40 #define HIDE_REASON_HYDROGEN 8
41 #define HIDE_REASON_QPEAK 16
42 #define HIDE_REASON_BELO 32
43 /*! \brief ChGL is the QGLWidget of ShelXle
44 */
45 class ChGL : public QOpenGLWidget{
46 Q_OBJECT
47 public:
48 explicit ChGL(QWidget * parent = 0);
49 virtual ~ChGL();
50 void setMainWindow(QWidget * parent){
51 chparent=parent;
52 }
53 QTimer *idl;//! idle rotation timer
54 QTimer *idl_end;//! idle rotation timer
55 bool on;
56 bool habzutun;
57 QString theIconPath;
58 int ww,//!<Window with
59 wh,//!<Window height
60 minus;//!<for streo mode swiches right and left eye view
61 int SDM_Limit; //!< if the number of atoms in the au exceeds this limit shortest distance is not computed automatically default 350
62 double retinafktr;
63 int stereo_mode;//!< intager value of the current stereo mode
64 int objCnt;//!< number of visible atoms + q-peaks
65 int ImeanThisAtom;//!< atom index for context menu.
66 double viewAngle,//!< viewing angele for the perspective view 0 is othogonal
67 envirange;//!< range in Angstrom around which environmental atoms should be consedered.
68 QColor labelColor,//!< Color of atom labels.
69 backGroundColor;//!< Base color of the back groud.
70 bool pause,//!< if true no rendering is made
71 inRenameMode,//!< if true wee are in rename mode
72 noWaitLabel,//!< if true wire mode after list initialization is not used to generate srceen shots.
73 exporting;//!< for exporting bitmaps
74 QVector< QVector< float > > fVertexes;
75 QVector< QVector< float > > fNormals;
76 double lintrans;//!<degree of thansparency for the maps 0-1. 0 is transparent.
77 double linwidth;//!<linewidth of the meshes.
78 double contMin,contMax;
79 QColor fopc;//!< Fo positive color
80 QColor fomc;//!< Fo negative color
81 QColor dipc;//!< Fo-Fc positive color
82 QColor dimc;//!< Fo-Fc negative color
83 struct labz{
84 int x,y;
85 QString l;
86 int an;
87 };//!< struct labels for exporting bitmaps
88 QList<labz> LabelZ;//!< labels for exporting bitmaps
89 bool hiddenThings;//!< We know that there are hidden objects.
90 bool neutrons;//!< true if we have neuton scattering factors (negative Fo map is shown if this is true)
91 int dratpause;//!< when the molecule is rotated for a time of dratpause milliseconds the molecule is drawn as a wire frame draft
92 QFont myFont,//!< there is a Font for Labels of atoms
93 nonAtomFont;//!< there is a Font for Labels of Q-Peaks
94 QTimer *moving;//!< timer runs dratpause miliseconds after a rotation or scale
95 GLdouble MM[16];//!< a GL matrix.
96 QAction *addBond,//!< QAction BIND
97 *killBond,//!< QAction FREE
98 *clearSelection,//!< QAction deselect
99 *centerSelection,//!< QAction center selected atoms
100 *hideNotSelection,//!< QAction hide non selected atoms
101 *unhide,//!< QAction show all previous hidden objects
102 *invhide,//!< QAction show all previous hidden and hide visible objects
103 *grow,//!< QAction grow
104 *fuse,//!< QAction fuse
105 *shpm1,//!< QAction show part -N ghost
106 *hideh, //!< QAction hide Hydrogen atoms
107 *qPeakBonds,//!< QAction Q-Peak binds
108 *toggleDockWidgets,//!< QAction hide text windows
109 *delSelAt,//!< QAction delete selected atoms
110 *highlightParts, //!< QAction highlight atoms in parts != 0
111 *centroid, //!< QAction create a centroid dummy
112 *enviNoQ,//!< QAction ENVI only for real atoms
113 *enviCova,//!< QAction ENVI only for covalent contacts
114 *wireButt,//!< QAction show atoms while rotation in wire mode
115 *invSelection,//!< QAction invert selection
116 *cntrPlot,
117 *nocntrPlot,
118 *rainbowPlot,
119 *hideBeLo,//!< hide/show BEDE and LONE objects
120 //*useTextureLabels,//!< alternative to Qt renderText render Labels on BillBoard textures
121 *shortLabels,//!< Labels without residue number or symmery flag are considered short
122 *atomLegend;//!< a key legend for atoms used
123 QToolButton *enviButt;//!< Button to clear the envi -ronment.
124 QToolButton *enviSelect;//!< Button to select the envi -ronment.
125 QList<V3>enviPositions;//!<List of atom postions of an envi-ronment.
126 QList<V3> cont;
127 QMap<int,GLfloat> contval;
128 QList<int>enviKat;//!< List of categorie:qs of contacts in an envi-ronment.
129 V3 enviP0;//!< coordinate used for envi.
130 QMenu *sfacMenu;//!< a sub menu to change the element of a specified atom.
131 QStringList labs;//!< Labels for an envi-ronment list.
132 Molecule *mol;//!< pointer to the Molecule object.
133 int murx;//!< non zero values lead to a rerendering of the display lists.
134 // static const int bas=1;//!< GL List base for atoms bonds unit cell.
135 // static const int wirbas=11;//!< GL List base for wireframe bonds and atoms
136 double L;//!< a scale factor.
137 QAction *foact, //!< QAction toggling Fobs maps.
138 *fofcact;//!< QAction toggling Fobs-Fcalc maps.
139 int rotze;//!< if not -1 the index of an atom in the rotation center.
140 QToolButton *invertMouseZoom;//!< inverts the mouse direction that zoom on right click.
141 QCheckBox *lighting;//!< enable lighting on the electron density.
142 QCheckBox *niceTrans;//!< draw 6 perspectives for each surface to improve transparent visualization.
143 QCheckBox *fillMap;//!< draw maps in filled style.
144 QToolButton *rCenter;//!< resets the rotation center
145 V3 altemitte;//!<rotation center position
146 V3 altcenter;
147 bool altpivot;
148 QComboBox *pivot1cb=nullptr;
149 QComboBox *pivot2cb=nullptr;
150 QDoubleSpinBox *axx=nullptr;
151 QDoubleSpinBox *axy=nullptr;
152 QDoubleSpinBox *axz=nullptr;
153 QDoubleSpinBox *orgx=nullptr;
154 QDoubleSpinBox *orgy=nullptr;
155 QDoubleSpinBox *orgz=nullptr;
156 QDoubleSpinBox *pickRadSpin=nullptr;
157 QCheckBox *manualAx=nullptr;
158 QCheckBox *freeRot=nullptr;
159 QLabel *whyNotSplit=nullptr;
160 // void initLists();
161 bool canSplitRotate();
162 double pickRad(){
163 return sqrt(pickradius);
164 }
165 QSpinBox *angle1=nullptr;
166 QSpinBox *angle2=nullptr;
167 void qglColor(const QColor c);
168 void qglClearColor(const QColor c);
169 void farbverlauf(double wrt, double min, double max);
170 QColor farbverlaufQC(double wrt, double min, double max);
171 void zoom(double speed);
172 bool isFO(){return drawFO;}//!< if Fo map is visible true is returned.
173 bool isDF(){return drawDF;}//!< if Fo-Fc map is visible true is returned.
174 //void warFaul(){warfaul=true;}
175 void gZoom(double speed);
176 void rotZ(double speed);
177 void rotY(double speed);
178 void rotX(double speed);
179 void moveX(double speed);
180 void moveY(double speed);
181 void setupTexture();
182 void updateBondActions();
183 QList<int> lastClicked();
184 inline QString glError2String(GLenum err){
185 switch (err) {
186 case GL_NO_ERROR: return QString("GL_NO_ERROR: No OpenGL error."); break;
187 case GL_INVALID_ENUM: return QString("GL_INVALID_ENUM: An enumeration parameter is not a legal enumeration for that function."); break;
188 case GL_INVALID_VALUE: return QString("GL_INVALID_VALUE: Given when a value parameter is not a legal value for that function."); break;
189 case GL_INVALID_OPERATION: return QString("GL_INVALID_OPERATION: Given when the set of state for a command is not legal for the parameters given to that command."); break;
190 case GL_STACK_OVERFLOW: return QString("GL_STACK_OVERFLOW: Given when a stack pushing operation cannot be done because it would overflow the limit of that stack's size."); break;
191 case GL_STACK_UNDERFLOW: return QString("GL_STACK_UNDERFLOW: Given when a stack popping operation cannot be done because the stack is already at its lowest point."); break;
192 case GL_OUT_OF_MEMORY: return QString("GL_OUT_OF_MEMORY: Given when performing an operation that can allocate memory, and the memory cannot be allocated."); break;
193 default : return QString("Some other OpenGL error."); break;
194 }
195 }
196 void pairing(QList<int> ima, QList<int> imb);
197 inline void setLabelSize(double s){
198 labScal=s;
199 }
200 signals:
201 void no_hw_st();//!< we have no hard ware stereo sorry!
202 void message(const QString &);//!< small text messages to the status bar.
203 void bigmessage(const QString &);//!< passes HTML strings to the info window.
204 void jumpit(int index);//!<An atom has ben left clicked: cursor jump on it.
205 void selectionChanged();
206 void movedByUser();
207 void diffscroll(int numsteps,int diff);//!< to change the iso value of the Fo- or Fo-Fc maps
208 void neuemitte(V3 mitte);//!< the rotation center has changet to mitte.
209 void inimibas();//!< tells FourXle to initialize the GL display lists.
210 void qpfoci(double height);//!< when a mouse hovers a Q-Peak the height is emitted to the Q-Peak Legend.
211 void insertDFIX(double value, double esd, QList<MyAtom> selected, QString resiSpec); //!< Insert DFIX restrain to the ins file
212 void bindthem();
213 void splitable(bool ok);
214 void insertDANG(double value, double esd, QList<MyAtom> selected, QString resiSpec); //!< Insert DANG restrain to the ins file
215 void insertFLAT(double esd, QList<MyAtom> selected, QString resiSpec); //!< Insert FLAT restrain to the ins file
216 void insertEXYZ(QList<MyAtom> selected); //!< Insert EXYZ restrain to the ins file
217 void insertEADP(QList<MyAtom> selected); //!< Insert EADP restrain to the ins file
218 void insertSADI(int selected); //!< Insert SADI restrain to the ins file
219 void insertDELU(double esd1, double esd2, QList<MyAtom> selected, QString resiSpec); //!< Insert DELU restrain to the ins file
220 void insertSIMU(double esd1, double st, double dmax, QList<MyAtom> selected, QString resiSpec); //!< Insert SIMU restrain to the ins file
221 void insertISOR(double esd1, double esd2, QList<MyAtom> selected, QString resiSpec); //!< Insert ISOR restrain to the ins file
222 void insertRIGU(double esd1, double esd2, QList<MyAtom> selected, QString resiSpec); //!< Insert DELU restrain to the ins file
223 void insertCHIV(double Vol, double esd1, QList<MyAtom> selected, QString resiSpec); //!< Insert CHIV restrain to the ins file
224 void insertANIS(QList<MyAtom> selected); //!< Insert ANIS instruction for selected atoms
225 void pivot1Changed(int i);
226 void pivot2Changed(int i);
227 void initialized();
228 void rebuffer(QVector< QVector< float > > &v, QVector< QVector< float > > &n);
229 public slots:
230 void rebuf(){
231 emit rebuffer(fVertexes,fNormals);
232 }
233 void printFPS();
234 void sdm();
235 void rotateIdle();
236 void along001();
237 void anaglyphRedCyan();
238 void changeBColor();
239 void changeEnviRange();
240 void changeTColor();
241 void changePivot1(int i){pivot=i;splitRotate();emit splitable(canSplitRotate()); }
242 void changePivot2(int i){pivot2=i;splitRotate();emit splitable(canSplitRotate());}
243 void clearEnvi();
244 // void clearLists();
245 void connectSelection();
246 void crosseye();
247 void disConnectSelection(int index);
248 void disSelection();
249 void envi();
250 void expand();
251 void fertig(){
252 habzutun=false;
253 update();
254 //printf("map veritces ready!\n");
255 }
256 void hardwareStereo();
257 void hideHydrogens();
258 void hideNonSelected();
259 void hideOtherFragments();
260 void hidePartMinusOne(bool off);
261 void hideQPeaksBelow(double cutoff);
262 void hideSelected();
263 void hideThisFragment();
264 void highliteQPeak(double co);
265 void homeXY();
266 void invertSelection();
267 void invertHidden();//!< Toggle visibility of atoms etc
268 void Listen();
269 void singleBondDistance();
270 void loadOrientation();
271 void loadOrientation(QString fn);
272 void nostereo();
273 void parallel();
274 void rehide();
275 void rotCenter();
276 void saveOrientation();
277 void saveOrientation(QString fn);
278 void selectEnvi();
279 void selectPair(const QString &s);
280 void selectResiByNr(int nr);
281 void selectThisFragment();
282 void setADP(bool b);
283 void setAtom(bool b);
284 void setBGGradient(bool b);
285 void setBond(bool b);
286 void setDepthCueing(bool b);
287 void setHBond(bool b);
288 void setLabel(bool b);
289 void setMSAA(bool b);
290 void setMatrix();
291 void setMolecule(Molecule *m);
292 void setReNaMo(bool b);
293 void setPickRad(double r){
294 pickradius = r*r;
295 showPickRad=true;
296 if (!pause) update();
297 }
298 void setRotationCenter();
299 void setRotationCenter(int rz);
300 void setRotationCenter(V3 center);
301 void setTube(bool b){
302 //!sets tube mode to b
303 tubes=b;
304 if (!pause) update();
305 }
306 void setUnit(bool b);
307 void setViewAngle(double ang);
308 void showHidden();
309 void showMatrix();
310 void splitRotate();
311 void toogleWithSymmetry(bool b);
312 void zoomOut();
313 void unsetTube(bool b){
314 //!sets tube mode to not b
315 tubes=!b;
316 if (!pause) update();
317 }
318 void updateLabelTextures();
319 void zalman();
320 // Restrain slots
321 void addDFIX();
322 void addDANG();
323 void addFLAT();
324 void addEXYZ();
325 void addEADP();
326 void addSADI();
327 void addDELU();
328 void addSIMU();
329 void addISOR();
330 void addRIGU();
331 void addCHIV();
332 void addANIS();
333 void wuff();
334
335 protected:
336 void initializeGL();
337 void resizeGL(int width, int height);
338 void paintGL();
339 //#if (QT_VERSION >= 0x040600) && (defined (Q_WS_MAC) || defined(Q_OS_MAC))
340 // bool event(QEvent *event);
341 //#endif
342 void mousePressEvent(QMouseEvent *event);
343 void mouseMoveEvent(QMouseEvent *event);
344 void contextMenuEvent(QContextMenuEvent *event);
345 void wheelEvent(QWheelEvent *event);
346 private:
347 QWidget *chparent;
348 bool was_short_labels = false;
349 QStringList labelTexts;
350 inline void __RotateCS( double c, double s, double& X, double& Y ) ;
351 void glTranslateL( const double dx, const double dy, const double dz );
352 void glRotateL( const double dang, const double x, const double y, const double z );
353 void glRotateMat( Matrix &mat, const double dang, const double x, const double y, const double z );
354 void findPivot();
355 void renderText(double x, double y, double z, const QString &str);
356 void renderText(double x, double y, const QString &str, int an);
357 void project(double x, double y, double z, GLdouble &tx, GLdouble &ty);
358 bool prepareShaderProgram(const QString& vertexShaderPath,
359 const QString& geometryShaderPath,
360 const QString& fragmentShaderPath);
361
362 QOpenGLShaderProgram m_shader;
363 int angleH, colorH;
364 GLfloat ang;
365 QList<int> seat;//selected atoms indices for splitrotation
366 int pivot,pivot2;
367 long long unsigned int frames_counter=0;
368 int ppp,pp,p;//there is no need this should longer GLuint 26.02.2020
369 //#if (QT_VERSION >= 0x040600) && (defined (Q_WS_MAC) || defined(Q_OS_MAC))
370 //bool gestureEvent(QGestureEvent *event);
371 //void pinchTriggered(QPinchGesture*);
372 //void swipeTriggered(QSwipeGesture*);
373 //#endif
374 bool mouseOverInteraction,atomsClickable,tubes,bggradient,depthcueing;
375 bool drawAx,drawUc,drawAt,drawADP,drawBo,drawLa,drawHb,drawFO,drawDF, warLabel;
376 bool showPickRad=false;
377 int imFokus,afok;
378 void draw();
379 Connection apair;
380 GLint vp[4];
381 int hideReason;
382 double qcutoff,pickradius;
383 int frid;
384 double labScal;
385 QList<QOpenGLTexture*> labelTextures;
386 QList<QOpenGLTexture*> extraTextures;
387 QList<QOpenGLTexture*> enviTextures;
388 int withsymm;
389 QPoint lastPos;
390 QStringList resis();
391 };
392
393 #endif // CHGL_H