Debian Codegraph @

opengltestwidget.h

raw symbols SCIP
1 #ifndef OPENGLTESTWIDGET_H
2 #define OPENGLTESTWIDGET_H
3
4 #include <QObject>
5 #include <QDialog>
6 #include <QOpenGLBuffer>
7 #include <QLabel>
8 #include <QMenu>
9 #include <QCheckBox>
10 #include <QToolButton>
11 #include <QToolBar>
12 #include <QColorDialog>
13 #include <QDoubleSpinBox>
14 #include <QOpenGLVertexArrayObject>
15 #include <QOpenGLShaderProgram>
16 #include <QComboBox>
17 #include "molecule.h"
18 #include "qpeakview.h"
19
20
21 #if defined (Q_OS_MAC)
22 #include <QOpenGLWindow>
23 class PlayOpenGL: public QOpenGLWindow, protected QOpenGLExtraFunctions { //
24 #else
25 #include <QOpenGLWidget>
26 class PlayOpenGL: public QOpenGLWidget, protected QOpenGLExtraFunctions { //
27 #endif
28
29 Q_OBJECT
30 public:
31 explicit PlayOpenGL( Molecule *externMole);
32 virtual ~PlayOpenGL() override;
33 void setMolecule(Molecule *m);
34 void setMainWindow(QWidget * parent){ chparent=parent; }
35 QColor farbverlaufQC(double wrt, double min, double max);
36 inline void __RotateCS( float c, float s, float& X, float& Y );
37 inline void __RotateCS( double c, double s, double& X, double& Y );
38 void glRotateMat( QMatrix4x4 &mat, const float dang, const float x , const float y, const float z ) ;
39 void glRotateMat( Matrix &mat, const float dang, const double x , const double y, const double z );
40 unsigned long long frame_cnt=0;
41
42 //QSize sizeHint() const override;
43 //QSize minimumSizeHint() const override;
44 bool drawBonds = true;
45 bool drawAtoms = true;
46 bool drawLabels = true;
47 bool isMainWindow = true;
48 bool isOrtho=true;
49 QString theIconPath;
50 int ImeanThisAtom;//!< atom index for context menu.
51 QMenu *sfacMenu;//!< a sub menu to change the element of a specified atom.
52 QMenu *selSfacMenu;
53 QList<QVector2D> screenAtoms;
54 //CEnvironment theAtoms;
55 QList<QImage> altLabels;
56 QToolButton *rCenter;
57 V3 sumse;
58 V3 altemitte;
59 int inFocus = -1;
60 int rotze = 1;// RotationsZentrum
61 double viewAngle = 29.0;
62 double previousViewAngle = 29.0;
63 float pickradius=256.0f;
64 int scrx=0,scry=0;
65 int scrx0=0,scry0=0;
66 bool rectangle=false;
67 void getMVmat(GLdouble mv[16]){
68 mv[0] = static_cast<GLdouble>(mvmat(0,0));
69 mv[1] = static_cast<GLdouble>(mvmat(1,0));
70 mv[2] = static_cast<GLdouble>(mvmat(2,0));
71 mv[3] = static_cast<GLdouble>(mvmat(3,0));
72
73 mv[4] = static_cast<GLdouble>(mvmat(0,1));
74 mv[5] = static_cast<GLdouble>(mvmat(1,1));
75 mv[6] = static_cast<GLdouble>(mvmat(2,1));
76 mv[7] = static_cast<GLdouble>(mvmat(3,1));
77
78 mv[8] = static_cast<GLdouble>(mvmat(0,2));
79 mv[9] = static_cast<GLdouble>(mvmat(1,2));
80 mv[10] = static_cast<GLdouble>(mvmat(2,2));
81 mv[11] = static_cast<GLdouble>(mvmat(3,2));
82
83
84 mv[12] = static_cast<GLdouble>(mvmat(0,3));
85 mv[13] = static_cast<GLdouble>(mvmat(1,3));
86 mv[14] = static_cast<GLdouble>(mvmat(2,3));
87 mv[15] = static_cast<GLdouble>(mvmat(3,3));
88
89 }
90
91 double envirange;
92 QVector4D rotstat;
93
94 QTimer *idl;//! idle rotation timer
95 QTimer *idl_end;//! idle rotation timer
96
97 QList<int> lastClicked();
98
99
100 bool hiddenThings=false;//!< We know that there are hidden objects.
101 bool neutrons=false;//!< true if we have neuton scattering factors (negative Fo map is shown if this is true)
102 bool atomsClickable=true;
103 int SDM_Limit; //!< if the number of atoms in the au exceeds this limit shortest distance is not computed automatically default 350
104 bool inRenameMode=false;//!< if true wee are in rename mode
105 bool exporting;//!< for exporting bitmaps
106
107 QToolButton *invertMouseZoom=nullptr;//!< inverts the mouse direction that zoom on right click.
108 QDoubleSpinBox *pickRadSpin=nullptr;
109
110
111 bool altpivot=false;
112 QComboBox *pivot1cb=nullptr;
113 QComboBox *pivot2cb=nullptr;
114 QDoubleSpinBox *axx=nullptr;
115 QDoubleSpinBox *axy=nullptr;
116 QDoubleSpinBox *axz=nullptr;
117 QDoubleSpinBox *orgx=nullptr;
118 QDoubleSpinBox *orgy=nullptr;
119 QDoubleSpinBox *orgz=nullptr;
120 QCheckBox *manualAx=nullptr;
121 QCheckBox *freeRot=nullptr;
122 QLabel *whyNotSplit=nullptr;
123 QSpinBox *angle1=nullptr;
124 QSpinBox *angle2=nullptr;
125 // void initLists();
126 bool canSplitRotate();
127
128 Connection apair;
129 bool showPickRad=false;
130 QColor labelColor;//!< Color of atom labels.
131 QColor selectedLabelColor;
132 QColor focusedLabelColor;
133
134 QColor labelBGColor;//!< Color of atom labels.
135 QColor selectedLabelBGColor;
136 QColor focusedLabelBGColor;
137 QColor backGroundColor;//!< Base color of the back groud.
138 struct labz{
139 int x,y;
140 QString l;
141 int an;
142 };//!< struct labels for exporting bitmaps
143 QList<labz> LabelZ;//!< labels for exporting bitmaps
144
145
146 //variables for maps...
147 double lintrans;//!<degree of thansparency for the maps 0-1. 0 is transparent.
148 double linwidth;//!<linewidth of the meshes.
149 double contMin;
150 double contMax;
151 QColor fopc;//!< Fo positive color
152 QColor fomc;//!< Fo negative color
153 QColor dipc;//!< Fo-Fc positive color
154 QColor dimc;//!< Fo-Fc negative color
155 QCheckBox *lighting;//!< enable lighting on the electron density.
156 QCheckBox *niceTrans;//!< draw 6 perspectives for each surface to improve transparent visualization.
157 QCheckBox *fillMap;//!< draw maps in filled style.
158 QAction *foact; //!< QAction toggling Fobs maps.
159 QAction *fofcact;//!< QAction toggling Fobs-Fcalc maps.
160 QVector< QVector< float > > fVertexes;
161 QVector< QVector< float > > fNormals;
162 bool vbyeye(VPoly a,VPoly b);
163 int commonFaces(Vert a,Vert b, int f[2]);
164 void voronoij(CEnvironment au, int intat);
165 QList<VPoly> vtriangles;
166 float InversionCenterRadius = 0.15;
167 float planeTransparence=0.2;
168 float glideVectorThickness=0.04;
169 float axisThickness=0.04;
170 float planeFrameThinkness=0.04;
171 double legend_sc = 0.6;
172 /*
173 QList<PPoly> ptriangles;
174 QList<V3> axvecs;
175 QList<int> axcols;
176 QList<int> axoprs;
177 QList<int> invoprs;
178 QList<V3> invvecs;*/
179 void setMapsStuff();
180 /*void setMapsStuff(QVector< QVector< float > > &_fVertexes,
181 QVector< QVector< float > > &_fNormals,
182 double *_lintrans,
183 double *_linwidth,
184 QColor *_fopc,
185 QColor *_fomc,
186 QColor *_dipc,
187 QColor *_dimc,
188 QCheckBox *_lighting,
189 QCheckBox *_niceTrans,
190 QCheckBox *_fillMap,
191 QAction *_foact,
192 QAction *_fofcact
193 );*/
194
195
196 //QAction *centerSelection;
197
198 QAction *h_bonds=nullptr;
199 QAction *adp=nullptr;
200 QAction *tubes=nullptr;
201 QAction *ballStick=nullptr;
202 QAction *QPeakLegend=nullptr;
203 QAction *hideHydrogen=nullptr;
204 QAction *addBond=nullptr;//!< QAction BIND
205 QAction *killBond=nullptr;//!< QAction FREE
206 QAction *clearSelection=nullptr;//!< QAction deselect
207 QAction *centerSelection=nullptr;//!< QAction center selected atoms
208 QAction *hideNotSelection=nullptr;//!< QAction hide non selected atoms
209 QAction *unhide=nullptr;//!< QAction show all previous hidden objects
210 QAction *invhide=nullptr;//!< QAction show all previous hidden and hide visible objects
211 QAction *grow=nullptr;//!< QAction grow
212 QAction *fuse=nullptr;//!< QAction fuse
213 QAction *shpm1=nullptr;//!< QAction show part -N ghost
214 QAction *qPeakBonds=nullptr;//!< QAction Q-Peak binds
215 QAction *toggleDockWidgets=nullptr;//!< QAction hide text windows
216 QAction *delSelAt=nullptr;//!< QAction delete selected atoms
217 QAction *highlightParts=nullptr; //!< QAction highlight atoms in parts != 0
218 QAction *centroid=nullptr; //!< QAction create a centroid dummy
219 QAction *enviNoQ=nullptr;//!< QAction ENVI only for real atoms
220 QAction *enviCova=nullptr;//!< QAction ENVI only for covalent contacts
221 QAction *invSelection=nullptr;//!< QAction invert selection
222 QAction *cntrPlot=nullptr;
223 QAction *nocntrPlot=nullptr;
224 QAction *rainbowPlot=nullptr;
225 QAction *togUnit=nullptr;
226 QAction *toggleOrthoView=nullptr;
227 QAction *hideBeLo=nullptr;//!< hide/show BEDE and LONE objects
228 QAction *shortLabels=nullptr;//!< Labels without residue number or symmery flag are considered short
229 QAction *atomLegend=nullptr;//!< a key legend for atoms used
230 double retinafktr=1.0;
231 //float bondStrength = 0.05f;
232 float qcutoff= -10.0;
233 //int LOD = 8;
234 double getScaleing(){ return L; }
235 QFont myFont;//!< there is a Font for Labels of atoms
236 QFont nonAtomFont;//!< there is a Font for Labels of Q-Peaks
237 bool bggradient = true;
238 bool shaderInfo = false;
239 //QColor bgcolor = QColor("lightskyblue");
240
241 Molecule *mol;
242 QToolButton *enviButt;//!< Button to clear the envi -ronment.
243 QToolButton *enviSelect;//!< Button to select the envi -ronment.
244 QList<V3>enviPositions;//!<List of atom postions of an envi-ronment.
245 QList<V3> cont;
246 QMap<int,GLfloat> contval;
247 QList<int>enviKat;//!< List of categorie:qs of contacts in an envi-ronment.
248 V3 enviP0;//!< coordinate used for envi.
249 QStringList labs;//!< Labels for an envi-ronment list.
250 bool burnGPU = false; // true is to measure FPS
251 bool isReady(){ return ready;}
252 void makeBonds(const CEnvironment &atoms, const Connection &bonds, const Connection &lbonds, Connection &hbonds);//, float* atomColors
253 void makeAtoms(const CEnvironment &atoms);
254 void makeClassicAtoms(const CEnvironment &atoms);
255 void makeSelectedAtoms();
256 void makeBackGround();
257 void makeEnvi();
258 void makeSplitRot();
259 void makeSymmetryElements();
260 void makeUnitCell();
261 void makeContours();
262 void contDestruct();
263 void voroDestruct();
264 void pushRotStat();
265 void popRotStat();
266 signals:
267 //void message(const QString &);//!< small text messages to the status bar.
268 //void qpfoci(double height);//!< when a mouse hovers a Q-Peak the height is emitted to the Q-Peak Legend.
269
270 void no_hw_st();//!< we have no hard ware stereo sorry!
271 void message(const QString &);//!< small text messages to the status bar.
272 void bigmessage(const QString &);//!< passes HTML strings to the info window.
273 void jumpit(int index);//!<An atom has ben left clicked: cursor jump on it.
274 void selectionChanged();
275 void movedByUser();
276 void diffscroll(int numsteps,int diff);//!< to change the iso value of the Fo- or Fo-Fc maps
277 void neuemitte(V3 mitte);//!< the rotation center has changet to mitte.
278 void inimibas();//!< tells FourXle to initialize the GL display lists.
279 void qpfoci(double height);//!< when a mouse hovers a Q-Peak the height is emitted to the Q-Peak Legend.
280 void insertDFIX(double value, double esd, QList<MyAtom> selected, QString resiSpec); //!< Insert DFIX restrain to the ins file
281 void bindthem();
282 void splitable(bool ok);
283 void insertDANG(double value, double esd, QList<MyAtom> selected, QString resiSpec); //!< Insert DANG restrain to the ins file
284 void insertFLAT(double esd, QList<MyAtom> selected, QString resiSpec); //!< Insert FLAT restrain to the ins file
285 void insertEXYZ(QList<MyAtom> selected); //!< Insert EXYZ restrain to the ins file
286 void insertEADP(QList<MyAtom> selected); //!< Insert EADP restrain to the ins file
287 void insertSADI(int selected); //!< Insert SADI restrain to the ins file
288 void insertDELU(double esd1, double esd2, QList<MyAtom> selected, QString resiSpec); //!< Insert DELU restrain to the ins file
289 void insertSIMU(double esd1, double st, double dmax, QList<MyAtom> selected, QString resiSpec); //!< Insert SIMU restrain to the ins file
290 void insertISOR(double esd1, double esd2, QList<MyAtom> selected, QString resiSpec); //!< Insert ISOR restrain to the ins file
291 void insertRIGU(double esd1, double esd2, QList<MyAtom> selected, QString resiSpec); //!< Insert DELU restrain to the ins file
292 void insertCHIV(double Vol, double esd1, QList<MyAtom> selected, QString resiSpec); //!< Insert CHIV restrain to the ins file
293 void insertANIS(QList<MyAtom> selected); //!< Insert ANIS instruction for selected atoms
294 void pivot1Changed(int i);
295 void pivot2Changed(int i);
296 void initialized();
297 void viewAngeleChanged(double);
298 void rebuffer(QVector< QVector< float > > &v, QVector< QVector< float > > &n);
299 public slots:
300 void rebuf(){
301 emit rebuffer(fVertexes,fNormals);
302 }
303 void addANIS();
304 void addCHIV();
305 void addDANG();
306 void addDELU();
307 void addDFIX();
308 void addEADP();
309 void addEXYZ();
310 void addFLAT();
311 void addISOR();
312 void addRIGU();
313 void addSADI();
314 void addSIMU();
315 void changeEnviRange();
316 void makeLegendAtoms();
317
318 void changeBColor(){//! a color dialog for chosing a new back ground color
319 QColor c= QColorDialog::getColor(backGroundColor);
320 if(c.isValid()) backGroundColor=c;
321 update();
322 }
323 void changeTColor(){//! a color dialog for chosing a new back ground color
324 QColor c= QColorDialog::getColor(backGroundColor);
325 if(c.isValid()) labelColor=c;
326 update();
327 }
328 double pickRad(){
329 return sqrt(pickradius);
330 }
331
332 void setPickRad(double r){
333 pickradius = r*r;
334 showPickRad=true;
335 }
336
337 void changePivot1(int i){pivot=i;splitRotate();emit splitable(canSplitRotate()); }
338 void changePivot2(int i){pivot2=i;splitRotate();emit splitable(canSplitRotate());}
339 void invertSelection(){
340 CEnvironment tempa=mol->selectedatoms;
341 // printf("invert %d %d\n",tempa.size(),mol->selectedatoms.size());
342 mol->selectedatoms.clear();
343
344 for (int i=0; i<mol->showatoms.size();i++){
345 if (!tempa.contains(mol->showatoms.at(i))) {
346 mol->selectedatoms.append(mol->showatoms[i]);
347 mol->selectedatoms.last().style=i;
348 }
349 }
350 rehide();
351 updateBondActions();
352 update();
353 }
354
355 void invertHidden(){
356 if (!hiddenThings) return; // nothing is hidden => hide everything now? NO!
357 hideHydrogen->setVisible(!hideHydrogen->isVisible());
358 for (int i=0;i<mol->legendAtoms.size();i++) mol->legendAtoms[i].hidden=1;
359 QHash<int,bool> anExists;
360 for (int i = 0; i < mol->showatoms.size(); i++){
361 mol->showatoms[i].hidden = (mol->showatoms.at(i).hidden!=0)?0:1;
362 if (!mol->showatoms.at(i).hidden) anExists[mol->showatoms.at(i).an]=true;
363 printf("%-4s %d %d\n",mol->showatoms.at(i).Label.toStdString().c_str(),mol->showatoms.at(i).hidden,mol->showatoms.at(i).an);
364 }
365 for (int i=0;i<mol->legendAtoms.size();i++) if (anExists.contains(mol->legendAtoms.at(i).an)) mol->legendAtoms[i].hidden=0;
366 //frid=-10;
367 //hideReason=0;
368 mol->selectedatoms.clear();
369 //murx=__LINE__;
370 makeAtoms(mol->showatoms);
371 makeBonds(mol->showatoms, mol->showbonds, mol->lbonds, mol->theH_Bonds);
372 updateBondActions();
373 update();
374 }
375
376 void hideHydrogens(){
377 hiddenThings=true;
378 //printf("hiddenThings hideHydrogens\n");
379 hideHydrogen->setVisible(false);
380 for (int i=0;i<mol->showatoms.size();i++) mol->showatoms[i].hidden=
381 (mol->showatoms.at(i).an==0)?1:mol->showatoms.at(i).hidden;
382 for (int i=0;i<mol->legendAtoms.size();i++) mol->legendAtoms[i].hidden=
383 (mol->legendAtoms.at(i).an==0)?1:mol->legendAtoms.at(i).hidden;
384 mol->selectedatoms.clear();
385 makeAtoms(mol->showatoms);
386 makeBonds(mol->showatoms, mol->showbonds, mol->lbonds, mol->theH_Bonds);
387 updateBondActions();
388 update();
389 }
390 void hidePartMinusOne(bool b){
391 update();
392 }
393 void clearEnvi();
394 void envi();
395 void growEnvi();
396 void showEnvi();
397 void expand();
398 void getReady(){ready=true;}
399 void hideOtherFragments();
400 void hideSelected();
401 void hideThisFragment();
402 void hideNonSelected(){
403 for (int i=0;i<mol->showatoms.size();i++) mol->showatoms[i].hidden=1;
404 for(int i=0;i<mol->selectedatoms.size();i++){
405 if (mol->selectedatoms.at(i).style < mol->showatoms.size())
406 mol->showatoms[mol->selectedatoms.at(i).style].hidden=0;
407 // std::cout<<mol->showatoms.at(mol->selectedatoms.at(i).style).Label.toStdString()<<std::endl;
408 }
409 hiddenThings=true;
410 //hideReason|=HIDE_REASON_SELECT;
411 mol->selectedatoms.clear();
412 //murx=-__LINE__;
413
414 makeAtoms(mol->showatoms);
415 makeBonds(mol->showatoms, mol->showbonds, mol->lbonds, mol->theH_Bonds);
416 updateBondActions();
417 update();
418 }
419 void selectEnvi();
420 void selectThisFragment();
421 void selectResiByNr(int nr){
422 //todo
423 mol->selectedatoms.clear();
424 apair.clear();
425 for (int i=0; i<mol->showatoms.size();i++){
426 if (mol->showatoms.at(i).resiNr==nr) {
427 mol->selectedatoms.append(mol->showatoms[i]);
428 mol->selectedatoms.last().style=i;
429 }
430 }
431 //draw();
432 if (hiddenThings) hideNonSelected();
433 updateBondActions();
434 update();
435 }
436
437 void showMatrix(){
438 //todo
439 }
440
441 void setReNaMo(bool b){
442 inRenameMode = b;
443 }
444
445 void saveOrientation(){
446 //todo
447 }
448
449 void loadOrientation(){
450 //todo
451 }
452
453 void fertig(){
454 // habzutun=false;
455 update();
456 //printf("map veritces ready!\n");
457 }
458 void setRotationCenter();
459 void setRotationCenter(int rz);
460 void setLabelSize(int s);
461 void setRotationCenter(V3 center);
462 void toogleWithSymmetry(bool b);
463 void singleBondDistance();
464
465 void zoomOut(){
466 //todo
467 }
468
469 void wuff(){
470 bool beloff=hideBeLo->isChecked();
471 for (int i=0;i<mol->showatoms.size();i++) if (mol->showatoms.at(i).an==-42) mol->showatoms[i].hidden=(beloff)?0:1;
472 for (int i=0;i<mol->legendAtoms.size();i++) if (mol->legendAtoms.at(i).an==-42) mol->legendAtoms[i].hidden=(beloff)?0:1;
473 hiddenThings=hiddenThings||(!hideBeLo->isChecked());
474 mol->selectedatoms.clear();
475 updateBondActions();
476 update();
477
478 }
479 void showHidden(){
480 printf("show hidden\n");
481 int h=0;
482 for (int i=0;i<mol->showatoms.size();i++){
483 mol->showatoms[i].hidden=0;
484 if (mol->showatoms[i].an==0)h++;
485 }
486 for (int i=0;i<mol->legendAtoms.size();i++) mol->legendAtoms[i].hidden=0;
487 if (h) hideHydrogen->setVisible(true);
488 hiddenThings=false;
489 hideBeLo->setChecked(true);//toggle state is OK this way
490 wuff();
491 makeAtoms(mol->showatoms);
492 makeBonds(mol->showatoms, mol->showbonds, mol->lbonds, mol->theH_Bonds);
493 makeLegendAtoms();
494 updateBondActions();
495 update();
496 }//todo!
497
498 void splitRotate();
499 void rehide(){
500
501 makeAtoms(mol->showatoms);
502 makeBonds(mol->showatoms, mol->showbonds, mol->lbonds, mol->theH_Bonds);
503 updateBondActions();
504 }//todo!!
505 void toggleOrtho(bool b);
506 void orthor(){
507 setViewAngle(viewAngle);
508 }
509 void makeMaps(QVector< QVector< float > > &v,QVector< QVector< float > > &n);
510 void highliteQPeak(double co);
511 void along001();
512 void zoom(double speed);
513 //bool isFO(){return drawFO;}//!< if Fo map is visible true is returned.
514 //bool isDF(){return drawDF;}//!< if Fo-Fc map is visible true is returned.
515 //void warFaul(){warfaul=true;}
516 void gZoom(double speed);
517 void rotZ(double speed=0.01);
518 void rotY(double speed=0.01);
519 void rotX(double speed=0.01);
520 void moveX(double speed);
521 void moveY(double speed);
522 void makeLabels();
523 void renderText(const QVector2D &scpos, const QString &text, int an);
524 void renderText(const QVector2D &scpos, const QString &text, int an, int pts);
525 void renderText(const QVector2D &scpos,int i);
526 void renderRect();
527 void renderText(const V3 &pos, const QString &text, QColor &color, uint bg = Qt::lightGray);
528 void renderText(QMatrix4x4 mat, int w, int h, const V3 &pos, const QString &text, QColor &color, uint bg = Qt::lightGray);
529 void rotCenter();
530 void setAtoms(bool b){drawAtoms = b; update();}
531 void setBonds(bool b){drawBonds = b; update();}
532 void setBondStrength(double s){ mol->bondStrength = static_cast<float>(s);update();}
533 void setLabels(bool b){drawLabels = b; update();}
534 void setBGGradient(bool b){bggradient=b; update();}
535 void setLOD(int l){mol->LOD=l;update();}
536 void homeXY();
537 void setViewAngle(double ang);
538 void setQpeakCutoff(double cut){
539 qcutoff = static_cast<float>(cut);
540 update();
541 }
542 void toggleAutoUpdate(int b){
543 burnGPU = (b==Qt::Checked);
544 if (burnGPU){
545 if (!tmr){
546 tmr = new QTimer();
547 connect(tmr, &QTimer::timeout, this, &PlayOpenGL::reportFPS);
548 }
549 tmr->start(1000);
550
551 }else{
552 if (tmr) tmr->stop();
553 }
554 printf("burn GPU! %d\n",burnGPU);
555 update();
556 }
557 void updateBondActions();
558 void updateSceenAtoms();
559
560 void connectSelection();
561 void disConnectSelection(int index);
562 void disSelection();
563 void reportFPS(){
564 if (!burnGPU) return;
565 QString s = QString("FPS: %1").arg(frame_cnt / 1.0,0,'f',1);
566 frame_cnt = 0;
567 emit message(s);
568 }
569 protected:
570 void initializeGL() override;
571 void resizeGL(int width, int height) override;
572 void paintGL() override;
573 void mouseMoveEvent(QMouseEvent *event) override;
574 void mousePressEvent(QMouseEvent *event) override;
575 void wheelEvent(QWheelEvent *event) override;
576 void contextMenuEvent(QMouseEvent *event);// override;
577 private:
578 QWidget *chparent;
579 QTimer *tmr = nullptr;
580 QMenu *menu = nullptr;
581 QMenu *restrMenu = nullptr ;
582 QMenu *constrMenu = nullptr;
583 QMenu *enviMenu = nullptr;
584 bool ready=false;
585 int withsymm;
586
587 QList<int> seat;//selected atoms indices for splitrotation
588 int pivot;
589 int pivot2;
590 int ppp=0,pp=0,p=0;//there is no need this should longer GLuint 26.02.2020
591 QString glTypeInt2String(int ityp);
592 QStringList resis();
593 void programInfo(QOpenGLShaderProgram *p, const QString pname);
594 double moux, mouy,L;
595 QOpenGLVertexArrayObject bond_vao;
596 QOpenGLVertexArrayObject atom_vao;
597 QOpenGLVertexArrayObject catom_vao;
598 QOpenGLVertexArrayObject latom_vao;
599 QOpenGLVertexArrayObject bg_vao;
600 QOpenGLVertexArrayObject slct_vao;
601 QOpenGLVertexArrayObject map_vao;
602 QOpenGLVertexArrayObject voro_vao;
603 QOpenGLVertexArrayObject envi_vao;
604 QOpenGLVertexArrayObject uc_vao;
605 QOpenGLVertexArrayObject cont_vao;
606 QOpenGLVertexArrayObject symm_vao0;
607 QOpenGLVertexArrayObject symm_vao1;
608 QOpenGLVertexArrayObject symm_vao2;
609 QOpenGLVertexArrayObject splitrot_vao;
610
611 QOpenGLBuffer atom_vertexBuffer;
612 QOpenGLBuffer atom_indexBuffer;
613
614 QOpenGLBuffer catom_vertexBuffer;
615 QOpenGLBuffer catom_indexBuffer;
616
617 QOpenGLBuffer latom_vertexBuffer;
618 QOpenGLBuffer latom_indexBuffer;
619
620 QOpenGLBuffer satom_vertexBuffer;
621 QOpenGLBuffer satom_indexBuffer;
622
623 int atom_index_size;
624 int catom_index_size;
625
626 int latom_index_size;
627
628 int axend = 0;
629 int invend = 0;
630 int planend = 0;
631 int glend = 0;
632 QOpenGLBuffer backGround_vertexBuffer;
633 QOpenGLBuffer bond_vertexBuffer;
634 QOpenGLBuffer bond_indexBuffer;
635 QOpenGLBuffer map_vertexBuffer;
636 QOpenGLBuffer envi_vertexBuffer;
637 QOpenGLBuffer voro_vertexBuffer;
638 QOpenGLBuffer uc_vertexBuffer;
639 QOpenGLBuffer cont_vertexBuffer;
640 QOpenGLBuffer symm_vertexBuffer0;
641 QOpenGLBuffer symm_vertexBuffer1;
642 QOpenGLBuffer symm_vertexBuffer2;
643 QOpenGLBuffer splitrot_vertexBuffer;
644 QOpenGLBuffer splitrot_indexBuffer;
645
646 QOpenGLShaderProgram *symm_program0 = nullptr;
647 QOpenGLShaderProgram *symm_program1 = nullptr;
648 QOpenGLShaderProgram *symm_program2 = nullptr;
649 QOpenGLShaderProgram *splitrot_program = nullptr;
650 QOpenGLShaderProgram *cont_program = nullptr;
651 QOpenGLShaderProgram *uc_program = nullptr;
652 QOpenGLShaderProgram *voro_program = nullptr;
653 QOpenGLShaderProgram *bg_program = nullptr;
654 QOpenGLShaderProgram *map_program = nullptr;
655 QOpenGLShaderProgram *bond_program = nullptr;
656 QOpenGLShaderProgram *atom_program = nullptr;// let's nuce the code with this name ;-P
657 QOpenGLShaderProgram *catom_program = nullptr;
658 QOpenGLShaderProgram *satom_program = nullptr;
659 QOpenGLShaderProgram *envi_program = nullptr;
660 QList<int> offsets;
661 QMatrix4x4 pmv;
662 QMatrix3x3 nm;
663 QVector4D eye;
664 int nbondx2=0;
665
666 int bondStrengthloc;
667 int lodloc;
668 V3 screenRotx=V3(1,0,0);
669 V3 screenRoty=V3(0,1,0);
670 V3 SRorg=V3(0,0,0);
671
672
673 QMatrix4x4 pmat, mvmat;
674 Matrix freeRotMat=Matrix(1,0,0 ,0,1,0, 0,0,1);
675 double fdx=0.0;
676 double fdy=0.0;
677 GLfloat ang;
678 void findPivot();
679 };
680
681
682 class OpenGLTestWidget : public QDialog {
683 Q_OBJECT
684 public:
685 explicit OpenGLTestWidget(Molecule *externMole, QList<QAction*> &acts, QWidget *parent = nullptr);
686 PlayOpenGL *ogl;
687 QLabel *fpslabel;
688 QLabel *messagelabel;
689 QPeakView *qpv;
690 QToolBar *vito;
691 QDoubleSpinBox *fov;
692 QWidget *container;
693 QSize sizeHint() const override;
694 QSize minimumSizeHint() const override;
695
696 public slots:
697 void printFPS();
698 void updateMessage(QString);
699 void setViewAngle(double);
700 signals:
701
702 };
703
704 #endif // OPENGLTESTWIDGET_H