| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 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 |
|
| 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 |
|
| 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; |
| 54 |
QTimer *idl_end; |
| 55 |
bool on; |
| 56 |
bool habzutun; |
| 57 |
QString theIconPath; |
| 58 |
int ww, |
| 59 |
wh, |
| 60 |
minus; |
| 61 |
int SDM_Limit; |
| 62 |
double retinafktr; |
| 63 |
int stereo_mode; |
| 64 |
int objCnt; |
| 65 |
int ImeanThisAtom; |
| 66 |
double viewAngle, |
| 67 |
envirange; |
| 68 |
QColor labelColor, |
| 69 |
backGroundColor; |
| 70 |
bool pause, |
| 71 |
inRenameMode, |
| 72 |
noWaitLabel, |
| 73 |
exporting; |
| 74 |
QVector< QVector< float > > fVertexes; |
| 75 |
QVector< QVector< float > > fNormals; |
| 76 |
double lintrans; |
| 77 |
double linwidth; |
| 78 |
double contMin,contMax; |
| 79 |
QColor fopc; |
| 80 |
QColor fomc; |
| 81 |
QColor dipc; |
| 82 |
QColor dimc; |
| 83 |
struct labz{ |
| 84 |
int x,y; |
| 85 |
QString l; |
| 86 |
int an; |
| 87 |
}; |
| 88 |
QList<labz> LabelZ; |
| 89 |
bool hiddenThings; |
| 90 |
bool neutrons; |
| 91 |
int dratpause; |
| 92 |
QFont myFont, |
| 93 |
nonAtomFont; |
| 94 |
QTimer *moving; |
| 95 |
GLdouble MM[16]; |
| 96 |
QAction *addBond, |
| 97 |
*killBond, |
| 98 |
*clearSelection, |
| 99 |
*centerSelection, |
| 100 |
*hideNotSelection, |
| 101 |
*unhide, |
| 102 |
*invhide, |
| 103 |
*grow, |
| 104 |
*fuse, |
| 105 |
*shpm1, |
| 106 |
*hideh, |
| 107 |
*qPeakBonds, |
| 108 |
*toggleDockWidgets, |
| 109 |
*delSelAt, |
| 110 |
*highlightParts, |
| 111 |
*centroid, |
| 112 |
*enviNoQ, |
| 113 |
*enviCova, |
| 114 |
*wireButt, |
| 115 |
*invSelection, |
| 116 |
*cntrPlot, |
| 117 |
*nocntrPlot, |
| 118 |
*rainbowPlot, |
| 119 |
*hideBeLo, |
| 120 |
|
| 121 |
*shortLabels, |
| 122 |
*atomLegend; |
| 123 |
QToolButton *enviButt; |
| 124 |
QToolButton *enviSelect; |
| 125 |
QList<V3>enviPositions; |
| 126 |
QList<V3> cont; |
| 127 |
QMap<int,GLfloat> contval; |
| 128 |
QList<int>enviKat; |
| 129 |
V3 enviP0; |
| 130 |
QMenu *sfacMenu; |
| 131 |
QStringList labs; |
| 132 |
Molecule *mol; |
| 133 |
int murx; |
| 134 |
|
| 135 |
|
| 136 |
double L; |
| 137 |
QAction *foact, |
| 138 |
*fofcact; |
| 139 |
int rotze; |
| 140 |
QToolButton *invertMouseZoom; |
| 141 |
QCheckBox *lighting; |
| 142 |
QCheckBox *niceTrans; |
| 143 |
QCheckBox *fillMap; |
| 144 |
QToolButton *rCenter; |
| 145 |
V3 altemitte; |
| 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 |
|
| 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;} |
| 173 |
bool isDF(){return drawDF;} |
| 174 |
|
| 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(); |
| 202 |
void message(const QString &); |
| 203 |
void bigmessage(const QString &); |
| 204 |
void jumpit(int index); |
| 205 |
void selectionChanged(); |
| 206 |
void movedByUser(); |
| 207 |
void diffscroll(int numsteps,int diff); |
| 208 |
void neuemitte(V3 mitte); |
| 209 |
void inimibas(); |
| 210 |
void qpfoci(double height); |
| 211 |
void insertDFIX(double value, double esd, QList<MyAtom> selected, QString resiSpec); |
| 212 |
void bindthem(); |
| 213 |
void splitable(bool ok); |
| 214 |
void insertDANG(double value, double esd, QList<MyAtom> selected, QString resiSpec); |
| 215 |
void insertFLAT(double esd, QList<MyAtom> selected, QString resiSpec); |
| 216 |
void insertEXYZ(QList<MyAtom> selected); |
| 217 |
void insertEADP(QList<MyAtom> selected); |
| 218 |
void insertSADI(int selected); |
| 219 |
void insertDELU(double esd1, double esd2, QList<MyAtom> selected, QString resiSpec); |
| 220 |
void insertSIMU(double esd1, double st, double dmax, QList<MyAtom> selected, QString resiSpec); |
| 221 |
void insertISOR(double esd1, double esd2, QList<MyAtom> selected, QString resiSpec); |
| 222 |
void insertRIGU(double esd1, double esd2, QList<MyAtom> selected, QString resiSpec); |
| 223 |
void insertCHIV(double Vol, double esd1, QList<MyAtom> selected, QString resiSpec); |
| 224 |
void insertANIS(QList<MyAtom> selected); |
| 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 |
|
| 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 |
|
| 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(); |
| 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 |
|
| 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 |
|
| 315 |
tubes=!b; |
| 316 |
if (!pause) update(); |
| 317 |
} |
| 318 |
void updateLabelTextures(); |
| 319 |
void zalman(); |
| 320 |
|
| 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 |
|
| 340 |
|
| 341 |
|
| 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; |
| 366 |
int pivot,pivot2; |
| 367 |
long long unsigned int frames_counter=0; |
| 368 |
int ppp,pp,p; |
| 369 |
|
| 370 |
|
| 371 |
|
| 372 |
|
| 373 |
|
| 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 |