| 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 |
|
| 43 |
|
| 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; |
| 51 |
QMenu *sfacMenu; |
| 52 |
QMenu *selSfacMenu; |
| 53 |
QList<QVector2D> screenAtoms; |
| 54 |
|
| 55 |
QList<QImage> altLabels; |
| 56 |
QToolButton *rCenter; |
| 57 |
V3 sumse; |
| 58 |
V3 altemitte; |
| 59 |
int inFocus = -1; |
| 60 |
int rotze = 1; |
| 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; |
| 95 |
QTimer *idl_end; |
| 96 |
|
| 97 |
QList<int> lastClicked(); |
| 98 |
|
| 99 |
|
| 100 |
bool hiddenThings=false; |
| 101 |
bool neutrons=false; |
| 102 |
bool atomsClickable=true; |
| 103 |
int SDM_Limit; |
| 104 |
bool inRenameMode=false; |
| 105 |
bool exporting; |
| 106 |
|
| 107 |
QToolButton *invertMouseZoom=nullptr; |
| 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 |
|
| 126 |
bool canSplitRotate(); |
| 127 |
|
| 128 |
Connection apair; |
| 129 |
bool showPickRad=false; |
| 130 |
QColor labelColor; |
| 131 |
QColor selectedLabelColor; |
| 132 |
QColor focusedLabelColor; |
| 133 |
|
| 134 |
QColor labelBGColor; |
| 135 |
QColor selectedLabelBGColor; |
| 136 |
QColor focusedLabelBGColor; |
| 137 |
QColor backGroundColor; |
| 138 |
struct labz{ |
| 139 |
int x,y; |
| 140 |
QString l; |
| 141 |
int an; |
| 142 |
}; |
| 143 |
QList<labz> LabelZ; |
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
double lintrans; |
| 148 |
double linwidth; |
| 149 |
double contMin; |
| 150 |
double contMax; |
| 151 |
QColor fopc; |
| 152 |
QColor fomc; |
| 153 |
QColor dipc; |
| 154 |
QColor dimc; |
| 155 |
QCheckBox *lighting; |
| 156 |
QCheckBox *niceTrans; |
| 157 |
QCheckBox *fillMap; |
| 158 |
QAction *foact; |
| 159 |
QAction *fofcact; |
| 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 |
|
| 174 |
|
| 175 |
|
| 176 |
|
| 177 |
|
| 178 |
|
| 179 |
void setMapsStuff(); |
| 180 |
|
| 181 |
|
| 182 |
|
| 183 |
|
| 184 |
|
| 185 |
|
| 186 |
|
| 187 |
|
| 188 |
|
| 189 |
|
| 190 |
|
| 191 |
|
| 192 |
|
| 193 |
|
| 194 |
|
| 195 |
|
| 196 |
|
| 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; |
| 205 |
QAction *killBond=nullptr; |
| 206 |
QAction *clearSelection=nullptr; |
| 207 |
QAction *centerSelection=nullptr; |
| 208 |
QAction *hideNotSelection=nullptr; |
| 209 |
QAction *unhide=nullptr; |
| 210 |
QAction *invhide=nullptr; |
| 211 |
QAction *grow=nullptr; |
| 212 |
QAction *fuse=nullptr; |
| 213 |
QAction *shpm1=nullptr; |
| 214 |
QAction *qPeakBonds=nullptr; |
| 215 |
QAction *toggleDockWidgets=nullptr; |
| 216 |
QAction *delSelAt=nullptr; |
| 217 |
QAction *highlightParts=nullptr; |
| 218 |
QAction *centroid=nullptr; |
| 219 |
QAction *enviNoQ=nullptr; |
| 220 |
QAction *enviCova=nullptr; |
| 221 |
QAction *invSelection=nullptr; |
| 222 |
QAction *cntrPlot=nullptr; |
| 223 |
QAction *nocntrPlot=nullptr; |
| 224 |
QAction *rainbowPlot=nullptr; |
| 225 |
QAction *togUnit=nullptr; |
| 226 |
QAction *toggleOrthoView=nullptr; |
| 227 |
QAction *hideBeLo=nullptr; |
| 228 |
QAction *shortLabels=nullptr; |
| 229 |
QAction *atomLegend=nullptr; |
| 230 |
double retinafktr=1.0; |
| 231 |
|
| 232 |
float qcutoff= -10.0; |
| 233 |
|
| 234 |
double getScaleing(){ return L; } |
| 235 |
QFont myFont; |
| 236 |
QFont nonAtomFont; |
| 237 |
bool bggradient = true; |
| 238 |
bool shaderInfo = false; |
| 239 |
|
| 240 |
|
| 241 |
Molecule *mol; |
| 242 |
QToolButton *enviButt; |
| 243 |
QToolButton *enviSelect; |
| 244 |
QList<V3>enviPositions; |
| 245 |
QList<V3> cont; |
| 246 |
QMap<int,GLfloat> contval; |
| 247 |
QList<int>enviKat; |
| 248 |
V3 enviP0; |
| 249 |
QStringList labs; |
| 250 |
bool burnGPU = false; |
| 251 |
bool isReady(){ return ready;} |
| 252 |
void makeBonds(const CEnvironment &atoms, const Connection &bonds, const Connection &lbonds, Connection &hbonds); |
| 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 |
|
| 268 |
|
| 269 |
|
| 270 |
void no_hw_st(); |
| 271 |
void message(const QString &); |
| 272 |
void bigmessage(const QString &); |
| 273 |
void jumpit(int index); |
| 274 |
void selectionChanged(); |
| 275 |
void movedByUser(); |
| 276 |
void diffscroll(int numsteps,int diff); |
| 277 |
void neuemitte(V3 mitte); |
| 278 |
void inimibas(); |
| 279 |
void qpfoci(double height); |
| 280 |
void insertDFIX(double value, double esd, QList<MyAtom> selected, QString resiSpec); |
| 281 |
void bindthem(); |
| 282 |
void splitable(bool ok); |
| 283 |
void insertDANG(double value, double esd, QList<MyAtom> selected, QString resiSpec); |
| 284 |
void insertFLAT(double esd, QList<MyAtom> selected, QString resiSpec); |
| 285 |
void insertEXYZ(QList<MyAtom> selected); |
| 286 |
void insertEADP(QList<MyAtom> selected); |
| 287 |
void insertSADI(int selected); |
| 288 |
void insertDELU(double esd1, double esd2, QList<MyAtom> selected, QString resiSpec); |
| 289 |
void insertSIMU(double esd1, double st, double dmax, QList<MyAtom> selected, QString resiSpec); |
| 290 |
void insertISOR(double esd1, double esd2, QList<MyAtom> selected, QString resiSpec); |
| 291 |
void insertRIGU(double esd1, double esd2, QList<MyAtom> selected, QString resiSpec); |
| 292 |
void insertCHIV(double Vol, double esd1, QList<MyAtom> selected, QString resiSpec); |
| 293 |
void insertANIS(QList<MyAtom> selected); |
| 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(){ |
| 319 |
QColor c= QColorDialog::getColor(backGroundColor); |
| 320 |
if(c.isValid()) backGroundColor=c; |
| 321 |
update(); |
| 322 |
} |
| 323 |
void changeTColor(){ |
| 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 |
|
| 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; |
| 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 |
|
| 367 |
|
| 368 |
mol->selectedatoms.clear(); |
| 369 |
|
| 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 |
|
| 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 |
|
| 408 |
} |
| 409 |
hiddenThings=true; |
| 410 |
|
| 411 |
mol->selectedatoms.clear(); |
| 412 |
|
| 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 |
|
| 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 |
|
| 432 |
if (hiddenThings) hideNonSelected(); |
| 433 |
updateBondActions(); |
| 434 |
update(); |
| 435 |
} |
| 436 |
|
| 437 |
void showMatrix(){ |
| 438 |
|
| 439 |
} |
| 440 |
|
| 441 |
void setReNaMo(bool b){ |
| 442 |
inRenameMode = b; |
| 443 |
} |
| 444 |
|
| 445 |
void saveOrientation(){ |
| 446 |
|
| 447 |
} |
| 448 |
|
| 449 |
void loadOrientation(){ |
| 450 |
|
| 451 |
} |
| 452 |
|
| 453 |
void fertig(){ |
| 454 |
|
| 455 |
update(); |
| 456 |
|
| 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 |
|
| 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); |
| 490 |
wuff(); |
| 491 |
makeAtoms(mol->showatoms); |
| 492 |
makeBonds(mol->showatoms, mol->showbonds, mol->lbonds, mol->theH_Bonds); |
| 493 |
makeLegendAtoms(); |
| 494 |
updateBondActions(); |
| 495 |
update(); |
| 496 |
} |
| 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 |
} |
| 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 |
|
| 514 |
|
| 515 |
|
| 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); |
| 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; |
| 588 |
int pivot; |
| 589 |
int pivot2; |
| 590 |
int ppp=0,pp=0,p=0; |
| 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; |
| 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 |