1
2 /****************************************************************************
3 **
4 ** Copyright (C) 2011 Christian B. Huebschle & George M. Sheldrick
5 ** All rights reserved.
6 ** Contact: chuebsch@moliso.de
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 #include "eacDlg.h"
20 #include "deprecation.h"
21 //#if defined (Q_WS_MAC) || defined (Q_OS_MAC)
22 //#include <OpenGL/glu.h>
23 // //#include <glu.h>
24 //#else
25 //#include <GL/glu.h>
26 //#endif
27 #include "itsme.h"
28 #ifndef GL_MULTISAMPLE
29 #define GL_MULTISAMPLE 0x809D
30 #endif
31 /*
32 extern void __RotateCS( double c, double s, double& X, double& Y );
33 extern void glTranslateL( const double dx, const double dy, const double dz );
34 extern void glRotateL( const double dang, const double x, const double y, const double z );
35 */
36
EacGLW(Molecule * externMole,QWidget * parent)37 EacGLW::EacGLW(Molecule *externMole, QWidget * parent): QGLWidget(QGLFormat(QGL::SampleBuffers),parent){
38 this->setParent(parent);
39 mol=externMole;
40 exmin=mol->pmin;
41 exmax=mol->pmax;
42 mol->pmax=0.99;
43 mol->pmin=0.39;
44 //mol->copyAcol(mol->AtomColor,mol->arad,mol->AtomStyle);
45 //mol->loadSettings();
46 proba=50;
47 MyAtom xda;
48 xda.symmGroup=0;
49 xda.hidden=0;
50 xda.part=0;
51 //xda.ownStyle=false;
52 xda.Label="H";
53 xda.pos.x=0;
54 xda.pos.y=0;
55 xda.pos.z=0;
56 xda.uc.m11=0.1;
57 xda.uc.m22=0.07;
58 xda.uc.m33=0.025;
59 xda.uc.m13=xda.uc.m31=0.01;
60 xda.uc.m12=xda.uc.m21=-0.02;
61 xda.uc.m23=xda.uc.m32=0.01;
62 xda.an=6;
63 xd.append(xda);
64
65 xda.Label="H1(noADP)";
66 xda.pos.x=0.00001;
67 xda.pos.y=0.00001;
68 xda.pos.z=1.0;
69 // xda.ownStyle=true;
70 //xda.style=ATOM_STYLE_NOADP;
71 //xda.rad=mol->arad[0];
72 //xda.color=mol->AtomColor[0];
73 xda.uc.m11=0.05;
74 xda.uc.m22=0.05;
75 xda.uc.m33=0.05;
76 xda.uc.m13=0.0;
77 xda.uc.m12=0.0;
78 xda.uc.m23=0.0;
79 xda.an=0;
80 xd.append(xda);
81
82 xda.Label="H2";
83 //xda.ownStyle=false;
84 xda.pos.x=0.81649658102978810529098386315336;
85 xda.pos.y=-0.4714045208499572479996295714055;
86 xda.pos.z=-0.333333;
87 xda.uc.m11=0.05;
88 xda.uc.m22=0.05;
89 xda.uc.m33=0.05;
90 xda.uc.m13=0.0;
91 xda.uc.m12=0.0;
92 xda.uc.m23=0.0;
93 xda.an=0;
94 xd.append(xda);
95
96 xda.Label="H3";
97 xda.pos.x=0;
98 xda.pos.y=0.94280904169991449599925914281199;
99 xda.pos.z=-0.333333;
100 xda.uc.m11=0.05;
101 xda.uc.m22=0.05;
102 xda.uc.m33=0.05;
103 xda.uc.m13=0.0;
104 xda.uc.m12=0.0;
105 xda.uc.m23=0.0;
106 xda.an=0;
107 xd.append(xda);
108
109 xda.Label="H4";
110 xda.pos.x=-0.81649658102978810529098386315336;
111 xda.pos.y=-0.4714045208499572479996295714055;
112 xda.pos.z=-0.333333;
113 xda.uc.m11=0.05;
114 xda.uc.m22=0.05;
115 xda.uc.m33=0.05;
116 xda.uc.m13=0.0;
117 xda.uc.m12=0.0;
118 xda.uc.m23=0.0;
119 xda.an=0;
120 xd.append(xda);
121 xda.Label="Q1";
122 xda.pos.x=-0.81649658102978810529098386315336;
123 xda.pos.y=-0.4714045208499572479996295714055;
124 xda.pos.z=0.333333;
125 xda.peakHeight=0.91;
126 xda.uc.m11=0.05;
127 xda.uc.m22=0.05;
128 xda.uc.m33=0.05;
129 xda.uc.m13=0.0;
130 xda.uc.m12=0.0;
131 xda.uc.m23=0.0;
132 xda.an=-1;
133 xd.append(xda);
134 xda.Label="Q2";
135 xda.pos.x=0.81649658102978810529098386315336;
136 xda.pos.y=0.4714045208499572479996295714055;
137 xda.pos.z=0.333333;
138 xda.peakHeight=0.41;
139 xda.uc.m11=0.05;
140 xda.uc.m22=0.05;
141 xda.uc.m33=0.05;
142 xda.uc.m13=0.0;
143 xda.uc.m12=0.0;
144 xda.uc.m23=0.0;
145 xda.an=-1;
146 xd.append(xda);
147 xda.Label="Q3";
148 xda.pos.x=0;
149 xda.pos.y=-0.94280904169991449599925914281199;
150 xda.pos.z=0.333333;
151 xda.peakHeight=0.71;
152 xda.uc.m11=0.05;
153 xda.uc.m22=0.05;
154 xda.uc.m33=0.05;
155 xda.uc.m13=0.0;
156 xda.uc.m12=0.0;
157 xda.uc.m23=0.0;
158 xda.an=-1;
159 xd.append(xda);
160 bonds=mol->connecting(xd,true);
161 xd[0].an=0;//das ist ein ... trick um bindungen vom zentralatom zu den liganden zu erzeugen.
162 /*
163
164 MyBond b;
165 b.ato1=&xd[0];
166 b.ato2=&xd[1];
167 b.a1=0;
168 b.a2=1;
169 b.length=1;
170 bonds.append(b);
171 b.ato1=&xd[0];
172 b.ato2=&xd[2];
173 b.a1=0;
174 b.a2=2;
175 b.length=1;
176 bonds.append(b);
177 b.ato1=&xd[0];
178 b.ato2=&xd[3];
179 b.a1=0;
180 b.a2=3;
181 b.length=1;
182 bonds.append(b);
183 b.ato1=&xd[0];
184 b.ato2=&xd[4];
185 b.a1=0;
186 b.a2=4;
187 b.length=1;
188 bonds.append(b);
189 */
190 }
191
setMSAA(bool b)192 void EacGLW::setMSAA(bool b){
193 QGLFormat glf = format();
194 printf("sampleBuffers = %d samples %d\n",glf.sampleBuffers(),glf.samples());
195 if (b) {
196 glEnable(GL_MULTISAMPLE);
197 }
198 else {
199 glDisable(GL_MULTISAMPLE);;
200 }
201 updateGL();
202 }
draw()203 void EacGLW::draw(){
204 //int pr;
205 //glGetIntegerv(GL_CURRENT_PROGRAM,&pr);
206 //printf("@@@%d %d \n",pr,mol->g_program);
207 const GLfloat OBJ_SPE[] = { 0.8f, 0.8f, 0.8f, 1.0f };
208 const GLfloat OBJ_SHIN = 32.0f;
209 glMaterialfv( GL_FRONT_AND_BACK, GL_SPECULAR, OBJ_SPE );
210 glEnable ( GL_COLOR_MATERIAL ) ;
211 glColorMaterial ( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE ) ;
212 glMaterialf( GL_FRONT_AND_BACK, GL_SHININESS, OBJ_SHIN );
213 static double rtx=2.0;
214 glRotated(rtx,1.0,0.0,0.0);
215 glRotated(rtx,0.0,1.0,0.0);
216 rtx+=0.5;
217 mol->dratom=0;
218 //mol->nonPositiveDefinite=0;
219 // mol->parthigh=false;
220 glPushMatrix();
221 glScaled( 40, 40, 40 );
222 mol->adp=1;
223 mol->intern=1;
224 mol->tubes=0;
225 glEnable(GL_CULL_FACE);
226 mol->atoms(xd,proba);
227 glDisable(GL_CULL_FACE);
228 if (mol->bondColorStyle){
229 qglColor(mol->bondColor);
230 glDisable(GL_COLOR_MATERIAL);
231 }
232 mol->bonds(bonds);
233 glEnable(GL_COLOR_MATERIAL);
234 glEnable(GL_BLEND);
235 mol->intern=0;
236 mol->dratom=0;
237 if (!mol->useShaders) mol->atoms(xd,proba);
238 mol->lbond();
239 glDisable(GL_BLEND);
240 glColor3f(0,0,0);
241 glClear( GL_DEPTH_BUFFER_BIT);
242 for (int i=0; i<xd.size();i++){
243 if ((i==1)||(!(mol->AtomStyle[xd[i].an]&ATOM_STYLE_NOLABEL)))
244 renderText( xd.at(i).pos.x,xd.at(i).pos.y,xd.at(i).pos.z, xd.at(i).Label,myFont);
245 }
246 glPopMatrix();
247 }
initializeGL()248 void EacGLW::initializeGL(){
249 glEnable(GL_LINE_SMOOTH);
250 glHint(GL_LINE_SMOOTH_HINT,GL_NICEST);
251
252 timer = new QTimer(this);
253 connect( timer, SIGNAL(timeout()),
254 this, SLOT(updateGL()) );
255 // Jede Sekunde updateTime() aufrufen
256 timer->start(20);
257
258 //glEnable(GL_POLYGON_SMOOTH);
259 myFont= QFont("Arial", 18, -1, false);
260 const GLfloat position[] = {100.0f, 100.0f,100.0f,0.0f};
261 const GLfloat diffuse[] = { 1.0f, 1.0f, 1.0f, 1.0f };
262 const GLfloat specular[] = { 1.0f, 0.9f, 0.9f, 1.0f };
263 const GLfloat ambient[] = { 0.4f, 0.4f, 0.4f, 1.0f };
264
265 glLightModeli( GL_LIGHT_MODEL_LOCAL_VIEWER, 1 );
266
267 glLightfv( GL_LIGHT0, GL_POSITION, position );
268 glLightfv( GL_LIGHT0, GL_AMBIENT, ambient );
269 glLightfv( GL_LIGHT0, GL_DIFFUSE, diffuse );
270 glLightfv( GL_LIGHT0, GL_SPECULAR, specular );
271
272 glLightfv( GL_LIGHT1, GL_POSITION, position );
273 glLightfv( GL_LIGHT1, GL_DIFFUSE, diffuse );
274 glLightfv( GL_LIGHT1, GL_AMBIENT, ambient );
275 glLightModeli( GL_LIGHT_MODEL_TWO_SIDE, 1);
276
277 glLightfv( GL_LIGHT2, GL_DIFFUSE, diffuse );
278 mol->adpwall_plaid=bindTexture(QImage(QString(":/icons/adpwall.png")),GL_TEXTURE_2D);
279 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
280 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
281 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
282
283 mol->adpwall=bindTexture(QImage(QString(":/icons/adpwall3.png")),GL_TEXTURE_2D);
284 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
285 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
286 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
287
288 mol->hbtex=bindTexture(QImage(QString(":/icons/hbb.png")),GL_TEXTURE_2D);
289 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
290 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
291 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
292 glEnable( GL_LIGHTING );
293 glEnable( GL_LIGHT0 );
294 // glEnable( GL_BLEND);
295 glDisable(GL_BLEND);
296 glAlphaFunc ( GL_GREATER, 0.01f ) ;
297 //glEnable(GL_ALPHA_TEST);
298 glBlendFunc ( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ) ;
299 const GLfloat OBJ_SPE[] = { 1.0f, 1.0f, 1.0f, 1.0f };
300 const GLfloat OBJ_SHIN = 127.0f;
301 glMaterialfv( GL_FRONT_AND_BACK, GL_SPECULAR, OBJ_SPE );
302 glEnable ( GL_COLOR_MATERIAL ) ;
303 glColorMaterial ( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE ) ;
304 glMaterialf( GL_FRONT_AND_BACK, GL_SHININESS, OBJ_SHIN );
305 glShadeModel( GL_SMOOTH );
306 glEnable(GL_NORMALIZE);
307 glClearColor(0.4f,0.4f,0.4f,1.0f);
308 glEnable(GL_DEPTH_TEST );
309 glDepthFunc(GL_LEQUAL);
310 gluLookAt_(0.0, 200, 50 , 0.0, 0.0, 0.0, 0.0, -100, 400 );
311 glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
312 saveProgram=mol->g_Program;
313 mol->g_Program=new QGLShaderProgram(context(),this);
314 mol->g_program=mol->installShader();
315 //g_program=mol->installShader();
316 }
resizeGL(int width,int height)317 void EacGLW::resizeGL(int width, int height){
318 #if defined Q_OS_MAC && (QT_VERSION >= 0x050000)
319 glViewport(0, 0, width*2, height*2);
320 #else
321 glViewport(0, 0, width, height);
322 #endif
323 glGetIntegerv(GL_VIEWPORT, vp);
324 glMatrixMode(GL_PROJECTION);
325 glLoadIdentity();
326 gluPerspective_( 29.0, (double)width/height, 5.0, 8000.0 );
327 }
328
paintGL()329 void EacGLW::paintGL(){
330 glClearColor(0.8f,0.8f,0.8f,1.0f);
331 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
332 #if defined Q_OS_MAC && (QT_VERSION >= 0x050000)
333 glViewport(0, 0, QGLWidget::width()*2, QGLWidget::height()*2);
334 #else
335 glViewport(0, 0, QGLWidget::width(), QGLWidget::height());
336 #endif
337 glGetIntegerv(GL_VIEWPORT, vp);
338 glMatrixMode(GL_PROJECTION);
339 glLoadIdentity();
340 gluPerspective_( 29.0, (double)QGLWidget::width()/QGLWidget::height(), 5.0, 8000.0 );
341 glMatrixMode(GL_MODELVIEW);
342 glPushMatrix();
343 draw();
344 glPopMatrix();
345 }
changeAtom(int OZ)346 void EacGLW::changeAtom(int OZ){
347 xd[0].Label=mol->pse(OZ);
348 xd[0].an=OZ;
349 xd[1].Label=QString("%1(noADP)").arg(mol->pse(OZ));
350 xd[1].an=OZ;
351 //xd[1].ownStyle=true;
352 //xd[1].style=ATOM_STYLE_NOADP;
353 //xd[1].rad=mol->arad[OZ];
354 //xd[1].color=mol->AtomColor[OZ];
355 updateGL();
356 }
colorDLG()357 void EacGLW::colorDLG(){
358 QColor bgcolor;
359 bgcolor=QColorDialog::getColor(mol->AtomColor[xd.at(0).an], this);
360 if (bgcolor.isValid()) {
361 mol->AtomColor[xd.at(0).an]=bgcolor;
362 mol->AtomColor[xd.at(0).an].setAlpha(127);
363 xd[1].an=xd.at(0).an;
364 mol->einstellung->beginGroup("Atoms");
365 mol->einstellung->beginWriteArray("AtomColors",107);
366 for (int i = 0; i < 107; ++i) {
367 mol->einstellung->setArrayIndex(i);
368 mol->einstellung->setValue("Color", mol->AtomColor[i]);
369 }
370 mol->einstellung->endArray();
371 mol->einstellung->endGroup();
372 mol->einstellung->sync();
373 emit colorchanged(bgcolor);
374
375 }
376 }
377
colorchange(QColor bgcolor)378 void EacDlg::colorchange(QColor bgcolor){
379 colorbut->setStyleSheet(QString(
380 "QPushButton {"
381 "border: 1px solid #000000;"
382 "border-radius: 9px;"
383 "color: %4;"
384 "background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 %1, stop: 0.5 %3, stop: 1 %2);"
385 "}"
386 "QPushButton:hover {"
387 "background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 %2, stop: 0.5 %1, stop: 1 %2);"
388 "}"
389 "QPushButton:flat {"
390 " border: none; /* no border for a flat push button */"
391 "}"
392 )
393 .arg(bgcolor.name())
394 .arg(bgcolor.darker(200).name())
395 .arg(bgcolor.lighter(200).name())
396 .arg((bgcolor.value()<90)?"#ffffff":"#000000"));
397
398 }
399
colorDLG2()400 void EacDlg::colorDLG2(){
401 QColor bgcolor;
402 bgcolor=QColorDialog::getColor(mol->bondColor, this);
403 if (bgcolor.isValid()) {
404 mol->bondColor=eacGLW->mol->bondColor=bgcolor;
405
406 colorbut2->setStyleSheet(QString(
407 "QPushButton {"
408 "border: 1px solid #000000;"
409 "border-radius: 9px;"
410 "color: %4;"
411 "background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 %1, stop: 0.5 %3, stop: 1 %2);"
412 "}"
413 "QPushButton:hover {"
414 "background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 %2, stop: 0.5 %1, stop: 1 %2);"
415 "}"
416 "QPushButton:flat {"
417 " border: none; /* no border for a flat push button */"
418 "}"
419 )
420 .arg(bgcolor.name())
421 .arg(bgcolor.darker(200).name())
422 .arg(bgcolor.lighter(200).name())
423 .arg((bgcolor.value()<90)?"#ffffff":"#000000"));
424 mol->einstellung->beginGroup("Bonds");
425 mol->einstellung->setValue("BondColor",mol->bondColor);
426 mol->einstellung->setValue("BondStyle",mol->bondColorStyle);
427 mol->einstellung->setValue("BondStrength",mol->bondStrength);
428
429 mol->einstellung->setValue("enviBondColor",mol->enviBondColor);
430 mol->einstellung->setValue("enviHBColor",mol->enviHBColor);
431 mol->einstellung->setValue("enviDefaultColor",mol->enviDefaultColor);
432 mol->einstellung->endGroup();
433 }
434 update();
435 }
436
colorDLGenvidef()437 void EacDlg::colorDLGenvidef(){
438 QColor bgcolor;
439 bgcolor=QColorDialog::getColor(mol->enviDefaultColor, this);
440 if (bgcolor.isValid()) {
441 mol->enviDefaultColor=eacGLW->mol->enviDefaultColor=bgcolor;
442
443 colorbutEdf->setStyleSheet(QString(
444 "QPushButton {"
445 "border: 1px solid #000000;"
446 "border-radius: 9px;"
447 "color: %4;"
448 "background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 %1, stop: 0.5 %3, stop: 1 %2);"
449 "}"
450 "QPushButton:hover {"
451 "background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 %2, stop: 0.5 %1, stop: 1 %2);"
452 "}"
453 "QPushButton:flat {"
454 " border: none; /* no border for a flat push button */"
455 "}"
456 )
457 .arg(bgcolor.name())
458 .arg(bgcolor.darker(200).name())
459 .arg(bgcolor.lighter(200).name())
460 .arg((bgcolor.value()<90)?"#ffffff":"#000000"));
461 mol->einstellung->beginGroup("Bonds");
462 mol->einstellung->setValue("BondColor",mol->bondColor);
463 mol->einstellung->setValue("BondStyle",mol->bondColorStyle);
464 mol->einstellung->setValue("BondStrength",mol->bondStrength);
465
466 mol->einstellung->setValue("enviBondColor",mol->enviBondColor);
467 mol->einstellung->setValue("enviHBColor",mol->enviHBColor);
468 mol->einstellung->setValue("enviDefaultColor",mol->enviDefaultColor);
469
470 mol->einstellung->beginWriteArray("HBondDonors",mol->theseAreDonors.size());
471 for (int i = 0; i < mol->theseAreDonors.size(); ++i) {
472 mol->einstellung->setArrayIndex(i);
473 mol->einstellung->setValue("Element",mol->pse(mol->theseAreDonors.at(i)));
474 }
475 mol->einstellung->endArray();
476
477 mol->einstellung->beginWriteArray("HBondAcceptors",mol->theseAreAcceptors.size());
478 for (int i = 0; i < mol->theseAreAcceptors.size(); ++i) {
479 mol->einstellung->setArrayIndex(i);
480 mol->einstellung->setValue("Element",mol->pse(mol->theseAreAcceptors.at(i)));
481 }
482 mol->einstellung->endArray();
483 mol->einstellung->endGroup();
484 }
485 update();
486 }
colorDLGenvibon()487 void EacDlg::colorDLGenvibon(){
488 QColor bgcolor;
489 bgcolor=QColorDialog::getColor(mol->enviBondColor, this);
490 if (bgcolor.isValid()) {
491 mol->enviBondColor=eacGLW->mol->enviBondColor=bgcolor;
492
493 colorbutEbo->setStyleSheet(QString(
494 "QPushButton {"
495 "border: 1px solid #000000;"
496 "border-radius: 9px;"
497 "color: %4;"
498 "background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 %1, stop: 0.5 %3, stop: 1 %2);"
499 "}"
500 "QPushButton:hover {"
501 "background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 %2, stop: 0.5 %1, stop: 1 %2);"
502 "}"
503 "QPushButton:flat {"
504 " border: none; /* no border for a flat push button */"
505 "}"
506 )
507 .arg(bgcolor.name())
508 .arg(bgcolor.darker(200).name())
509 .arg(bgcolor.lighter(200).name())
510 .arg((bgcolor.value()<90)?"#ffffff":"#000000"));
511 mol->einstellung->beginGroup("Bonds");
512 mol->einstellung->setValue("BondColor",mol->bondColor);
513 mol->einstellung->setValue("BondStyle",mol->bondColorStyle);
514 mol->einstellung->setValue("BondStrength",mol->bondStrength);
515
516 mol->einstellung->setValue("enviBondColor",mol->enviBondColor);
517 mol->einstellung->setValue("enviHBColor",mol->enviHBColor);
518 mol->einstellung->setValue("enviDefaultColor",mol->enviDefaultColor);
519
520 mol->einstellung->beginWriteArray("HBondDonors",mol->theseAreDonors.size());
521 for (int i = 0; i < mol->theseAreDonors.size(); ++i) {
522 mol->einstellung->setArrayIndex(i);
523 mol->einstellung->setValue("Element",mol->pse(mol->theseAreDonors.at(i)));
524 }
525 mol->einstellung->endArray();
526
527 mol->einstellung->beginWriteArray("HBondAcceptors",mol->theseAreAcceptors.size());
528 for (int i = 0; i < mol->theseAreAcceptors.size(); ++i) {
529 mol->einstellung->setArrayIndex(i);
530 mol->einstellung->setValue("Element",mol->pse(mol->theseAreAcceptors.at(i)));
531 }
532 mol->einstellung->endArray();
533 mol->einstellung->endGroup();
534 }
535 update();
536 }
537
colorDLGenvihbo()538 void EacDlg::colorDLGenvihbo(){
539 QColor bgcolor;
540 bgcolor=QColorDialog::getColor(mol->enviHBColor, this);
541 if (bgcolor.isValid()) {
542 mol->enviHBColor=eacGLW->mol->enviHBColor=bgcolor;
543
544 colorbutEhb->setStyleSheet(QString(
545 "QPushButton {"
546 "border: 1px solid #000000;"
547 "border-radius: 9px;"
548 "color: %4;"
549 "background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 %1, stop: 0.5 %3, stop: 1 %2);"
550 "}"
551 "QPushButton:hover {"
552 "background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 %2, stop: 0.5 %1, stop: 1 %2);"
553 "}"
554 "QPushButton:flat {"
555 " border: none; /* no border for a flat push button */"
556 "}"
557 )
558 .arg(bgcolor.name())
559 .arg(bgcolor.darker(200).name())
560 .arg(bgcolor.lighter(200).name())
561 .arg((bgcolor.value()<90)?"#ffffff":"#000000"));
562 mol->einstellung->beginGroup("Bonds");
563 mol->einstellung->setValue("BondColor",mol->bondColor);
564 mol->einstellung->setValue("BondStyle",mol->bondColorStyle);
565 mol->einstellung->setValue("BondStrength",mol->bondStrength);
566
567 mol->einstellung->setValue("enviBondColor",mol->enviBondColor);
568 mol->einstellung->setValue("enviHBColor",mol->enviHBColor);
569 mol->einstellung->setValue("enviDefaultColor",mol->enviDefaultColor);
570
571 mol->einstellung->beginWriteArray("HBondDonors",mol->theseAreDonors.size());
572 for (int i = 0; i < mol->theseAreDonors.size(); ++i) {
573 mol->einstellung->setArrayIndex(i);
574 mol->einstellung->setValue("Element",mol->pse(mol->theseAreDonors.at(i)));
575 }
576 mol->einstellung->endArray();
577
578 mol->einstellung->beginWriteArray("HBondAcceptors",mol->theseAreAcceptors.size());
579 for (int i = 0; i < mol->theseAreAcceptors.size(); ++i) {
580 mol->einstellung->setArrayIndex(i);
581 mol->einstellung->setValue("Element",mol->pse(mol->theseAreAcceptors.at(i)));
582 }
583 mol->einstellung->endArray();
584 mol->einstellung->endGroup();
585 }
586 update();
587 }
wallA(int st)588 void EacGLW::wallA(int st){
589 if (st) mol->AtomStyle[xd.at(0).an]|=ATOM_STYLE_WALLS;
590 else if (mol->AtomStyle[xd.at(0).an]&ATOM_STYLE_WALLS) mol->AtomStyle[xd.at(0).an]-=ATOM_STYLE_WALLS;
591 if (st==Qt::PartiallyChecked) mol->AtomStyle[xd.at(0).an]|=ATOM_STYLE_PLAID;
592 else if (mol->AtomStyle[xd.at(0).an]&ATOM_STYLE_PLAID) mol->AtomStyle[xd.at(0).an]-=ATOM_STYLE_PLAID;
593
594 }
ringA(int st)595 void EacGLW::ringA(int st){
596 if (st==Qt::PartiallyChecked) mol->AtomStyle[xd.at(0).an]|=ATOM_STYLE_WHITERING;
597 else if (mol->AtomStyle[xd.at(0).an]&ATOM_STYLE_WHITERING) mol->AtomStyle[xd.at(0).an]-=ATOM_STYLE_WHITERING;
598 if (st) mol->AtomStyle[xd.at(0).an]|=ATOM_STYLE_RINGS;
599 else if (mol->AtomStyle[xd.at(0).an]&ATOM_STYLE_RINGS) mol->AtomStyle[xd.at(0).an]-=ATOM_STYLE_RINGS;
600
601 }
spheA(int st)602 void EacGLW::spheA(int st){
603 if (st) mol->AtomStyle[xd.at(0).an]|=ATOM_STYLE_SPHERE;
604 else if (mol->AtomStyle[xd.at(0).an]&ATOM_STYLE_SPHERE) mol->AtomStyle[xd.at(0).an]-=ATOM_STYLE_SPHERE;
605
606 }
soldA(int st)607 void EacGLW::soldA(int st){
608 if (st) {
609 mol->AtomStyle[xd.at(0).an]|=ATOM_STYLE_SOLID;
610 }
611 else if (mol->AtomStyle[xd.at(0).an]&ATOM_STYLE_SOLID) mol->AtomStyle[xd.at(0).an]-=ATOM_STYLE_SOLID;
612
613 }
woADP(bool b)614 void EacDlg::woADP(bool b){
615 walbx->setDisabled(b);
616 rinbx->setDisabled(b);
617 sphbx->setDisabled(b);
618 sldbx->setDisabled(b);
619 if (b) {
620 eacGLW->mol->AtomStyle[eacGLW->xd.at(0).an]|=ATOM_STYLE_NOADP;
621 sldbx->setChecked(b);
622 }
623 else
624 if (eacGLW->mol->AtomStyle[eacGLW->xd.at(0).an]&ATOM_STYLE_NOADP)
625 eacGLW->mol->AtomStyle[eacGLW->xd.at(0).an]-=ATOM_STYLE_NOADP;
626 }
627
whitA(int st)628 void EacGLW::whitA(int st){
629 if (st) {
630 mol->AtomStyle[xd.at(0).an]|=ATOM_STYLE_WHITERING;
631 }
632 else if (mol->AtomStyle[xd.at(0).an]&ATOM_STYLE_WHITERING) mol->AtomStyle[xd.at(0).an]-=ATOM_STYLE_WHITERING;
633 }
634
nolaA(int st)635 void EacGLW::nolaA(int st){
636 if (st) {
637 mol->AtomStyle[xd.at(0).an]|=ATOM_STYLE_NOLABEL;
638 }
639 else if (mol->AtomStyle[xd.at(0).an]&ATOM_STYLE_NOLABEL) mol->AtomStyle[xd.at(0).an]-=ATOM_STYLE_NOLABEL;
640 }
641
metalA(int st)642 void EacGLW::metalA(int st){
643 if (st) {
644 mol->AtomStyle[xd.at(0).an]|=ATOM_STYLE_METAL;
645 }
646 else if (mol->AtomStyle[xd.at(0).an]&ATOM_STYLE_METAL) mol->AtomStyle[xd.at(0).an]-=ATOM_STYLE_METAL;
647 }
checkWall()648 void EacDlg::checkWall(){
649 if (sldbx->checkState()&&(walbx->checkState()))walbx->setCheckState(Qt::Unchecked);
650 }
checkSolid()651 void EacDlg::checkSolid(){
652 if (sldbx->checkState()&&(walbx->checkState()))sldbx->setCheckState(Qt::Unchecked);
653 }
checkShader(bool b)654 void EacDlg::checkShader(bool b){
655 bool bb=false;
656 if (b&&(eacGLW->mol->g_Program!=nullptr)) bb=eacGLW->mol->g_Program->bind();
657 eacGLW->mol->useShaders = bb;
658
659 mol->einstellung->beginGroup("Window");
660 mol->einstellung->setValue("Use_GLSL_Shaders",bb);
661 mol->einstellung->endGroup();
662 }
checkBall()663 void EacDlg::checkBall(){
664 if (sphbx->checkState())sldbx->setEnabled(true);
665 else sldbx->setEnabled(false);
666 }
updateLEs(int OZ)667 void EacDlg::updateLEs(int OZ){
668 eacKRAD->setValue(eacGLW->mol->Kovalenz_Radien[OZ]/100.0);
669 eacRAD->setValue(eacGLW->mol->arad[OZ]);
670 rinbx->setCheckState((eacGLW->mol->AtomStyle[OZ]&ATOM_STYLE_RINGS)?((eacGLW->mol->AtomStyle[OZ]&ATOM_STYLE_WHITERING)?Qt::PartiallyChecked :Qt::Checked):Qt::Unchecked);
671
672 sphbx->setCheckState((eacGLW->mol->AtomStyle[OZ]&ATOM_STYLE_SPHERE)?Qt::Checked:Qt::Unchecked);
673 sldbx->setCheckState((eacGLW->mol->AtomStyle[OZ]&ATOM_STYLE_SOLID)?Qt::Checked:Qt::Unchecked);
674 walbx->setCheckState((eacGLW->mol->AtomStyle[OZ]&ATOM_STYLE_WALLS)?((eacGLW->mol->AtomStyle[OZ]&ATOM_STYLE_PLAID)?Qt::PartiallyChecked: Qt::Checked):Qt::Unchecked);
675 nlabx->setCheckState((eacGLW->mol->AtomStyle[OZ]&ATOM_STYLE_NOLABEL)?Qt::Checked:Qt::Unchecked);
676 metalic->setCheckState((eacGLW->mol->AtomStyle[OZ]&ATOM_STYLE_METAL)?Qt::Checked:Qt::Unchecked);
677 noadp->setChecked((eacGLW->mol->AtomStyle[OZ]&ATOM_STYLE_NOADP)?true:false);
678 woADP(noadp->isChecked());
679 colorbut->setStyleSheet(QString(
680 "QPushButton {"
681 "border: 1px solid #000000;"
682 "border-radius: 9px;"
683 "color: %4;"
684 "background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 %1, stop: 0.5 %3, stop: 1 %2);"
685 "}"
686 "QPushButton:hover {"
687 "background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 %2, stop: 0.5 %1, stop: 1 %2);"
688 "}"
689 "QPushButton:flat {"
690 " border: none; /* no border for a flat push button */"
691 "}"
692 )
693 .arg(mol->AtomColor[OZ].name())
694 .arg(mol->AtomColor[OZ].darker(200).name())
695 .arg(mol->AtomColor[OZ].lighter(200).name())
696 .arg((mol->AtomColor[OZ].value()<90)?"#ffffff":"#000000"));
697
698 update();
699 }
700
probaChanged(int ix)701 void EacDlg::probaChanged(int ix){
702 eacGLW->proba=mol->proba=eacProba->itemData(ix).toInt() ;
703 update();
704 }
705
unicolor(bool b)706 void EacDlg::unicolor(bool b){
707 eacGLW->mol->bondColor = mol->bondColor;
708 eacGLW->mol->bondColorStyle=mol->bondColorStyle=(b)?1:0;
709 mol->einstellung->beginGroup("Bonds");
710 mol->einstellung->setValue("BondColor",mol->bondColor);
711 mol->einstellung->setValue("BondStyle",mol->bondColorStyle);
712 mol->einstellung->setValue("BondStrength",mol->bondStrength);
713 mol->einstellung->setValue("enviBondColor",mol->enviBondColor);
714 mol->einstellung->setValue("enviHBColor",mol->enviHBColor);
715 mol->einstellung->setValue("enviDefaultColor",mol->enviDefaultColor);
716
717 mol->einstellung->beginWriteArray("HBondDonors",mol->theseAreDonors.size());
718 for (int i = 0; i < mol->theseAreDonors.size(); ++i) {
719 mol->einstellung->setArrayIndex(i);
720 mol->einstellung->setValue("Element",mol->pse(mol->theseAreDonors.at(i)));
721 }
722 mol->einstellung->endArray();
723
724 mol->einstellung->beginWriteArray("HBondAcceptors",mol->theseAreAcceptors.size());
725 for (int i = 0; i < mol->theseAreAcceptors.size(); ++i) {
726 mol->einstellung->setArrayIndex(i);
727 mol->einstellung->setValue("Element",mol->pse(mol->theseAreAcceptors.at(i)));
728 }
729 mol->einstellung->endArray();
730
731 mol->einstellung->endGroup();
732 update();
733 }
734
735
strengthChanged(double d)736 void EacDlg::strengthChanged(double d){
737 eacGLW->mol->bondStrength=mol->bondStrength=d;
738 mol->einstellung->beginGroup("Bonds");
739 mol->einstellung->setValue("BondColor",mol->bondColor);
740 mol->einstellung->setValue("BondStyle",mol->bondColorStyle);
741 mol->einstellung->setValue("BondStrength",mol->bondStrength);
742 mol->einstellung->setValue("enviBondColor",mol->enviBondColor);
743 mol->einstellung->setValue("enviHBColor",mol->enviHBColor);
744 mol->einstellung->setValue("enviDefaultColor",mol->enviDefaultColor);
745
746 mol->einstellung->beginWriteArray("HBondDonors",mol->theseAreDonors.size());
747 for (int i = 0; i < mol->theseAreDonors.size(); ++i) {
748 mol->einstellung->setArrayIndex(i);
749 mol->einstellung->setValue("Element",mol->pse(mol->theseAreDonors.at(i)));
750 }
751 mol->einstellung->endArray();
752
753 mol->einstellung->beginWriteArray("HBondAcceptors",mol->theseAreAcceptors.size());
754 for (int i = 0; i < mol->theseAreAcceptors.size(); ++i) {
755 mol->einstellung->setArrayIndex(i);
756 mol->einstellung->setValue("Element",mol->pse(mol->theseAreAcceptors.at(i)));
757 }
758 mol->einstellung->endArray();
759 mol->einstellung->endGroup();
760 update();
761 }
762
QPeakRadChanged(double d)763 void EacDlg::QPeakRadChanged(double d){
764 eacGLW->mol->qPeakRad=mol->qPeakRad=d;
765 mol->einstellung->beginGroup("QPeaks");
766 mol->einstellung->setValue("QPeaksRadius",mol->qPeakRad);
767 mol->einstellung->endGroup();
768 //settings...
769 update();
770 }
771
lodChanged(int d)772 void EacDlg::lodChanged(int d){
773 eacGLW->mol->LOD=d;
774 mol->einstellung->beginGroup("Window");
775 mol->einstellung->setValue("LevelOfDetail",mol->LOD);
776 mol->einstellung->endGroup();
777
778 update();
779 }
780
importSettings()781 void EacDlg::importSettings(){
782 mol->einstellung->beginGroup("Files");
783 QString dn=mol->einstellung->value("lastFile").toString();
784 mol->einstellung->endGroup();
785 if (!dn.isEmpty()) {
786 dn.replace(QRegExp(".ins$"),".ini");
787 dn.replace(QRegExp(".res$"),".ini");
788 }
789 QString fn = QFileDialog::getOpenFileName (this,"Exporting atom style settings...",dn,"Settings (*.ini)");
790 if (fn.isNull())return;
791 QSettings *eaSettings = new QSettings(fn,QSettings::IniFormat);
792
793 //-------------------------
794 //
795 eaSettings->beginGroup("Atoms");
796 int ri=eaSettings->beginReadArray("CovaleceRadii");
797 for (int i = 0; i < ri; ++i) {
798 eaSettings->setArrayIndex(i);
799 mol->Kovalenz_Radien[i]=eaSettings->value("Radius").toInt();
800 }
801 eaSettings->endArray();
802
803 ri = eaSettings->beginReadArray("BallRadii");
804 for (int i = 0; i < ri; ++i) {
805 eaSettings->setArrayIndex(i);
806 mol->arad[i]=eaSettings->value("Radius").toDouble();
807 }
808 eaSettings->endArray();
809 ri = eaSettings->beginReadArray("AtomStyles");
810 for (int i = 0; i < ri; ++i) {
811 eaSettings->setArrayIndex(i);
812 eacGLW->mol->AtomStyle[i]=eaSettings->value("Style" ).toInt();
813 }
814 eaSettings->endArray();
815 ri = eaSettings->beginReadArray("AtomColors");
816 for (int i = 0; i < ri; ++i) {
817 eaSettings->setArrayIndex(i);
818 mol->AtomColor[i]=eaSettings->value("Color").value<QColor>();
819 mol->AtomColor[i].setAlphaF(0.5);;
820 }
821 eaSettings->endArray();
822 eaSettings->endGroup();
823
824 eaSettings->beginGroup("Bonds");
825 mol->bondColor = eaSettings->value("BondColor").value<QColor>();
826 mol->bondColorStyle = eaSettings->value("BondStyle").toInt();;
827 mol->bondStrength = eaSettings->value("BondStrength").toDouble();
828
829 mol->enviBondColor=eaSettings->value("enviBondColor",QColor(Qt::darkGreen)).value<QColor>();
830 mol->enviHBColor=eaSettings->value("enviHBColor",QColor(Qt::darkYellow)).value<QColor>();
831 mol->enviDefaultColor=eaSettings->value("enviDefaultColor",QColor(Qt::black)).value<QColor>();
832
833 eaSettings->endGroup();
834 delete eaSettings;
835
836 //
837 mol->einstellung->beginGroup("Atoms");
838 mol->einstellung->beginWriteArray("CovaleceRadii",95);
839 for (int i = 0; i < 95; ++i) {
840 mol->einstellung->setArrayIndex(i);
841 mol->einstellung->setValue("Radius", mol->Kovalenz_Radien[i]);
842 }
843 mol->einstellung->endArray();
844
845 mol->einstellung->beginWriteArray("BallRadii");
846 for (int i = 0; i < 109; ++i) {
847 mol->einstellung->setArrayIndex(i);
848 mol->einstellung->setValue("Radius",mol->arad[i]);
849 }
850 mol->einstellung->endArray();
851 mol->einstellung->beginWriteArray("AtomStyles",107);
852 for (int i = 0; i < 107; ++i) {
853 mol->einstellung->setArrayIndex(i);
854 mol->einstellung->setValue("Style", eacGLW->mol->AtomStyle[i]);
855 }
856 mol->einstellung->endArray();
857 int asel=psew->selection;
858 mol->einstellung->beginWriteArray("AtomColors",107);
859 for (int i = 0; i < 107; ++i) {
860 mol->einstellung->setArrayIndex(i);
861 mol->einstellung->setValue("Color", mol->AtomColor[i]);
862 psew->selection=i;
863 psew->colorchange(mol->AtomColor[i]);
864 }
865 psew->selection=asel;
866 mol->einstellung->endArray();
867 mol->einstellung->endGroup();
868
869 mol->einstellung->beginGroup("Bonds");
870 mol->einstellung->setValue("BondColor",mol->bondColor);
871 mol->einstellung->setValue("BondStyle",mol->bondColorStyle);
872 mol->einstellung->setValue("BondStrength",mol->bondStrength);
873 mol->einstellung->setValue("enviBondColor",mol->enviBondColor);
874 mol->einstellung->setValue("enviHBColor",mol->enviHBColor);
875 mol->einstellung->setValue("enviDefaultColor",mol->enviDefaultColor);
876 mol->einstellung->beginWriteArray("HBondDonors",mol->theseAreDonors.size());
877 for (int i = 0; i < mol->theseAreDonors.size(); ++i) {
878 mol->einstellung->setArrayIndex(i);
879 mol->einstellung->setValue("Element",mol->pse(mol->theseAreDonors.at(i)));
880 }
881 mol->einstellung->endArray();
882
883 mol->einstellung->beginWriteArray("HBondAcceptors",mol->theseAreAcceptors.size());
884 for (int i = 0; i < mol->theseAreAcceptors.size(); ++i) {
885 mol->einstellung->setArrayIndex(i);
886 mol->einstellung->setValue("Element",mol->pse(mol->theseAreAcceptors.at(i)));
887 }
888 mol->einstellung->endArray();
889
890 mol->einstellung->endGroup();
891 //--------------------------------------
892 }
893
exportSettings()894 void EacDlg::exportSettings(){
895 mol->einstellung->beginGroup("Files");
896 QString dn=mol->einstellung->value("lastFile").toString();
897 mol->einstellung->endGroup();
898 if (!dn.isEmpty()) {
899 dn.replace(QRegExp(".ins$"),".ini");
900 dn.replace(QRegExp(".res$"),".ini");
901 }
902 QString fn = QFileDialog::getSaveFileName (this,"Exporting atom style settings...",dn,"Settings (*.ini)");
903 QSettings *eaSettings = new QSettings(fn,QSettings::IniFormat);
904 //-------------------------
905 //
906 eaSettings->beginGroup("Atoms");
907 eaSettings->beginWriteArray("CovaleceRadii",95);
908 for (int i = 0; i < 95; ++i) {
909 eaSettings->setArrayIndex(i);
910 eaSettings->setValue("Radius", mol->Kovalenz_Radien[i]);
911 }
912 eaSettings->endArray();
913
914 eaSettings->beginWriteArray("BallRadii");
915 for (int i = 0; i < 109; ++i) {
916 eaSettings->setArrayIndex(i);
917 eaSettings->setValue("Radius",mol->arad[i]);
918 }
919 eaSettings->endArray();
920 eaSettings->beginWriteArray("AtomStyles",107);
921 for (int i = 0; i < 107; ++i) {
922 eaSettings->setArrayIndex(i);
923 eaSettings->setValue("Style", eacGLW->mol->AtomStyle[i]);
924 }
925 eaSettings->endArray();
926 eaSettings->beginWriteArray("AtomColors",107);
927 for (int i = 0; i < 107; ++i) {
928 eaSettings->setArrayIndex(i);
929 eaSettings->setValue("Color", mol->AtomColor[i]);
930 }
931 eaSettings->endArray();
932 eaSettings->endGroup();
933
934 eaSettings->beginGroup("Bonds");
935 eaSettings->setValue("BondColor",mol->bondColor);
936 eaSettings->setValue("BondStyle",mol->bondColorStyle);
937 eaSettings->setValue("BondStrength",mol->bondStrength);
938 eaSettings->setValue("enviBondColor",mol->enviBondColor);
939 eaSettings->setValue("enviHBColor",mol->enviHBColor);
940 eaSettings->setValue("enviDefaultColor",mol->enviDefaultColor);
941
942 eaSettings->setValue("HBondMaxDist",mol->hbdist());
943 eaSettings->value("HBondMaxAng",mol->hbangl());
944 eaSettings->endGroup();
945 delete eaSettings;
946 //--------------------------------------
947 //
948 }
949
kradChanged(double d)950 void EacDlg::kradChanged(double d){
951 eacGLW->mol->Kovalenz_Radien[psew->selection]=mol->Kovalenz_Radien[psew->selection]=(int)(d*100);
952 mol->einstellung->beginGroup("Atoms");
953 mol->einstellung->beginWriteArray("CovaleceRadii",95);
954 for (int i = 0; i < 95; ++i) {
955 mol->einstellung->setArrayIndex(i);
956 mol->einstellung->setValue("Radius", mol->Kovalenz_Radien[i]);
957 }
958 mol->einstellung->endArray();
959 mol->einstellung->endGroup();
960 mol->einstellung->sync();
961 update();
962 }
963
964
hbdistChanged(double)965 void EacDlg::hbdistChanged(double){
966 mol->einstellung->beginGroup("Bonds");
967 mol->setHBondMaxDist(eacHBDist->value());
968 mol->einstellung->setValue("HBondMaxDist",eacHBDist->value());
969 mol->setHBondMaxAngl(eacHBAngl->value());
970 mol->einstellung->setValue("HBondMaxAng",eacHBAngl->value());
971 mol->einstellung->endGroup();
972 mol->einstellung->sync();
973 update();
974 }
975
updateHBElemnts()976 void EacDlg::updateHBElemnts(){
977 QStringList accst=accLE->text().simplified().split(",",skipEmptyParts);
978 mol->theseAreAcceptors.clear();
979 for (int i=0; i<accst.size();i++){
980 int an=mol->getOZ(accst.at(i));
981 if (an>=0) mol->theseAreAcceptors.append(an);
982 }
983 QStringList donst=donLE->text().simplified().split(",",skipEmptyParts);
984 mol->theseAreDonors.clear();
985 for (int i=0; i<donst.size();i++){
986 int an=mol->getOZ(donst.at(i));
987 if (an>=0) mol->theseAreDonors.append(an);
988 }
989 donst.clear();
990 for (int i=0; i<mol->theseAreDonors.size(); i++) donst.append(mol->pse(mol->theseAreDonors.at(i)));
991 donLE->setText(donst.join(","));
992 accst.clear();
993 for (int i=0; i<mol->theseAreAcceptors.size(); i++) accst.append(mol->pse(mol->theseAreAcceptors.at(i)));
994 accLE->setText(accst.join(","));
995
996 mol->einstellung->beginGroup("Bonds");
997 mol->einstellung->setValue("BondColor",mol->bondColor);
998 mol->einstellung->setValue("BondStyle",mol->bondColorStyle);
999 mol->einstellung->setValue("BondStrength",mol->bondStrength);
1000 mol->einstellung->setValue("enviBondColor",mol->enviBondColor);
1001 mol->einstellung->setValue("enviHBColor",mol->enviHBColor);
1002 mol->einstellung->setValue("enviDefaultColor",mol->enviDefaultColor);
1003
1004 mol->einstellung->beginWriteArray("HBondDonors",mol->theseAreDonors.size());
1005 for (int i = 0; i < mol->theseAreDonors.size(); ++i) {
1006 mol->einstellung->setArrayIndex(i);
1007 mol->einstellung->setValue("Element",mol->pse(mol->theseAreDonors.at(i)));
1008 }
1009 mol->einstellung->endArray();
1010
1011 mol->einstellung->beginWriteArray("HBondAcceptors",mol->theseAreAcceptors.size());
1012 for (int i = 0; i < mol->theseAreAcceptors.size(); ++i) {
1013 mol->einstellung->setArrayIndex(i);
1014 mol->einstellung->setValue("Element",mol->pse(mol->theseAreAcceptors.at(i)));
1015 }
1016 mol->einstellung->endArray();
1017 mol->einstellung->endGroup();
1018 }
1019
hbanglChanged(double)1020 void EacDlg::hbanglChanged(double){
1021 mol->einstellung->beginGroup("Bonds");
1022 mol->setHBondMaxDist(eacHBDist->value());
1023 mol->einstellung->setValue("HBondMaxDist",eacHBDist->value());
1024 mol->setHBondMaxAngl(eacHBAngl->value());
1025 mol->einstellung->setValue("HBondMaxAng",eacHBAngl->value());
1026 mol->einstellung->endGroup();
1027 mol->einstellung->sync();
1028 update();
1029 }
radChanged(double d)1030 void EacDlg::radChanged(double d){
1031
1032 eacGLW->mol->arad[psew->selection] = mol->arad[psew->selection] = d;
1033 //eacGLW->xd[1].rad=d;
1034 mol->einstellung->beginGroup("Atoms");
1035
1036 mol->einstellung->beginWriteArray("BallRadii");
1037 for (int i = 0; i < 109; ++i) {
1038 mol->einstellung->setArrayIndex(i);
1039 mol->einstellung->setValue("Radius",mol->arad[i]);
1040 }
1041 mol->einstellung->endArray();
1042 mol->einstellung->endGroup();
1043 mol->einstellung->sync();
1044
1045 update();
1046 }
1047
EacDlg(Molecule * externMole)1048 EacDlg::EacDlg(Molecule *externMole){
1049 //otm=nullptr;
1050 mol=externMole;
1051 mol->loadSettings();
1052 setWindowTitle("Edit Atom Parameters");
1053 //mol->loadSettings();
1054 eacGLW = new EacGLW(mol,this);
1055 connect(eacGLW,SIGNAL(colorchanged(QColor)),this,SLOT(colorchange(QColor)));
1056
1057 eacGLW->proba=mol->proba;
1058 //eacGLW->m=em;
1059 eacGLO = new QGridLayout;
1060 //eacCB = new QComboBox;
1061 eacRAD = new QDoubleSpinBox();
1062 eacKRAD = new QDoubleSpinBox();
1063 eacHBDist = new QDoubleSpinBox();
1064 eacHBAngl = new QDoubleSpinBox();
1065 //QLabel *smbl =new QLabel("Element symbol");
1066 QLabel *rad =new QLabel("Sphere radius");
1067 QLabel *krad =new QLabel("Covalent radius");
1068 QGroupBox *globalStuff = new QGroupBox("global style");
1069 QVBoxLayout *glt= new QVBoxLayout();
1070 eacProba = new QComboBox(this);
1071 eacProba->addItem("90 % Probability",90);
1072 eacProba->addItem("70 % Probability",70);
1073 eacProba->addItem("50 % Probability",50);
1074 eacProba->addItem("30 % Probability",30);
1075 eacProba->addItem("10 % Probability",10);
1076 eacProba->setCurrentIndex(2);
1077 switch (mol->proba){
1078 case 10: eacProba->setCurrentIndex(4);break;
1079 case 30: eacProba->setCurrentIndex(3);break;
1080 case 50: eacProba->setCurrentIndex(2);break;
1081 case 70: eacProba->setCurrentIndex(1);break;
1082 case 90: eacProba->setCurrentIndex(0);break;
1083 }
1084 // printf("zwei %d \n",mol->proba);
1085 connect(eacProba,SIGNAL(currentIndexChanged(int)),this,SLOT(probaChanged(int)));
1086 QCheckBox *singleC =new QCheckBox("uni colored bonds");
1087 singleC->setChecked(mol->bondColorStyle);
1088 unicolor(mol->bondColorStyle);
1089 connect(singleC,SIGNAL(toggled(bool)),this,SLOT(unicolor(bool)));
1090 impbut = new QPushButton("Import atom styles");
1091 expbut = new QPushButton("Export atom styles");
1092 connect(impbut,SIGNAL(pressed()),this,SLOT(importSettings()));
1093 connect(expbut,SIGNAL(pressed()),this,SLOT(exportSettings()));
1094 colorbut2 =new QPushButton("Bond Color");
1095 colorbut2->setStyleSheet(QString(
1096 "QPushButton {"
1097 "border: 1px solid #000000;"
1098 "border-radius: 9px;"
1099 "color: %4;"
1100 "background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 %1, stop: 0.5 %3, stop: 1 %2);"
1101 "}"
1102 "QPushButton:hover {"
1103 "background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 %1, stop: 0.5 %2, stop: 1 %1);"
1104 "border: 0px"
1105 "}"
1106 "QPushButton:flat {"
1107 " border: none; /* no border for a flat push button */"
1108 "}"
1109 )
1110 .arg(mol->bondColor.name())
1111 .arg(mol->bondColor.darker(200).name())
1112 .arg(mol->bondColor.lighter(200).name())
1113 .arg((mol->bondColor.value()<90)?"#ffffff":"#000000"));
1114 connect(colorbut2,SIGNAL(pressed()),this,SLOT(colorDLG2()));
1115
1116
1117 colorbutEdf =new QPushButton("ENVI default color");
1118 colorbutEdf->setStyleSheet(QString(
1119 "QPushButton {"
1120 "border: 1px solid #000000;"
1121 "border-radius: 9px;"
1122 "color: %4;"
1123 "background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 %1, stop: 0.5 %3, stop: 1 %2);"
1124 "}"
1125 "QPushButton:hover {"
1126 "background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 %1, stop: 0.5 %2, stop: 1 %1);"
1127 "border: 0px"
1128 "}"
1129 "QPushButton:flat {"
1130 " border: none; /* no border for a flat push button */"
1131 "}"
1132 )
1133 .arg(mol->enviDefaultColor.name())
1134 .arg(mol->enviDefaultColor.darker(200).name())
1135 .arg(mol->enviDefaultColor.lighter(200).name())
1136 .arg((mol->enviDefaultColor.value()<90)?"#ffffff":"#000000"));
1137 connect(colorbutEdf,SIGNAL(pressed()),this,SLOT(colorDLGenvidef()));
1138
1139 colorbutEbo =new QPushButton("ENVI covalent color");
1140 colorbutEbo->setStyleSheet(QString(
1141 "QPushButton {"
1142 "border: 1px solid #000000;"
1143 "border-radius: 9px;"
1144 "color: %4;"
1145 "background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 %1, stop: 0.5 %3, stop: 1 %2);"
1146 "}"
1147 "QPushButton:hover {"
1148 "background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 %1, stop: 0.5 %2, stop: 1 %1);"
1149 "border: 0px"
1150 "}"
1151 "QPushButton:flat {"
1152 " border: none; /* no border for a flat push button */"
1153 "}"
1154 )
1155 .arg(mol->enviBondColor.name())
1156 .arg(mol->enviBondColor.darker(200).name())
1157 .arg(mol->enviBondColor.lighter(200).name())
1158 .arg((mol->enviBondColor.value()<90)?"#ffffff":"#000000"));
1159 connect(colorbutEbo,SIGNAL(pressed()),this,SLOT(colorDLGenvibon()));
1160
1161 colorbutEhb =new QPushButton("ENVI H-Bond color");
1162 colorbutEhb->setStyleSheet(QString(
1163 "QPushButton {"
1164 "border: 1px solid #000000;"
1165 "border-radius: 9px;"
1166 "color: %4;"
1167 "background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 %1, stop: 0.5 %3, stop: 1 %2);"
1168 "}"
1169 "QPushButton:hover {"
1170 "background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 %1, stop: 0.5 %2, stop: 1 %1);"
1171 "border: 0px"
1172 "}"
1173 "QPushButton:flat {"
1174 " border: none; /* no border for a flat push button */"
1175 "}"
1176 )
1177 .arg(mol->enviHBColor.name())
1178 .arg(mol->enviHBColor.darker(200).name())
1179 .arg(mol->enviHBColor.lighter(200).name())
1180 .arg((mol->enviHBColor.value()<90)?"#ffffff":"#000000"));
1181 connect(colorbutEhb,SIGNAL(pressed()),this,SLOT(colorDLGenvihbo()));
1182 bondStrength = new QDoubleSpinBox();
1183 bondStrength->setValue(mol->bondStrength);
1184 bondStrength->setDecimals(2);
1185 bondStrength->setSingleStep(0.01);
1186 bondStrength->setToolTip("Bond Strength");
1187 connect(bondStrength,SIGNAL(valueChanged(double)),this,SLOT(strengthChanged(double)) );
1188 glt->addWidget(eacProba);
1189 glt->addWidget(singleC);
1190 glt->addWidget(colorbut2);
1191 glt->addWidget(colorbutEdf);
1192 glt->addWidget(colorbutEbo);
1193 glt->addWidget(colorbutEhb);
1194 QHBoxLayout *glt2= new QHBoxLayout();
1195 QHBoxLayout *glt5= new QHBoxLayout();
1196 QHBoxLayout *glt6= new QHBoxLayout();
1197 QHBoxLayout *glt7= new QHBoxLayout();
1198 QHBoxLayout *glt8= new QHBoxLayout();
1199 QStringList accsl;
1200 for (int i=0; i<mol->theseAreAcceptors.size(); i++) accsl.append(mol->pse(mol->theseAreAcceptors.at(i)));
1201 accLE = new QLineEdit(accsl.join(","));
1202 QLabel *accla = new QLabel("H-Bond Acceptor Elements");
1203 glt7->addWidget(accLE);
1204 glt7->addWidget(accla);
1205
1206 QStringList donsl;
1207 for (int i=0; i<mol->theseAreDonors.size(); i++) donsl.append(mol->pse(mol->theseAreDonors.at(i)));
1208 donLE = new QLineEdit(donsl.join(","));
1209 QLabel *donla = new QLabel("H-Bond Donor Elements ");
1210 glt8->addWidget(donLE);
1211 glt8->addWidget(donla);
1212 connect(accLE,SIGNAL(editingFinished()),this,SLOT(updateHBElemnts()));
1213 glt2->addWidget(bondStrength);
1214 QLabel *bsl = new QLabel("Bond strength");
1215 QLabel *lodl = new QLabel("Level of detail");
1216 QLabel *qradl = new QLabel("QPeak-size");
1217 glt2->addWidget(bsl);
1218 lodSpinBox = new QSpinBox();
1219 lodSpinBox->setValue(mol->LOD);
1220 lodSpinBox->setMinimum(2);
1221 lodSpinBox->setMaximum(15);
1222 connect(lodSpinBox,SIGNAL(valueChanged(int)),this,SLOT(lodChanged(int)));
1223 QHBoxLayout *glt3= new QHBoxLayout();
1224 glt3->addWidget(lodSpinBox);
1225 glt3->addWidget(lodl);
1226 glt6->addWidget(eacHBDist);
1227 QLabel *hbdl = new QLabel("Max H-Acceptor Distance");
1228 glt6->addWidget(hbdl);
1229 QLabel *hbal = new QLabel("Min H-Bond Angle");
1230 glt5->addWidget(eacHBAngl);
1231 glt5->addWidget(hbal);
1232 QDoubleSpinBox* qPeakSizeSBx = new QDoubleSpinBox();
1233 qPeakSizeSBx->setValue(mol->qPeakRad);
1234 qPeakSizeSBx->setDecimals(3);
1235 qPeakSizeSBx->setMinimum(0.005);
1236 qPeakSizeSBx->setMaximum(0.5);
1237 qPeakSizeSBx->setSingleStep(0.003);
1238 qPeakSizeSBx->setToolTip("QPeak-size");
1239 connect(qPeakSizeSBx,SIGNAL(valueChanged(double)),this,SLOT(QPeakRadChanged(double)) );
1240 QHBoxLayout *glt4= new QHBoxLayout();
1241 glt4->addWidget(qPeakSizeSBx);
1242 glt4->addWidget(qradl);
1243
1244 glt->addLayout(glt2);
1245 glt->addLayout(glt3);
1246 glt->addLayout(glt4);
1247 glt->addLayout(glt5);
1248 glt->addLayout(glt6);
1249 glt->addLayout(glt7);
1250 glt->addLayout(glt8);
1251
1252 shaderUse = new QCheckBox("Use GLSL shader for atoms");
1253 if (mol->g_program&&mol->shaders_work){
1254 shaderUse->setChecked(mol->useShaders);
1255 connect(shaderUse ,SIGNAL(toggled(bool)),this,SLOT(checkShader(bool)));
1256 }else{
1257 mol->useShaders=false;
1258 shaderUse->setChecked(mol->useShaders);
1259 //shaderUse->setDisabled(true);
1260 connect(shaderUse ,SIGNAL(toggled(bool)),this,SLOT(checkShader(bool)));
1261 }
1262 glt->addWidget(shaderUse);
1263 globalStuff->setLayout(glt);
1264 walbx = new QCheckBox("Draw intersecting planes");
1265 //walbx->setTristate();
1266 rinbx = new QCheckBox("Draw principal ellipses (check again for black or white)");
1267 rinbx->setTristate();
1268 sphbx = new QCheckBox("Draw ellipsoid surface");
1269 sldbx = new QCheckBox("Solid closed ellipsoid");
1270 noadp = new QCheckBox("No ADP");
1271 metalic = new QCheckBox("Dashed Bonds to others");
1272 nlabx = new QCheckBox("No label!");
1273 metalic->setCheckState ( Qt::Unchecked);
1274 walbx->setCheckState ( Qt::Checked);
1275 rinbx->setCheckState ( Qt::Checked);
1276 rinbx->setWhatsThis("If this check box is half selected <font color=gray><b>white</b></font> <b>outer lines</b> will be drawn around the ellipsoid which looks nice when the atom has a dark color.<br> If this is fully selected <b>black outer lines</b> will be drawn around the ellipsoid.");
1277 sphbx->setCheckState ( Qt::Checked);
1278 sldbx->setCheckState ( Qt::Unchecked);
1279 nlabx->setCheckState ( Qt::Unchecked);
1280 noadp->setCheckState ( Qt::Unchecked);
1281
1282
1283 psew = new PSEWidget();
1284 connect(eacGLW,SIGNAL(colorchanged(QColor)),psew,SLOT(colorchange(QColor)));
1285
1286 /* QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
1287 connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
1288 connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));*/
1289 connect(noadp,SIGNAL(toggled(bool)),this,SLOT(woADP(bool)));
1290 QPushButton *multi = new QPushButton("Style multiple Elements");
1291 colorbut =new QPushButton("Atom Color");
1292 colorbut->setStyleSheet(QString(
1293 "QPushButton {"
1294 "border: 1px solid #000000;"
1295 "border-radius: 9px;"
1296 "color: %4;"
1297 "background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 %1, stop: 0.5 %3, stop: 1 %2);"
1298 "}"
1299 "QPushButton:hover {"
1300 "background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 %2, stop: 0.5 %1, stop: 1 %2);"
1301 "}"
1302 "QPushButton:flat {"
1303 " border: none; /* no border for a flat push button */"
1304 "}"
1305 )
1306 .arg(mol->AtomColor[0].name())
1307 .arg(mol->AtomColor[0].darker(200).name())
1308 .arg(mol->AtomColor[0].lighter(200).name())
1309 .arg((mol->AtomColor[0].value()<90)?"#ffffff":"#000000"));
1310 eacKRAD->setValue(eacGLW->mol->Kovalenz_Radien[0]/100.0);
1311 eacKRAD->setDecimals(2);
1312 eacKRAD->setSingleStep(0.01);
1313 eacRAD->setValue(eacGLW->mol->arad[0]);
1314 eacRAD->setDecimals(2);
1315 eacRAD->setSingleStep(0.01);
1316 connect(eacKRAD,SIGNAL(valueChanged(double)),this,SLOT(kradChanged(double)) );
1317 connect(eacRAD,SIGNAL(valueChanged(double)),this,SLOT(radChanged(double)) );
1318 eacHBDist->setValue(eacGLW->mol->hbdist());
1319 eacHBDist->setDecimals(2);
1320 eacHBDist->setSingleStep(0.01);
1321
1322 eacHBAngl->setMaximum(180.0);
1323 eacHBAngl->setMinimum(0.0);
1324 eacHBAngl->setValue(eacGLW->mol->hbangl());
1325 eacHBAngl->setDecimals(1);
1326 eacHBAngl->setSingleStep(0.1);
1327
1328 connect(eacHBDist,SIGNAL(valueChanged(double)),this,SLOT(hbdistChanged(double)) );
1329 connect(eacHBAngl,SIGNAL(valueChanged(double)),this,SLOT(hbanglChanged(double)) );
1330 eacGLO->addWidget(eacGLW,0,0,6,6);
1331 eacGLO->addWidget(globalStuff,0,6,1,3);
1332 //eacGLO->addWidget(smbl,1,7);
1333 eacGLO->addWidget(rad,3,7);
1334 eacGLO->addWidget(krad,4,7);
1335 //eacGLO->addWidget(eacCB,1,6);
1336 eacGLO->addWidget(eacRAD,3,6);
1337 eacGLO->addWidget(eacKRAD,4,6);
1338 eacGLO->addWidget(colorbut,2,6,1,3);
1339 eacGLO->addWidget(nlabx,5,6);
1340 eacGLO->addWidget(multi,4,8);
1341 eacGLO->addWidget(expbut,7,8);
1342 eacGLO->addWidget(impbut,7,7);
1343 eacGLO->addWidget(walbx,6,0);
1344 eacGLO->addWidget(rinbx,6,2);
1345 eacGLO->addWidget(sphbx,6,4);
1346 eacGLO->addWidget(sldbx,6,6);
1347 eacGLO->addWidget(noadp,6,7);
1348 eacGLO->addWidget(metalic,6,8);
1349 //eacGLO->addWidget(buttonBox,7,0,1,8);
1350 eacGLO->addWidget(psew,1,6,1,3);
1351 setLayout(eacGLO);
1352 connect(multi,SIGNAL(pressed()),this , SLOT(doMulti()));
1353 connect(colorbut,SIGNAL(pressed()),eacGLW,SLOT(colorDLG()));
1354 connect(psew,SIGNAL(pseSelected(int)), eacGLW, SLOT(changeAtom(int)));
1355 connect(psew,SIGNAL(pseSelected(int)), this, SLOT(updateLEs(int)));
1356 updateLEs(0);
1357 connect(walbx,SIGNAL(stateChanged(int)),eacGLW,SLOT(wallA(int)));
1358
1359 connect(nlabx,SIGNAL(stateChanged(int)),eacGLW,SLOT(nolaA(int)));
1360 connect(walbx,SIGNAL(stateChanged(int)),this,SLOT(checkSolid()));
1361 connect(rinbx,SIGNAL(stateChanged(int)),eacGLW,SLOT(ringA(int)));
1362 connect(sphbx,SIGNAL(stateChanged(int)),eacGLW,SLOT(spheA(int)));
1363 connect(sphbx,SIGNAL(stateChanged(int)),this,SLOT(checkBall()));
1364 connect(sldbx,SIGNAL(stateChanged(int)),eacGLW,SLOT(soldA(int)));
1365 connect(sldbx,SIGNAL(stateChanged(int)),this,SLOT(checkWall()));
1366 connect(metalic,SIGNAL(stateChanged(int)),eacGLW,SLOT(metalA(int)));
1367 eacGLW->setMSAA(true);
1368 }
1369
doMulti()1370 void EacDlg::doMulti(){
1371 MultiStyle *m = new MultiStyle(mol);
1372 if (m->exec()==QDialog::Accepted){
1373 int stt=0;
1374 if (m->sphbx->checkState())stt|=ATOM_STYLE_SPHERE;
1375 if (m->rinbx->checkState())stt|=ATOM_STYLE_RINGS;
1376 if (m->rinbx->checkState()==Qt::PartiallyChecked)stt|=ATOM_STYLE_WHITERING;
1377 if (m->walbx->checkState())stt|=ATOM_STYLE_WALLS;
1378 if (m->walbx->checkState()==Qt::PartiallyChecked)stt|=ATOM_STYLE_PLAID;
1379 if (m->sldbx->checkState())stt|=ATOM_STYLE_SOLID;
1380 if (m->metalic->checkState())stt|=ATOM_STYLE_METAL;
1381 int mi=qMin(m->start->currentIndex(),m->end->currentIndex()),
1382 ma=qMax(m->start->currentIndex(),m->end->currentIndex());
1383 for (int i=mi;i<=ma;i++){
1384 mol->AtomStyle[i]=stt;
1385 }
1386
1387 }
1388 }
1389
MultiStyle(Molecule * externMole)1390 MultiStyle::MultiStyle(Molecule *externMole){
1391 mol=externMole;
1392 setWindowTitle("Multiple Elements Styler");
1393 start = new QComboBox();
1394 end = new QComboBox();
1395 start->addItems(mol->thepse());
1396 start->setCurrentIndex(2);
1397 end->addItems(mol->thepse());
1398 end->setCurrentIndex(93);
1399 QLabel *staL =new QLabel("From: ");
1400 QLabel *endL =new QLabel("To: ");
1401 walbx = new QCheckBox("Draw intersecting planes");
1402 //walbx->setTristate();
1403 rinbx = new QCheckBox("Draw principal ellipses");
1404 rinbx->setTristate();
1405 sphbx = new QCheckBox("Draw ellipsoid surface");
1406 sldbx = new QCheckBox("Solid ellipsoid");
1407 metalic = new QCheckBox("Dashed Bonds to others");
1408 metalic->setCheckState ( Qt::Unchecked);
1409 walbx->setCheckState ( Qt::Checked);
1410 rinbx->setCheckState ( Qt::Checked);
1411 sphbx->setCheckState ( Qt::Checked);
1412 sldbx->setCheckState ( Qt::Unchecked);
1413 QGridLayout *eacGLO = new QGridLayout;
1414 eacGLO->addWidget(staL,0,0,1,1,Qt::AlignRight);
1415 eacGLO->addWidget(endL,0,2,1,1,Qt::AlignRight);
1416 eacGLO->addWidget(start,0,1);
1417 eacGLO->addWidget(end,0,3);
1418 eacGLO->addWidget(walbx,1,0);
1419 eacGLO->addWidget(rinbx,1,1);
1420 eacGLO->addWidget(sphbx,1,2);
1421 eacGLO->addWidget(sldbx,1,3);
1422 eacGLO->addWidget(metalic,1,4);
1423 connect(walbx,SIGNAL(stateChanged(int)),this,SLOT(checkSolid()));
1424 connect(sphbx,SIGNAL(stateChanged(int)),this,SLOT(checkBall()));
1425 connect(sldbx,SIGNAL(stateChanged(int)),this,SLOT(checkWall()));
1426 QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
1427 connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
1428 connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
1429 eacGLO->addWidget(buttonBox,2,0,1,5);
1430 // eacGLO->addWidget(,1,);
1431 setLayout(eacGLO);
1432 }
1433
checkWall()1434 void MultiStyle::checkWall(){
1435 if (sldbx->checkState()&&(walbx->checkState()))walbx->setCheckState(Qt::Unchecked);
1436 }
checkSolid()1437 void MultiStyle::checkSolid(){
1438 if (sldbx->checkState()&&(walbx->checkState()))sldbx->setCheckState(Qt::Unchecked);
1439 }
checkBall()1440 void MultiStyle::checkBall(){
1441 if (sphbx->checkState())sldbx->setEnabled(true);
1442 else sldbx->setEnabled(false);
1443 }
1444
reject()1445 void EacDlg::reject(){
1446 eacGLW->timer->stop();
1447 /*
1448 int i=eacGLW->xd.at(0).an;
1449 // extern molekul mol;
1450 mol->arad[i]=eacGLW->mol->arad[i]=eacRAD->text().toDouble();
1451 int stt=0;
1452 if (sphbx->checkState())stt|=ATOM_STYLE_SPHERE;
1453 if (rinbx->checkState())stt|=ATOM_STYLE_RINGS;
1454 if (rinbx->checkState()==Qt::PartiallyChecked)stt|=ATOM_STYLE_WHITERING;
1455 if (walbx->checkState())stt|=ATOM_STYLE_WALLS;
1456 if (walbx->checkState()==Qt::PartiallyChecked)stt|=ATOM_STYLE_PLAID;
1457 if (sldbx->checkState())stt|=ATOM_STYLE_SOLID;
1458 if (nlabx->checkState())stt|=ATOM_STYLE_NOLABEL;
1459 if (noadp->checkState())stt|=ATOM_STYLE_NOADP;
1460 if (metalic->checkState())stt|=ATOM_STYLE_METAL;
1461 mol->AtomStyle[i]=eacGLW->mol->AtomStyle[i]=stt;
1462 mol->Kovalenz_Radien[i]=eacGLW->mol->Kovalenz_Radien[i]=(int)(eacKRAD->text().toDouble()*100);*/
1463 mol->einstellung->beginGroup("Atoms");
1464 mol->einstellung->beginWriteArray("AtomStyles",107);
1465 for (int i = 0; i < 107; ++i) {
1466 mol->einstellung->setArrayIndex(i);
1467 mol->einstellung->setValue("Style", eacGLW->mol->AtomStyle[i]);
1468 }
1469 mol->einstellung->endArray();
1470 mol->einstellung->endGroup();
1471 mol->pmin=eacGLW->exmin;
1472 mol->pmax=eacGLW->exmax;
1473
1474 psew->esm->disconnect();
1475 delete psew->esm;
1476 psew->disconnect();
1477 eacGLW->disconnect();
1478 this->disconnect();
1479
1480 mol->g_Program->release();
1481 mol->g_Program->deleteLater();
1482 mol->g_Program=eacGLW->saveProgram;
1483 delete eacGLW;
1484 done(QDialog::Rejected);
1485 }
1486
accept()1487 void EacDlg::accept(){
1488 eacGLW->timer->stop();
1489 int i=eacGLW->xd.at(0).an;
1490 // extern molekul mol;
1491 mol->arad[i]=eacGLW->mol->arad[i]=eacRAD->text().toDouble();
1492 int stt=0;
1493 if (sphbx->checkState())stt|=ATOM_STYLE_SPHERE;
1494 if (rinbx->checkState())stt|=ATOM_STYLE_RINGS;
1495 if (rinbx->checkState()==Qt::PartiallyChecked)stt|=ATOM_STYLE_WHITERING;
1496 if (walbx->checkState())stt|=ATOM_STYLE_WALLS;
1497 if (walbx->checkState()==Qt::PartiallyChecked)stt|=ATOM_STYLE_PLAID;
1498 if (sldbx->checkState())stt|=ATOM_STYLE_SOLID;
1499 if (nlabx->checkState())stt|=ATOM_STYLE_NOLABEL;
1500 if (noadp->checkState())stt|=ATOM_STYLE_NOADP;
1501 mol->AtomStyle[i]=eacGLW->mol->AtomStyle[i]=stt;
1502 mol->Kovalenz_Radien[i]=eacGLW->mol->Kovalenz_Radien[i]=(int)(eacKRAD->text().toDouble()*100);
1503 mol->einstellung->beginGroup("Atoms");
1504 mol->einstellung->beginWriteArray("AtomStyles",107);
1505 for (int i = 0; i < 107; ++i) {
1506 mol->einstellung->setArrayIndex(i);
1507 mol->einstellung->setValue("Style", eacGLW->mol->AtomStyle[i]);
1508 }
1509 mol->einstellung->endArray();
1510 mol->einstellung->endGroup();
1511
1512 psew->esm->disconnect();
1513 delete psew->esm;
1514 psew->disconnect();
1515 eacGLW->disconnect();
1516 this->disconnect();
1517 mol->g_Program->release();
1518 mol->g_Program->deleteLater();
1519 mol->g_Program=eacGLW->saveProgram;
1520 done(QDialog::Accepted);
1521 }
1522