Debian Codegraph @

fourxle.cpp

raw symbols SCIP
1
2 /****************************************************************************
3 **
4 ** Copyright (C) 2011 Christian B. Huebschle & George M. Sheldrick
5 ** All rights reserved.
6 ** Contact: [email protected]
7 **
8 ** This file is part of the ShelXle
9 **
10 ** This file may be used under the terms of the GNU Lesser
11 ** General Public License version 2.1 as published by the Free Software
12 ** Foundation and appearing in the file COPYING included in the
13 ** packaging of this file. Please review the following information to
14 ** ensure the GNU Lesser General Public License version 2.1 requirements
15 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
16 **
17 **
18 ****************************************************************************/
19 #include "fourxle.h"
20 #include <QtCore>
21 #include <QtGui>
22 #include <QDialog>
23 #include <QColorDialog>
24 #include <QLineEdit>
25 #include <QGraphicsScene>
26 #include <QGraphicsItem>
27 #include <QGraphicsView>
28 #include "deprecation.h"
29 #include "itsme.h"
30 //üäöß
31 FourXle::FourXle(Molecule *mole_, PlayOpenGL *chgl_,QToolBar *toolView, double resol, double wght){
32 // printf("FourXle\n");
33 ownfcf6_=NULL;
34 mole =mole_;
35 f000=0.0;
36 overridef000=-1.0;
37 n1=n2=n3=n4=n5=0;
38 voxelstr.clear();
39 chgl=chgl_;
40 MYFCF=false;
41 oldatomsize=-1;
42 //chgl->habzutun=false;
43 map_radius=5.0;
44 maptrunc = 2;
45 mapcontrol=nullptr;
46 resDir=QDir::current();
47 // for (int i=0; i<37; i++) chgl->foubas[i]=0;
48 /*
49 QVector< QVector< float > > chgl->fchgl->fVertexes;
50 QVector< QVector< float > > chgl->fNormals;
51 */
52 chgl->fVertexes.resize(28);
53 chgl->fNormals.resize(28);
54 HKLMX=200;
55 datfo_fc=datfo=nullptr;
56 nodex=nodey=nodez=nullptr;
57 noGoMap=nullptr;
58 nodeX=nodeY=nodeZ=nullptr;
59 urs=V3(0,0,0);
60 nr=0;
61 nc=0;
62 sigma[0]=sigma[1]=iso[0]=iso[1]=0;
63 chgl->lintrans=0.8;
64 chgl->linwidth=0.5;
65 rr=resol;
66 rw=wght;
67 chgl->foact=toolView->addAction(QIcon(mole->theIconPath+"fomaps.svg"),"toggle Fo map",chgl,SLOT(update()));
68 chgl->foact->setWhatsThis("<h1>Toggle Fo map <img src=\""+mole->theIconPath+"fomaps.svg\"></h1> Toggle F-observed map on/off.");
69 connect(chgl->foact,SIGNAL(destroyed(QObject*)),this,SLOT(foactDestroyed()));
70 chgl->foact->setCheckable(true);
71 chgl->fofcact=toolView->addAction(QIcon(mole->theIconPath+"diffmap.svg"),"toggle Fo-Fc map",chgl,SLOT(update()));
72 chgl->fofcact->setWhatsThis("<h1>Toggle Fo-Fc map<img src=\""+mole->theIconPath+"diffmap.svg\"></h1> Toggle (F-observed)-(F-calculated) map on/off. Fo-Fc map is also known as difference Fourier map.");
73 connect(chgl->fofcact,SIGNAL(destroyed(QObject*)),this,SLOT(fofcactDestroyed()));
74 chgl->fofcact->setCheckable(true);
75 chgl->fofcact->setVisible(false);
76 chgl->foact->setVisible(false);
77 doMaps = new QCheckBox("Calculate Maps",0);
78 doMaps->setChecked(true);
79 doMaps->setWhatsThis("<h1>Calculate maps</h1> Enables Fo and Fo-Fc map calculation. This can only be performed if LIST is set to 6.");
80 keepIso = new QCheckBox("Keep map iso values");
81 keepIso->setChecked(false);
82 keepIso->setVisible(false);
83 connect(keepIso,SIGNAL(toggled(bool)), this,SLOT(keepIsoValues(bool )));
84 connect(chgl,SIGNAL(destroyed(QObject*)),this,SLOT(chglDestroyed()));
85 char *ENUS=setlocale(LC_ALL,"C");
86 if (!ENUS)ENUS=setlocale(LC_ALL,"en_US.UTF-8");
87 {
88 buttonBoxMC = new QDialogButtonBox( QDialogButtonBox::Apply | QDialogButtonBox::Cancel);
89 applyMC = buttonBoxMC->button(QDialogButtonBox::Apply);
90 applyDF = buttonBoxMC->addButton("Apply defaults",QDialogButtonBox::ActionRole);
91 wl= new QLabel("Factor to downweight weak data");
92 pl= new QLabel("Map precision: ");
93 dl= new QLabel("Fo-Fc map: ");
94 ol= new QLabel("F-observed map: ");
95 sl= new QLabel("Map truncation type: ");
96 lw= new QLabel("Line width: ");
97 ltz= new QLabel("Line transparency: ");
98 md = new QDialog();
99 md->setWindowTitle("Map Control");
100 connect(applyMC , SIGNAL(clicked()), this , SLOT(controlMap()));
101 connect(applyMC , SIGNAL(clicked()), this , SLOT(openMapControl()));
102 connect(applyDF , SIGNAL(clicked()), this , SLOT(mapDefault()));
103 connect(buttonBoxMC, SIGNAL(rejected()), md, SLOT(hide()));
104
105 mapprec = new QDoubleSpinBox(md);
106 mapprec->setMinimum(1.1);
107 mapprec->setMaximum(8.0);
108 mapprec->setValue(rr);
109 mapprec->setSingleStep(0.1);
110
111 lineTrans = new QDoubleSpinBox(md);
112 lineTrans->setMinimum(0.1);
113 lineTrans->setMaximum(1.0);
114 lineTrans->setValue(chgl->lintrans);
115 lineTrans->setSingleStep(0.1);
116
117 lineWidth = new QDoubleSpinBox(md);
118 lineWidth->setMinimum(0.15);
119 lineWidth->setMaximum(4.0);
120 lineWidth->setValue(chgl->linwidth);
121 lineWidth->setSingleStep(0.1);
122
123 weak = new QDoubleSpinBox(md);
124 weak->setMinimum(0.1);
125 weak->setMaximum(8.0);
126 weak->setValue(rw);
127 weak->setSingleStep(0.1);
128
129 difmaps = new QDoubleSpinBox(md);
130 difmaps->setMinimum(0.025);
131 difmaps->setMaximum(9999);
132 difmaps->setValue(fabs(iso[1]));
133 difmaps->setSingleStep(fabs(iso[1])/10.0);
134 difmaps->setSuffix("e/A^3");
135
136 fomaps = new QDoubleSpinBox();
137 fomaps->setMinimum(0.025);
138 fomaps->setMaximum(9999);
139 fomaps->setValue(iso[0]);
140 fomaps->setSingleStep(iso[0]/10.0);
141 fomaps->setSuffix("e/A^3");
142
143 cutrange = new QDoubleSpinBox(md);
144 cutrange->setMinimum(0.5);
145 cutrange->setMaximum(3.0);
146 cutrange->setValue(1.41);
147 cutrange->setSingleStep(0.1);
148 cutrange->setSuffix("A");
149 cutrange->setPrefix("cut range ");
150
151 maprad = new QDoubleSpinBox();
152 maprad->setValue(map_radius);
153 maprad->setMinimum(0);
154 maprad->setMaximum(25.0);
155 maprad->setSuffix("A");
156 maprad->setPrefix("Map radius: ");
157 maprad->setSingleStep(0.3);
158 mapSchnitt= new QComboBox();
159 mapSchnitt->addItem("one complete unit cell",0);
160 mapSchnitt->addItem("sphere around rotation center",1);
161 mapSchnitt->addItem("cut range around visible atoms or peaks",2);
162 mapSchnitt->setCurrentIndex(maptrunc);
163 connect(mapSchnitt,SIGNAL(currentIndexChanged(int)),this,SLOT(schnittart(int)));
164 chgl->lighting = new QCheckBox("Lighting");
165 chgl->lighting->setChecked(true);
166 chgl->niceTrans= new QCheckBox("Undistorted transparency");
167 chgl->niceTrans->setChecked(false);
168 chgl->fillMap= new QCheckBox("Filled map surface");
169 chgl->fillMap->setChecked(false);
170 mdl = new QGridLayout();
171 mdl->addWidget(mapprec,0,1);
172 mdl->addWidget(weak,1,1);
173 mdl->addWidget(difmaps,2,1);
174 mdl->addWidget(fomaps,3,1);
175 mdl->addWidget(maprad,6,2);
176 mdl->addWidget(mapSchnitt,6,1);
177 mdl->addWidget(cutrange,6,2);
178 mdl->addWidget(lineTrans,7,1);
179 mdl->addWidget(lineWidth,8,1);
180 mdl->addWidget(chgl->lighting,9,1);
181 mdl->addWidget(chgl->niceTrans,9,0);
182 mdl->addWidget(chgl->fillMap,9,2);
183 connect(lineTrans,SIGNAL(valueChanged(double)),this,SLOT(updateLines()));
184 connect(lineWidth,SIGNAL(valueChanged(double)),this,SLOT(updateLines()));
185
186 connect(chgl->fillMap,SIGNAL(stateChanged(int)),chgl,SLOT(update()));
187 connect(chgl->niceTrans,SIGNAL(stateChanged(int)),chgl,SLOT(update()));
188 connect(chgl->lighting,SIGNAL(stateChanged(int)),chgl,SLOT(update()));
189 mdl->addWidget(pl,0,0);
190 mdl->addWidget(wl,1,0);
191 mdl->addWidget(dl,2,0);
192 mdl->addWidget(ol,3,0);
193 //mdl->addWidget(rl,5,0);
194 mdl->addWidget(sl,6,0);
195 mdl->addWidget(ltz,7,0);
196 mdl->addWidget(lw,8,0);
197
198 QTabWidget *tabWidget = new QTabWidget(md);
199 QWidget *gwmd,*admd;
200 gwmd = new QWidget();
201
202 gwmd->setLayout(mdl);
203 admd = new QWidget();
204 QVBoxLayout *mdmain= new QVBoxLayout;
205 tabWidget->addTab(gwmd,"General");
206 tabWidget->addTab(admd,"Advanced");
207 einstellung = new QSettings( QSettings::IniFormat, QSettings::UserScope ,PROGRAM_NAME, mole->mynewnameis );
208
209 einstellung->beginGroup("Colors");
210 chgl->fopc=einstellung->value("FourFoPlusColor", QColor("#0000FF")).value<QColor>();
211 chgl->fomc=einstellung->value("FourFoMinusColor", QColor("#FFA600")).value<QColor>();
212 chgl->dipc=einstellung->value("FourDiffPlusColor", QColor("#00B200")).value<QColor>();
213 chgl->dimc=einstellung->value("FourDiffMinusColor",QColor("#CC0000")).value<QColor>();
214 einstellung->endGroup();
215
216 foPlusButton =new QPushButton("Fo positive color");
217 foPlusButton->setStyleSheet(QString(
218 "QPushButton {"
219 "font-size:16px;"
220 "font-weight:bold;"
221 "border: 1px solid #000000;"
222 "border-radius: 9px;"
223 "color: %4;"
224 "background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 %1, stop: 0.5 %3, stop: 1 %2);"
225 "}"
226 "QPushButton:hover {"
227 "background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 %1, stop: 0.5 %2, stop: 1 %1);"
228 "border: 0px"
229 "}"
230 "QPushButton:flat {"
231 " border: none; /* no border for a flat push button */"
232 "}"
233 )
234 .arg( chgl->fopc.name())
235 .arg( chgl->fopc.darker(200).name())
236 .arg( chgl->fopc.lighter(100).name())
237 .arg("#ffffff"));
238 connect(foPlusButton,SIGNAL(pressed()),this,SLOT(colorDLGFOP()));
239 defColorButton =new QPushButton("Default color scheme");
240 connect(defColorButton,SIGNAL(pressed()),this,SLOT(defaultColors()));
241 foMinusButton =new QPushButton("Fo negative color");
242 foMinusButton->setStyleSheet(QString(
243 "QPushButton {"
244 "font-size:16px;"
245 "font-weight:bold;"
246 "border: 1px solid #000000;"
247 "border-radius: 9px;"
248 "color: %4;"
249 "background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 %1, stop: 0.5 %3, stop: 1 %2);"
250 "}"
251 "QPushButton:hover {"
252 "background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 %1, stop: 0.5 %2, stop: 1 %1);"
253 "border: 0px"
254 "}"
255 "QPushButton:flat {"
256 " border: none; /* no border for a flat push button */"
257 "}"
258 )
259 .arg( chgl->fomc.name())
260 .arg( chgl->fomc.darker(200).name())
261 .arg( chgl->fomc.lighter(100).name())
262 .arg("#ffffff"));
263 connect(foMinusButton,SIGNAL(pressed()),this,SLOT(colorDLGFOM()));
264
265 diffMinusButton =new QPushButton("Fo-Fc negative color");
266 diffMinusButton->setStyleSheet(QString(
267 "QPushButton {"
268 "font-size:16px;"
269 "font-weight:bold;"
270 "border: 1px solid #000000;"
271 "border-radius: 9px;"
272 "color: %4;"
273 "background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 %1, stop: 0.5 %3, stop: 1 %2);"
274 "}"
275 "QPushButton:hover {"
276 "background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 %1, stop: 0.5 %2, stop: 1 %1);"
277 "border: 0px"
278 "}"
279 "QPushButton:flat {"
280 " border: none; /* no border for a flat push button */"
281 "}"
282 )
283 .arg( chgl->dimc.name())
284 .arg( chgl->dimc.darker(200).name())
285 .arg( chgl->dimc.lighter(100).name())
286 .arg("#ffffff"));
287 connect(diffMinusButton,SIGNAL(pressed()),this,SLOT(colorDLGDIM()));
288
289 diffPlusButton =new QPushButton("Fo-Fc positive color");
290 diffPlusButton->setStyleSheet(QString(
291 "QPushButton {"
292 "font-size:16px;"
293 "font-weight:bold;"
294 "border: 1px solid #000000;"
295 "border-radius: 9px;"
296 "color: %4;"
297 "background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 %1, stop: 0.5 %3, stop: 1 %2);"
298 "}"
299 "QPushButton:hover {"
300 "background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 %1, stop: 0.5 %2, stop: 1 %1);"
301 "border: 0px"
302 "}"
303 "QPushButton:flat {"
304 " border: none; /* no border for a flat push button */"
305 "}"
306 )
307 .arg( chgl->dipc.name())
308 .arg( chgl->dipc.darker(200).name())
309 .arg( chgl->dipc.lighter(100).name())
310 .arg("#ffffff"));
311 connect(diffPlusButton,SIGNAL(pressed()),this,SLOT(colorDLGDIP()));
312
313 amdl = new QVBoxLayout();
314 amdl->addWidget(foPlusButton);
315 amdl->addWidget(foMinusButton);
316 amdl->addWidget(diffPlusButton);
317 amdl->addWidget(diffMinusButton);
318 amdl->addWidget(defColorButton);
319 jnkButton = new QPushButton("fractal dimension analysis");
320 amdl->addWidget(jnkButton);
321 admd->setLayout(amdl);
322 mdmain->addWidget(tabWidget);
323 mdmain->addWidget(buttonBoxMC);
324
325 md->setLayout(mdmain);
326 md->setModal (false);
327 ownfcf6=new QCheckBox("fcf6 by hkl");
328 ownfcf6->setChecked(MYFCF);
329 ownfcf6_=new QCheckBox("Compute fcf6 file from structure factors and observed data from hkl file");
330 ownfcf6_->setChecked(MYFCF);
331 amdl->addWidget(ownfcf6_);
332 connect(ownfcf6_,SIGNAL(toggled(bool)),this , SLOT(doMapsNow(bool)));
333 connect(doMaps,SIGNAL(toggled(bool)),this , SLOT(doMapsNow(bool)));
334 einstellung->beginGroup("Window");//einstellung->beginGroup("");
335 if (einstellung->contains("Fo-Map")) chgl->foact->setChecked(einstellung->value("Fo-Map").toBool());
336 if (einstellung->contains("Fc-Fo-Map")) chgl->fofcact->setChecked(einstellung->value("Fc-Fo-Map").toBool());
337 if (einstellung->contains("Map-truncation-type")) maptrunc=einstellung->value("Map-truncation-type").toInt();
338 if (einstellung->contains("Map-Line-Transparency")) chgl->lintrans = einstellung->value("Map-Line-Transparency").toDouble();
339 if (einstellung->contains("Map-Line-Width")) chgl->linwidth = einstellung->value("Map-Line-Width").toDouble();
340 if (einstellung->contains("Map-Resolution")) rr = einstellung->value("Map-Resolution").toDouble();
341 if (einstellung->contains("Map-Weight")) rw = einstellung->value("Map-Weight").toDouble();
342 if (einstellung->contains("Map-Lighting")) chgl->lighting->setChecked(einstellung->value("Map-Lighting").toBool());
343 if (einstellung->contains("Nice-Transparency")) chgl->niceTrans->setChecked(einstellung->value("Nice-Transparency").toBool());
344 if (einstellung->contains("Solid-Map")) chgl->fillMap->setChecked(einstellung->value("Solid-Map").toBool());
345 if (einstellung->contains("Calculate-Maps")) doMaps->setChecked(einstellung->value("Calculate-Maps").toBool());
346 if (einstellung->contains("KeepMapIsoValues")){
347 keepIso->setChecked(einstellung->value("KeepMapIsoValues").toBool());
348 // keepiso->setChecked(einstellung->value("KeepMapIsoValues").toBool());
349 }
350 einstellung->endGroup();
351 schnittart(maptrunc);
352 // printf("@!#$ %p\n",einstellung);
353 md->hide();
354 }
355 connect(ownfcf6,SIGNAL(toggled(bool)),this , SLOT(doMapsNow(bool)));
356 isBelo=false;
357 //printf("constr. belo?%d\n",isBelo);
358 //printf("%s\n",ENUS);
359 }
360
361 FourXle::~FourXle(){
362 //printf("Maps will close... %p\n",chgl);
363 if (chgl!=NULL) disconnect(chgl,SIGNAL(diffscroll(int ,int )),0,0);
364 if (chgl!=NULL) disconnect(chgl,SIGNAL(neuemitte(V3)),0,0);
365 if (chgl!=NULL) disconnect(chgl,SIGNAL(inimibas()),0,0);
366 //printf("kill maps%d\n",__LINE__);
367 killmaps();
368 //printf("killed maps%d\n",__LINE__);
369 //doMaps->deleteLater();//apex qt5 crash here!
370 //printf("Maps closed.\n");
371 }
372
373 void FourXle::mapDefault(){
374 map_radius= 5.0;
375 maptrunc = 2;
376 rr= 2.0;
377 rw= 1.0;
378 chgl->lintrans= 0.8;
379 chgl->linwidth= 0.5;
380 iso[1]= sigma[0] * 2.7f;
381 iso[0]= sigma[1] * 1.2f;
382 chgl->niceTrans->setChecked(false);
383 chgl->lighting->setChecked(true);
384 chgl->fillMap->setChecked(false);
385 weak->setValue(rw);
386 mapprec->setValue(rr);
387 difmaps->setValue(fabs(iso[1]));
388 difmaps->setSingleStep(fabs(iso[1])/10.0);
389 lineTrans->setValue(chgl->lintrans);
390 lineWidth->setValue(chgl->linwidth);
391 fomaps->setValue(iso[0]);
392 fomaps->setSingleStep(iso[0]/10.0);
393 maprad->setValue(map_radius);
394 mapSchnitt->setCurrentIndex(maptrunc);
395 controlMap();
396 }
397
398 void FourXle::schnittart(int trunc){
399 if (trunc==1) maprad->show();
400 else maprad->hide();
401 if (trunc==2) cutrange->show();
402 else cutrange->hide();
403 }
404
405 void FourXle::keepIsoValues(bool b){
406 keepiso->setChecked(b);
407 keepIso->setChecked(b);
408 keepIso->setVisible(b);
409 if (n5>0){
410 sigma[0] = sigmaFoFc();
411 sigma[1] = sigmaFo();
412 iso[1]= sigma[0] * 2.7f;
413 iso[0]= sigma[1] * 1.2f;
414 fomaps->setValue(iso[0]);
415 difmaps->setValue(fabs(iso[1]));
416 controlMap();
417 }
418 }
419
420 void FourXle::updateLines(){
421 chgl->lintrans=lineTrans->value();
422 chgl->linwidth=lineWidth->value();
423 chgl->update();
424 }
425
426 void FourXle::killFourXleFirst(){
427 //fprintf(stderr,"chgl dies...argh...\n");
428 killmaps();
429 n5=0;
430 if (mapcontrol!=NULL) mapcontrol->setVisible(false);
431 }
432
433 void FourXle::doMapsNow(bool b){
434 //isBelo=false;
435 bool bb=MYFCF;
436 bool B = (MYFCF!=ownfcf6->isChecked())||(MYFCF!=ownfcf6_->isChecked());
437 MYFCF=(B)?!MYFCF:MYFCF;
438 if (bb!=MYFCF) {
439 ownfcf6->disconnect();
440 ownfcf6_->disconnect();
441 ownfcf6->setChecked(MYFCF);
442 ownfcf6_->setChecked(MYFCF);
443 connect(ownfcf6,SIGNAL(toggled(bool)),this , SLOT(doMapsNow(bool)));
444 connect(ownfcf6_,SIGNAL(toggled(bool)),this , SLOT(doMapsNow(bool)));
445 emit reloadRes();
446 return;
447 }
448 if (!b) {
449 killmaps();
450 n5=0;
451 if (mapcontrol!=NULL) mapcontrol->setVisible(false);
452 chgl->update();
453 return;
454 } else {
455 bool hamrsho=((iso[0]==iso[1])&&((iso[0]==0.0f)||(iso[0]==0.03f)));
456 if (!loadFouAndPerform(fouName.toLocal8Bit(),hamrsho)){
457 emit bigmessage(QString("<font color=red>Error while loading %1!</font><br>").arg(fouName));
458 if (mapcontrol!=NULL) mapcontrol->setVisible(false);
459 } else {
460 if (mapcontrol!=NULL) mapcontrol->setVisible(true);
461 if (!hamrsho) {
462 sigma[0] = sigmaFoFc();
463 sigma[1] = sigmaFo();
464 iso[1]= sigma[0] * 2.7f;
465 iso[0]= sigma[1] * 1.2f;
466 fomaps->setValue(iso[0]);
467 difmaps->setValue(fabs(iso[1]));
468 inimap();
469 }
470 }
471 chgl->update();
472 }
473
474 }
475
476 void FourXle::controlMap(){
477 maptrunc=mapSchnitt->currentIndex ();
478 if ((rw!=weak->value())||(rr!=mapprec->value())){
479 rr = mapprec->value();
480 rw = weak->value();
481 if (!loadFouAndPerform(fouName.toLocal8Bit(),false)){
482 emit bigmessage(QString("<font color=red>Error while loading %1!</font><br>").arg(fouName));
483 }
484 }
485 chgl->lintrans = lineTrans->value();
486 chgl->linwidth = lineWidth->value();
487 map_radius = maprad->value();
488 iso[0] = fomaps->value();
489 iso[1] = -difmaps->value();
490 inimap();
491 chgl->update();
492 }
493
494 void FourXle::killmaps(){
495 //printf("KM belo?%d chgl->%p dataFo-Fc->%p dataFo->%p\n",isBelo,chgl,datfo_fc,datfo);
496 isBelo=false;
497 // printf("These nodes will be killed %p %p %p\n",nodex,nodey,nodez);
498 /*! deletes all fourier maps and frees the memory
499 */
500 // printf("I kill maps\n");
501
502 if (chgl!=NULL) disconnect(chgl,SIGNAL(diffscroll(int ,int )),0,0);
503 if (chgl!=NULL) disconnect(chgl,SIGNAL(neuemitte(V3)),0,0);
504 if (chgl!=NULL) disconnect(chgl,SIGNAL(inimibas()),0,0);
505 //printf("emit halt\n");
506 //emit haltMW();
507 //printf("halt emited\n");
508 if ((chgl!=NULL)&&(chgl->fofcact!=NULL)) chgl->fofcact->setVisible(false);
509 if ((chgl!=NULL)&&(chgl->foact!=NULL)) chgl->foact->setVisible(false);
510 if (datfo!=NULL) free(datfo);
511 if (datfo_fc!=NULL) free(datfo_fc);
512 if (nodex!=NULL) free(nodex);
513 nodex=NULL;
514 if (nodey!=NULL) free(nodey);
515 nodey=NULL;
516 if (nodez!=NULL) free(nodez);
517 nodez=NULL;
518 if (noGoMap!=NULL) free(noGoMap);
519 noGoMap=NULL;
520 if (nodeX!=NULL) free(nodeX);
521 if (nodeY!=NULL) free(nodeY);
522 if (nodeZ!=NULL) free(nodeZ);
523 nodeX=nodeY=nodeZ=NULL;
524 datfo=datfo_fc=NULL;
525 if (chgl!=NULL){
526 //printf("I kill maps %d! %d!\n",chgl->fVertexes.size(),chgl->fNormals.size());
527 int sumsize=0;
528 for (int i=0; i<chgl->fVertexes.size(); i++) {sumsize+=chgl->fVertexes[i].size();chgl->fVertexes[i].clear();}
529 for (int i=0; i<chgl->fNormals.size(); i++) {sumsize+=chgl->fNormals[i].size();chgl->fNormals[i].clear();}
530 //printf("Freed %d normals and vertices.\n",sumsize);
531 }//else printf("chgl is already dead!\n");
532 }
533
534 void FourXle::colorDLGFOP(){
535 QColor color;
536 color=QColorDialog::getColor(chgl->fopc, md);
537 if (color.isValid()) {
538 chgl->fopc=color;
539 foPlusButton->setStyleSheet(QString(
540 "QPushButton {"
541 "font-size:16px;"
542 "font-weight:bold;"
543 "border: 1px solid #000000;"
544 "border-radius: 9px;"
545 "color: %4;"
546 "background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 %1, stop: 0.5 %3, stop: 1 %2);"
547 "}"
548 "QPushButton:hover {"
549 "background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 %2, stop: 0.5 %1, stop: 1 %2);"
550 "}"
551 "QPushButton:flat {"
552 " border: none; /* no border for a flat push button */"
553 "}"
554 )
555 .arg(color.name())
556 .arg(color.darker(200).name())
557 .arg(color.lighter(100).name())
558 .arg("#ffffff"));
559 }
560 einstellung->beginGroup("Colors");
561 einstellung->setValue("FourFoPlusColor", chgl->fopc);
562 einstellung->setValue("FourFoMinusColor", chgl->fomc);
563 einstellung->setValue("FourDiffPlusColor", chgl->dipc);
564 einstellung->setValue("FourDiffMinusColor",chgl->dimc);
565 einstellung->endGroup();
566 md->update();
567
568 }
569
570 void FourXle::colorDLGFOM(){
571 QColor color;
572 color=QColorDialog::getColor(chgl->fopc, md);
573 if (color.isValid()) {
574 chgl->fomc=color;
575 foMinusButton->setStyleSheet(QString(
576 "QPushButton {"
577 "font-size:16px;"
578 "font-weight:bold;"
579 "border: 1px solid #000000;"
580 "border-radius: 9px;"
581 "color: %4;"
582 "background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 %1, stop: 0.5 %3, stop: 1 %2);"
583 "}"
584 "QPushButton:hover {"
585 "background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 %2, stop: 0.5 %1, stop: 1 %2);"
586 "}"
587 "QPushButton:flat {"
588 " border: none; /* no border for a flat push button */"
589 "}"
590 )
591 .arg(color.name())
592 .arg(color.darker(200).name())
593 .arg(color.lighter(100).name())
594 .arg("#ffffff"));
595 }
596 einstellung->beginGroup("Colors");
597 einstellung->setValue("FourFoPlusColor", chgl->fopc);
598 einstellung->setValue("FourFoMinusColor", chgl->fomc);
599 einstellung->setValue("FourDiffPlusColor", chgl->dipc);
600 einstellung->setValue("FourDiffMinusColor",chgl->dimc);
601 einstellung->endGroup();
602 md->update();
603
604 }
605
606 void FourXle::colorDLGDIP(){
607 QColor color;
608 color=QColorDialog::getColor(chgl->fopc, md);
609 if (color.isValid()) {
610 chgl->dipc=color;
611
612 diffPlusButton->setStyleSheet(QString(
613 "QPushButton {"
614 "font-size:16px;"
615 "font-weight:bold;"
616 "border: 1px solid #000000;"
617 "border-radius: 9px;"
618 "color: %4;"
619 "background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 %1, stop: 0.5 %3, stop: 1 %2);"
620 "}"
621 "QPushButton:hover {"
622 "background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 %2, stop: 0.5 %1, stop: 1 %2);"
623 "}"
624 "QPushButton:flat {"
625 " border: none; /* no border for a flat push button */"
626 "}"
627 )
628 .arg(color.name())
629 .arg(color.darker(200).name())
630 .arg(color.lighter(100).name())
631 .arg("#ffffff"));
632 }
633 einstellung->beginGroup("Colors");
634 einstellung->setValue("FourFoPlusColor", chgl->fopc);
635 einstellung->setValue("FourFoMinusColor", chgl->fomc);
636 einstellung->setValue("FourDiffPlusColor", chgl->dipc);
637 einstellung->setValue("FourDiffMinusColor",chgl->dimc);
638 einstellung->endGroup();
639 md->update();
640 }
641
642 void FourXle::colorDLGDIM(){
643 QColor color;
644 color=QColorDialog::getColor(chgl->fopc, md);
645 if (color.isValid()) {
646 chgl->dimc=color;
647
648 diffMinusButton->setStyleSheet(QString(
649 "QPushButton {"
650 "font-size:16px;"
651 "font-weight:bold;"
652 "border: 1px solid #000000;"
653 "border-radius: 9px;"
654 "color: %4;"
655 "background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 %1, stop: 0.5 %3, stop: 1 %2);"
656 "}"
657 "QPushButton:hover {"
658 "background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 %2, stop: 0.5 %1, stop: 1 %2);"
659 "}"
660 "QPushButton:flat {"
661 " border: none; /* no border for a flat push button */"
662 "}"
663 )
664 .arg(color.name())
665 .arg(color.darker(200).name())
666 .arg(color.lighter(100).name())
667 .arg("#ffffff"));
668 }
669 einstellung->beginGroup("Colors");
670 einstellung->setValue("FourFoPlusColor", chgl->fopc);
671 einstellung->setValue("FourFoMinusColor", chgl->fomc);
672 einstellung->setValue("FourDiffPlusColor", chgl->dipc);
673 einstellung->setValue("FourDiffMinusColor",chgl->dimc);
674 einstellung->endGroup();
675 md->update();
676
677 }
678
679 void FourXle::openMapControl(){
680 weak->setValue(rw);
681 mapprec->setValue(rr);
682 difmaps->setValue(fabs(iso[1]));
683 difmaps->setSingleStep(fabs(iso[1])/10.0);
684 lineTrans->setValue(chgl->lintrans);
685 lineWidth->setValue(chgl->linwidth);
686 fomaps->setValue(iso[0]);
687 fomaps->setSingleStep(iso[0]/10.0);
688 maprad->setValue(map_radius);
689 mapSchnitt->setCurrentIndex(maptrunc);
690 md->show();
691 }
692
693 void FourXle::defaultColors(){
694 chgl->fopc = QColor("#0000FF");
695 chgl->fomc = QColor("#FFA600");
696 chgl->dipc = QColor("#00B200");
697 chgl->dimc = QColor("#CC0000");
698 foPlusButton->setStyleSheet(QString(
699 "QPushButton {"
700 "font-size:16px;"
701 "font-weight:bold;"
702 "border: 1px solid #000000;"
703 "border-radius: 9px;"
704 "color: %4;"
705 "background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 %1, stop: 0.5 %3, stop: 1 %2);"
706 "}"
707 "QPushButton:hover {"
708 "background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 %1, stop: 0.5 %2, stop: 1 %1);"
709 "border: 0px"
710 "}"
711 "QPushButton:flat {"
712 " border: none; /* no border for a flat push button */"
713 "}"
714 )
715 .arg( chgl->fopc.name())
716 .arg( chgl->fopc.darker(200).name())
717 .arg( chgl->fopc.lighter(100).name())
718 .arg("#ffffff"));
719
720 foMinusButton->setStyleSheet(QString(
721 "QPushButton {"
722 "font-size:16px;"
723 "font-weight:bold;"
724 "border: 1px solid #000000;"
725 "border-radius: 9px;"
726 "color: %4;"
727 "background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 %1, stop: 0.5 %3, stop: 1 %2);"
728 "}"
729 "QPushButton:hover {"
730 "background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 %1, stop: 0.5 %2, stop: 1 %1);"
731 "border: 0px"
732 "}"
733 "QPushButton:flat {"
734 " border: none; /* no border for a flat push button */"
735 "}"
736 )
737 .arg( chgl->fomc.name())
738 .arg( chgl->fomc.darker(200).name())
739 .arg( chgl->fomc.lighter(100).name())
740 .arg("#ffffff"));
741
742 diffMinusButton->setStyleSheet(QString(
743 "QPushButton {"
744 "font-size:16px;"
745 "font-weight:bold;"
746 "border: 1px solid #000000;"
747 "border-radius: 9px;"
748 "color: %4;"
749 "background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 %1, stop: 0.5 %3, stop: 1 %2);"
750 "}"
751 "QPushButton:hover {"
752 "background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 %1, stop: 0.5 %2, stop: 1 %1);"
753 "border: 0px"
754 "}"
755 "QPushButton:flat {"
756 " border: none; /* no border for a flat push button */"
757 "}"
758 )
759 .arg( chgl->dimc.name())
760 .arg( chgl->dimc.darker(200).name())
761 .arg( chgl->dimc.lighter(100).name())
762 .arg("#ffffff"));
763
764 diffPlusButton->setStyleSheet(QString(
765 "QPushButton {"
766 "font-size:16px;"
767 "font-weight:bold;"
768 "border: 1px solid #000000;"
769 "border-radius: 9px;"
770 "color: %4;"
771 "background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 %1, stop: 0.5 %3, stop: 1 %2);"
772 "}"
773 "QPushButton:hover {"
774 "background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 %1, stop: 0.5 %2, stop: 1 %1);"
775 "border: 0px"
776 "}"
777 "QPushButton:flat {"
778 " border: none; /* no border for a flat push button */"
779 "}"
780 )
781 .arg( chgl->dipc.name())
782 .arg( chgl->dipc.darker(200).name())
783 .arg( chgl->dipc.lighter(100).name())
784 .arg("#ffffff"));
785 einstellung->beginGroup("Colors");
786 einstellung->setValue("FourFoPlusColor", chgl->fopc);
787 einstellung->setValue("FourFoMinusColor", chgl->fomc);
788 einstellung->setValue("FourDiffPlusColor", chgl->dipc);
789 einstellung->setValue("FourDiffMinusColor",chgl->dimc);
790 einstellung->endGroup();
791 md->update();
792
793 }
794
795 bool FourXle::loadFouAndPerform(const char filename[],bool neu){
796 /*! loads a fcf file prepares the reciprocal data for the fourier transpormation and performs it.
797 */
798 foti.start();
799
800 const int it[143]= {2,3,4,5,6,8,9,10,12,15,16,18,20,24,25,27,30,32,36,40,45,48,50,54,60,64,72,75,80,81,90,96,100,
801 108,120,125,128,135,144,150,160,162,180,192,200,216,225,240,243,250,256,270,288,300,320,324,360,375,384,400,405,
802 432,450,480,486,500,512,540,576,600,625,640,648,675,720,729,750,768,800,810,864,900,960,972,1000,1024,1080,1125,
803 1152,1200,1215,1250,1280,1296,1350,1440,1458,1500,1536,1600,1620,1728,1800,1875,1920,1944,2000,2025,2048,2160,
804 2187,2250,2304,2400,2430,2500,2560,2592,2700,2880,2916,3000,3072,3125,3200,3240,3375,3456,3600,3645,3750,3840,
805 3888,4000,4050,4096,4320,4374,4500,4608,4800,4860,5000};//!multiples of 2 3 and 5
806 einstellung->beginGroup("Colors");
807 chgl->fopc=einstellung->value("FourFoPlusColor", QColor("#0000FF")).value<QColor>();
808 chgl->fomc=einstellung->value("FourFoMinusColor", QColor("#FFA600")).value<QColor>();
809 chgl->dipc=einstellung->value("FourDiffPlusColor", QColor("#00B200")).value<QColor>();
810 chgl->dimc=einstellung->value("FourDiffMinusColor",QColor("#CC0000")).value<QColor>();
811 einstellung->endGroup();
812 //printf("%d\n",__LINE__);
813 killmaps();
814 //printf("%d {%s}\n",__LINE__,filename);
815 int ok;
816 if (!doMaps->isChecked()) return false;
817 if (strstr(filename,".fcf")==NULL) return false;
818 FILE *f;
819 //printf("%d\n",__LINE__);
820 ok= readHeader(filename);
821 //printf("%d\n",__LINE__);
822 if (ok) {
823 switch (ok){
824 case 1: emit bigmessage("<font color=red>Map generation failed. SHELXL LIST code was not 6.</font>");break;
825 case 2: emit bigmessage(QString("<font color=red>Map generation failed. File %1 corrupted.</font>").arg(QString::fromLocal8Bit(filename)));break;
826 case 3: emit bigmessage(QString("<font color=red>Map generation failed. Cannot open file %1.</font>").arg(QString::fromLocal8Bit(filename)));break;
827 case 4: emit bigmessage(QString("<font color=red>Map generation failed. No reflection data in file %1.</font>").arg(QString::fromLocal8Bit(filename)));break;
828 }
829 return false;
830 }
831 //printf("%d\n",__LINE__);
832 f=fopen(filename,"rb");
833 if (f==NULL)return false;
834 char line[122]="";
835 while (strstr(line,"_refln_phase_calc")==NULL) {
836 if (fgets(line,120,f)){;}//just a stupid supression for annoying warnig
837 }
838 nr=0;
839 lr[nr].ih=0;
840 lr[nr].ik=0;
841 lr[nr].il=0;
842 lr[nr].fo=f000*f000;
843 lr[nr].so=0.5f;
844 lr[nr].fc=f000;
845 lr[nr].phi=0.0f;
846 nr=1;
847 //printf("f000 %g\n",f000);
848 emit bigmessage(QString::fromLocal8Bit(filename));
849
850 while (!feof(f)){
851 if (fgets(line,120,f)){;}//just a stupid supression for annoying warnig
852 int rdi=
853 sscanf(line,"%d %d %d %f %f %f %f",&lr[nr].ih,&lr[nr].ik, &lr[nr].il ,&lr[nr].fo, &lr[nr].so, &lr[nr].fc, &lr[nr].phi);
854 if (rdi==7) {
855 if ((abs(lr[nr].ih)<HKLMX)&&
856 (abs(lr[nr].ik)<HKLMX)&&
857 (abs(lr[nr].il)<HKLMX)&&
858 ((lr[nr].ih|lr[nr].ik|lr[nr].il)!=0))
859
860 //printf("%4d%4d%4d %g %g\n", lr[nr].ih, lr[nr].ik, lr[nr].il ,lr[nr].fo, lr[nr].so);
861 nr++;
862 }
863
864 // else printf("?? %d {%s}\n",rdi,line);
865
866 if (nr>=LM) {
867 emit bigmessage(QString("<font color=red>to many reflections in fcf file</font>"));
868 return false;
869 }
870 }
871 fclose(f);
872 if (nr<2) {
873 emit bigmessage(QString("<font color=red>Map generation failed. No reflection data in file %1.</font>").arg(QString::fromLocal8Bit(filename)));
874 return false;
875 }
876
877 for (int i=0;i<nr;i++){
878 double u=lr[i].ih,v=lr[i].ik,w=lr[i].il;
879 int mh=lr[i].ih,mk=lr[i].ik,ml=lr[i].il;
880 double p,q=lr[i].phi/180.0*M_PI;
881 lr[i].phi=fmod(4*M_PI+q,2*M_PI);
882 for (int k=0; k<ns; k++){
883 int nh,nk,nl;
884 double t=1.0;
885 nh=(int) (u*sy[0][k]+ v*sy[3][k] + w*sy[6][k]);
886 nk=(int) (u*sy[1][k]+ v*sy[4][k] + w*sy[7][k]);
887 nl=(int) (u*sy[2][k]+ v*sy[5][k] + w*sy[8][k]);
888 if((nl<0)||((nl==0)&&(nk<0))||((nl==0)&&(nk==0)&&(nh<0)))
889 {nh*=-1;nk*=-1;nl*=-1;t=-1.0;}
890 if ((nl<ml)||((nl==ml)&&(nk<mk))||((nl==ml)&&(nk==mk)&&(nh<=mh))) continue;
891 mh=nh;mk=nk;ml=nl;
892 p=u*sy[9][k]+v*sy[10][k]+w*sy[11][k];
893 lr[i].phi=fmod(4*M_PI+t*fmod(q-2*M_PI*p,2*M_PI)-0.01,2*M_PI)+0.01;
894
895 }
896 lr[i].ih=mh;
897 lr[i].ik=mk;
898 lr[i].il=ml;
899 }
900 sorthkl(nr,lr);
901 int n=-1;
902 {int i=0;
903 while(i<nr){
904 double t=0.;
905 double u=0.;
906 double v=0.;
907 double z=0.;
908 double p=0.;
909 int m;
910 int k=i;
911 while ((i<nr)&&(lr[i].ih==lr[k].ih)&&(lr[i].ik==lr[k].ik)&&(lr[i].il==lr[k].il)) {
912 t=t+1.;
913 u+=lr[i].fo;
914 v+=1./(lr[i].so*lr[i].so);
915 z+=lr[i].fc;
916 p=lr[i].phi;
917 i++;
918 }
919 m=n+1;
920 lr[m].fo=sqrt(fmax(0.,u/t));
921 lr[m].so=sqrt(lr[m].fo*lr[m].fo+sqrt(1./v))-lr[m].fo;
922 lr[m].fc=z/t;
923 lr[m].phi=p;
924 n=m;
925 lr[n].ih=lr[k].ih;
926 lr[n].ik=lr[k].ik;
927 lr[n].il=lr[k].il;
928 }
929 }
930 n++;
931 nr=n;
932 // printf("%4d%4d%4d %g %g %g %g\n",lr[0].ih,lr[0].ik,lr[0].il,lr[0].fo,lr[0].so,lr[0].fc,lr[0].phi);
933 {
934 float DX;
935 float DY;
936 float DZ;
937
938
939 {
940 int mh=0, mk=0, ml=0,j;
941 for (int n=0; n<nr; n++){
942 double u=lr[n].ih,v=lr[n].ik,w=lr[n].il;
943 int a,b,c;
944 for (int k=0; k<ns;k++){
945 a=abs((int)(u*sy[0][k]+v*sy[3][k]+w*sy[6][k]));
946 b=abs((int)(u*sy[1][k]+v*sy[4][k]+w*sy[7][k]));
947 c=abs((int)(u*sy[2][k]+v*sy[5][k]+w*sy[8][k]));
948 mh=(mh<a)?a:mh;
949 mk=(mk<b)?b:mk;
950 ml=(ml<c)?c:ml;
951 }
952 }
953 j=(int)(rr*mh+.5);
954 for (int i=0; it[i]< j; i++)n1=it[i+1];
955 j=(int)(rr*mk+.5);
956 for (int i=0; it[i]< j; i++)n2=it[i+1];
957 j=(int)(rr*ml+.5);
958 for (int i=0; (it[i]< j)||((nc)&&(it[i]%2)); i++) n3=it[i+1];
959 if (!voxelstr.isEmpty()) {
960 if (voxelstr.contains('x')) {
961 QStringList lll=voxelstr.split('x');
962 if (lll.size()==3){
963 n1=lll.at(0).toInt();
964 n2=lll.at(1).toInt();
965 n3=lll.at(2).toInt();
966 //printf("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n %d %d %d \n",n1,n2,n3);
967 }
968 }
969 }
970 n4=n2*n1;
971 n5=n3*n4;
972 datfo=(float*) malloc(sizeof(float)*n5);
973 if (datfo==NULL){
974 fprintf(stderr,"Too less memory for F_observed!\n");
975 datfo=NULL;
976 mapDefault();
977 info="";
978 emit bigmessage(QString("<font color=red>Could not allocate sufficient memory for density maps. Defaults have been applied.</font> (Try to tick and un tick fcf6 by hkl)"));
979 return false;
980 }
981 datfo_fc=(float*) malloc(sizeof(float)*n5);
982 if (datfo_fc==NULL){
983 fprintf(stderr,"Too less memory for F_observed - F_calculated!\n");
984 free(datfo);
985 datfo=NULL;
986 datfo_fc=NULL;
987 mapDefault();
988 info="";
989 emit bigmessage(QString("<font color=red>Could not allocate sufficient memory for density maps. Defaults have been applied.</font> (Try to tick and un tick fcf6 by hkl)"));
990 return false;
991 }
992 DX=1.0f/n1;
993 DY=1.0f/n2;
994 DZ=1.0f/n3;
995 }
996 for (int typ=0; typ<2;typ++){
997 double miZ=99999.99,maZ=-99999.99;
998 // mInimum[typ]=99999.99; mAximum[typ]=-99999.99;
999 int nbytes,dims[3];
1000 dims[0]=n3;
1001 dims[1]=n2;
1002 dims[2]=n1;
1003 #ifdef FFTW3_H
1004 B=(fftwf_complex*)fftwf_malloc(sizeof(fftwf_complex)*n5);
1005 if (B==NULL)return false;
1006 for (int i=0; i<n5; i++){B[i][0]=0;B[i][1]=0;}
1007 #else
1008 B=(kiss_fft_cpx*)KISS_FFT_MALLOC(nbytes = (sizeof(kiss_fft_cpx)*n5));
1009 if (B==NULL){
1010 fprintf(stderr,"Too less memory for FFT map!\n");
1011 free(datfo);
1012 free(datfo_fc);
1013 datfo=NULL;
1014 datfo_fc=NULL;
1015 mapDefault();
1016 info="";
1017 emit bigmessage(QString("<font color=red>Could not allocate sufficient memory for density maps. Defaults have been applied.</font> (Try to tick and un tick fcf6 by hkl)"));
1018 return false;
1019 }
1020 for (int i=0; i<n5; i++){B[i].r=0;B[i].i=0;}
1021 #endif
1022 for (int i=0; i<nr;i++){
1023 float u,v,w;
1024 u=lr[i].ih;
1025 v=lr[i].ik;
1026 w=lr[i].il;
1027 float ss,s=0,t=0,q,p;
1028 for (int n=0; n<ns;n++){
1029 int j,k,l;
1030 j=(int) (u*sy[0][n]+ v*sy[3][n] + w*sy[6][n]);
1031 k=(int) (u*sy[1][n]+ v*sy[4][n] + w*sy[7][n]);
1032 l=(int) (u*sy[2][n]+ v*sy[5][n] + w*sy[8][n]);
1033 if((abs(j-lr[i].ih)+abs(k-lr[i].ik)+abs(l-lr[i].il))==0)s+=1.0;
1034 if(abs(j+lr[i].ih)+abs(k+lr[i].ik)+abs(l+lr[i].il)==0)t+=1.0;
1035 }
1036 if (i==0) {//printf("v%f s%f t%f\n",C[14],s,t);
1037 s=1;t=0;//f000
1038 }
1039 if(typ==0) ss=(lr[i].fo-lr[i].fc)/(C[14]*(s+t));
1040 else if(typ==2) //here this happens never
1041 ss=(lr[i].fc)/(C[14]*(s+t));
1042 else ss=(lr[i].fo)/(C[14]*(s+t));
1043 if(lr[i].fc>1.E-6) ss=ss/(1.+rw*pow(lr[i].so/lr[i].fc,4));
1044 for (int n=0; n<ns;n++){
1045 int j,k,l,m;
1046 j=(int) (u*sy[0][n]+ v*sy[3][n] + w*sy[6][n]);
1047 k=(int) (u*sy[1][n]+ v*sy[4][n] + w*sy[7][n]);
1048 l=(int) (u*sy[2][n]+ v*sy[5][n] + w*sy[8][n]);
1049 // q=(-2*M_PI*(u*sy[9][n]+v*sy[10][n]+w*sy[11][n]))-M_PI*(j*DX+k*DY+l*DZ);
1050 q=(lr[i].phi-2*M_PI*(u*sy[9][n]+v*sy[10][n]+w*sy[11][n]))-M_PI*(j*DX+k*DY+l*DZ);
1051 j=(999*n1+j)%n1;
1052 k=(999*n2+k)%n2;
1053 l=(999*n3+l)%n3;
1054 m=j+n1*(k+n2*l);
1055 p=ss*cosf(q);
1056 q=ss*sinf(q);
1057 #ifdef FFTW3_H
1058 B[m][0]=p;
1059 B[m][1]=q;
1060 #else
1061 B[m].r=p;
1062 B[m].i=q;
1063 #endif
1064 j*=-1;
1065 if(j<0)j=n1+j;
1066 k*=-1;
1067 if(k<0)k=n2+k;
1068 l*=-1;
1069 if(l<0)l=n3+l;
1070 m=j+n1*(k+n2*l);
1071 #ifdef FFTW3_H
1072 B[m][0]=p;
1073 B[m][1]=-q;
1074 #else
1075 B[m].r=p;
1076 B[m].i=-q;
1077 #endif
1078 }
1079 }
1080 #ifdef FFTW3_H
1081 fwd_plan = fftwf_plan_dft_3d(n3,n2,n1,B,B,FFTW_FORWARD,FFTW_ESTIMATE);
1082 fftwf_execute(fwd_plan);
1083 fftwf_destroy_plan(fwd_plan);
1084 #else
1085 fwd_plan = kiss_fftnd_alloc(dims,3,0,0,0);
1086 kiss_fftnd( fwd_plan,B,B);
1087 free(fwd_plan);
1088 #endif
1089 float t=0;
1090 double DM=0., DS=0., DD ;
1091 for (int i=0; i<n5;i++){
1092 #ifdef FFTW3_H
1093 DD=B[i][0];
1094 #else
1095 DD=B[i].r;
1096 #endif
1097 // maxi[typ]=fmax(maxi[typ],DD); mini[typ]=fmin(mini[typ],DD);
1098 miZ=fmin(miZ,DD);
1099 maZ=fmax(maZ,DD);
1100 DM+=DD;
1101 DS+=DD*DD;
1102 #ifdef FFTW3_H
1103 if (typ==1) datfo[i]=B[i][0];
1104 else if (typ==0) datfo_fc[i]=B[i][0];
1105 #else
1106 if (typ==1) datfo[i]=B[i].r;
1107 else if (typ==0) datfo_fc[i]=B[i].r;
1108
1109 #endif
1110 }
1111 sigma[typ]=t=sqrt((DS/n5)-((DM/n5)*(DM/n5)));
1112 free(B);
1113 }//1
1114 }//2
1115 urs=V3(0,0,0);int gt=0;
1116 for (int i=0; i<mole->showatoms.size();i++)
1117 if (mole->showatoms.at(i).an>-1) {urs+=mole->showatoms.at(i).frac;gt++;}
1118 urs*=1.0/gt;
1119 urs=V3(1,1,1)-1.0*urs;
1120 mole->frac2kart(urs,urs);
1121
1122 nodex= (FNode*)malloc(sizeof(FNode)*n5);
1123 if (nodex==NULL){
1124 fprintf(stderr,"Too less memory for node X!\n");
1125 free(datfo);
1126 free(datfo_fc);
1127 datfo=NULL;
1128 datfo_fc=NULL;
1129 mapDefault();
1130 info="";
1131 emit bigmessage(QString("<font color=red>Could not allocate sufficient memory for density maps. Defaults have been applied.</font> (Try to tick and un tick fcf6 by hkl)"));
1132 return false;
1133 }
1134 nodey= (FNode*)malloc(sizeof(FNode)*n5);
1135 if (nodey==NULL){
1136 fprintf(stderr,"Too less memory for node Y!\n");
1137 free(nodex);
1138 free(datfo);
1139 free(datfo_fc);
1140 nodex = NULL;
1141 datfo = NULL;
1142 datfo_fc = NULL;
1143 mapDefault();
1144 info="";
1145 emit bigmessage(QString("<font color=red>Could not allocate sufficient memory for density maps. Defaults have been applied.</font> (Try to tick and un tick fcf6 by hkl)"));
1146 return false;
1147 }
1148 nodez= (FNode*)malloc(sizeof(FNode)*n5);
1149 if (nodez==NULL){
1150 fprintf(stderr,"Too less memory for node Z!\n");
1151 free(nodex);
1152 free(nodey);
1153 free(datfo);
1154 free(datfo_fc);
1155 nodex = NULL;
1156 nodey = NULL;
1157 datfo = NULL;
1158 datfo_fc = NULL;
1159 mapDefault();
1160 info="";
1161 emit bigmessage(QString("<font color=red>Could not allocate sufficient memory for density maps. Defaults have been applied.</font> (Try to tick and un tick fcf6 by hkl)"));
1162 return false;
1163 }
1164 noGoMap= (int*) malloc(sizeof(int)*n5*27);
1165 if (noGoMap==NULL){
1166 fprintf(stderr,"Too less memory for noGoMap!\n");
1167
1168 free(nodex);
1169 free(nodey);
1170 free(nodez);
1171 free(datfo);
1172 free(datfo_fc);
1173 nodex= NULL;
1174 nodey= NULL;
1175 nodez= NULL;
1176 datfo= NULL;
1177 datfo_fc= NULL;
1178 mapDefault();
1179 info="";
1180 emit bigmessage(QString("<font color=red>Could not allocate sufficient memory for density maps. Defaults have been applied.</font> (Try to tick and un tick fcf6 by hkl)"));
1181 return false;
1182 }
1183 for (int no=0;no<(n5*27);no++) noGoMap[no]=0;
1184 for (int o=0; o<n5;o++){
1185 nodex[o].flag=0;
1186 nodey[o].flag=0;
1187 nodez[o].flag=0;
1188 }
1189 dx=V3(1.0/(n1),0,0);
1190 dy=V3(0,1.0/(n2),0);
1191 dz=V3(0,0,1.0/(n3));
1192 mole->frac2kart(dx,dx);
1193 mole->frac2kart(dy,dy);
1194 mole->frac2kart(dz,dz);
1195 delDA[ 0]= -n1*dx -n2*dy -n3*dz;//nx ny,nz??
1196 delDA[ 1]= -n2*dy -n3*dz;
1197 delDA[ 2]= n1*dx -n2*dy -n3*dz;
1198 delDA[ 3]= -n1*dx -n3*dz;
1199 delDA[ 4]= -n3*dz;
1200 delDA[ 5]= n1*dx -n3*dz;
1201 delDA[ 6]= -n1*dx +n2*dy -n3*dz;
1202 delDA[ 7]= n2*dy -n3*dz;
1203 delDA[ 8]= n1*dx +n2*dy -n3*dz;
1204 delDA[ 9]= -n1*dx -n2*dy ;
1205 delDA[10]= -n2*dy ;
1206 delDA[11]= n1*dx -n2*dy ;
1207 delDA[12]= -n1*dx ;
1208 delDA[13]= V3(0,0,0) ;
1209 delDA[14]= n1*dx ;
1210 delDA[15]= -n1*dx +n2*dy ;
1211 delDA[16]= n2*dy ;
1212 delDA[17]= n1*dx +n2*dy ;
1213 delDA[18]= -n1*dx -n2*dy +n3*dz;
1214 delDA[19]= -n2*dy +n3*dz;
1215 delDA[20]= n1*dx -n2*dy +n3*dz;
1216 delDA[21]= -n1*dx +n3*dz;
1217 delDA[22]= +n3*dz;
1218 delDA[23]= n1*dx +n3*dz;
1219 delDA[24]= -n1*dx +n2*dy +n3*dz;
1220 delDA[25]= n2*dy +n3*dz;
1221 delDA[26]= n1*dx +n2*dy +n3*dz;
1222 emit bigmessage(QString("Uniq Reflections: %1 <br>Fourier grid dimensions: %2 %3 %4 = %5 grid points.<br>Time for loading and fourier transformation: <b>%6 s</b>.<br>").arg(nr).arg(n1).arg(n2).arg(n3).arg(n5).arg(foti.elapsed()/1000.0,1,'f',1));
1223 if (neu) gen_surface(neu);
1224 return true;
1225 }
1226
1227 bool FourXle::loadMap(int NX, int NY, int NZ, float *dat){
1228 bool wbi=isBelo;
1229 //printf("%d\n",__LINE__);
1230 killmaps();
1231 //printf("%d\n",__LINE__);
1232 isBelo=wbi;
1233
1234 n1=NX;
1235 n2=NY;
1236 n3=NZ;
1237 n4=n2*n1;
1238 n5=n3*n4;
1239 datfo=(float*) malloc(sizeof(float)*n5);
1240 if (datfo==NULL){
1241 fprintf(stderr,"Too less memory for F_observed - F_calculated!\n");
1242 free(datfo_fc);
1243 mapDefault();
1244 info="";
1245 emit bigmessage(QString("<font color=red>Could not allocate sufficient memory for density maps. Defaults have been applied.</font> (Try to tick and un tick fcf6 by hkl)"));
1246 return false;
1247 }
1248 for (int i=0; i<n5; i++)datfo[i]=0.0f;
1249 datfo_fc=dat;
1250
1251 sigma[0] = sigmaFoFc();
1252 sigma[1] = sigmaFo();
1253 iso[1]= sigma[0] * 2.5f;
1254 iso[0]= sigma[1] * 1.2f;
1255 fomaps->setValue(iso[0]);
1256 difmaps->setValue(iso[1]);
1257
1258 urs=V3(0,0,0);int gt=0;
1259 for (int i=0; i<mole->showatoms.size();i++)
1260 if (mole->showatoms.at(i).an>-1) {urs+=mole->showatoms.at(i).frac;gt++;}
1261 urs*=1.0/gt;
1262 urs=V3(1,1,1)-1.0*urs;
1263 mole->frac2kart(urs,urs);
1264 nodex= (FNode*)malloc(sizeof(FNode)*n5);
1265 if (nodex==NULL){
1266 fprintf(stderr,"Too less memory for node X!\n");
1267 free(datfo);
1268 free(datfo_fc);
1269 mapDefault();
1270 info="";
1271 emit bigmessage(QString("<font color=red>Could not allocate sufficient memory for density maps. Defaults have been applied.</font> (Try to tick and un tick fcf6 by hkl)"));
1272 return false;
1273 }
1274 nodey= (FNode*)malloc(sizeof(FNode)*n5);
1275 if (nodey==NULL){
1276 fprintf(stderr,"Too less memory for node Y!\n");
1277 free(datfo);
1278 free(datfo_fc);
1279 free(nodex);
1280 mapDefault();
1281 info="";
1282 emit bigmessage(QString("<font color=red>Could not allocate sufficient memory for density maps. Defaults have been applied.</font> (Try to tick and un tick fcf6 by hkl)"));
1283 return false;
1284 }
1285 nodez= (FNode*)malloc(sizeof(FNode)*n5);
1286 if (nodez==NULL){
1287 fprintf(stderr,"Too less memory for node Z!\n");
1288 free(datfo);
1289 free(datfo_fc);
1290 free(nodex);
1291 free(nodey);
1292 mapDefault();
1293 info="";
1294 emit bigmessage(QString("<font color=red>Could not allocate sufficient memory for density maps. Defaults have been applied.</font> (Try to tick and un tick fcf6 by hkl)"));
1295 return false;
1296 }
1297 noGoMap= (int*) malloc(sizeof(int)*n5*27);
1298 if (noGoMap==NULL){
1299 fprintf(stderr,"Too less memory for noGoMap!\n");
1300 free(datfo);
1301 free(datfo_fc);
1302 free(nodex);
1303 free(nodey);
1304 free(nodez);
1305 mapDefault();
1306 info="";
1307 emit bigmessage(QString("<font color=red>Could not allocate sufficient memory for density maps. Defaults have been applied.</font> (Try to tick and un tick fcf6 by hkl)"));
1308 return false;
1309 }
1310 for (int no=0;no<(n5*27);no++) noGoMap[no]=0;
1311 for (int o=0; o<n5;o++){
1312 nodex[o].flag=0;
1313 nodey[o].flag=0;
1314 nodez[o].flag=0;
1315 }
1316 dx = V3(1.0 / (n1), 0, 0);
1317 dy = V3(0, 1.0 / (n2), 0);
1318 dz = V3(0, 0, 1.0 / (n3));
1319 mole->frac2kart(dx,dx);
1320 mole->frac2kart(dy,dy);
1321 mole->frac2kart(dz,dz);
1322 delDA[ 0]= -n1*dx -n2*dy -n3*dz;//nx ny,nz??
1323 delDA[ 1]= -n2*dy -n3*dz;
1324 delDA[ 2]= n1*dx -n2*dy -n3*dz;
1325 delDA[ 3]= -n1*dx -n3*dz;
1326 delDA[ 4]= -n3*dz;
1327 delDA[ 5]= n1*dx -n3*dz;
1328 delDA[ 6]= -n1*dx +n2*dy -n3*dz;
1329 delDA[ 7]= n2*dy -n3*dz;
1330 delDA[ 8]= n1*dx +n2*dy -n3*dz;
1331 delDA[ 9]= -n1*dx -n2*dy ;
1332 delDA[10]= -n2*dy ;
1333 delDA[11]= n1*dx -n2*dy ;
1334 delDA[12]= -n1*dx ;
1335 delDA[13]= V3(0,0,0) ;
1336 delDA[14]= n1*dx ;
1337 delDA[15]= -n1*dx +n2*dy ;
1338 delDA[16]= n2*dy ;
1339 delDA[17]= n1*dx +n2*dy ;
1340 delDA[18]= -n1*dx -n2*dy +n3*dz;
1341 delDA[19]= -n2*dy +n3*dz;
1342 delDA[20]= n1*dx -n2*dy +n3*dz;
1343 delDA[21]= -n1*dx +n3*dz;
1344 delDA[22]= +n3*dz;
1345 delDA[23]= n1*dx +n3*dz;
1346 delDA[24]= -n1*dx +n2*dy +n3*dz;
1347 delDA[25]= n2*dy +n3*dz;
1348 delDA[26]= n1*dx +n2*dy +n3*dz;
1349 rr = mapprec->value();
1350 rw = weak->value();
1351 //gen_surface_silent();
1352 return true;
1353
1354 }
1355
1356
1357 void FourXle::trimm(char s[]){
1358 /*! a trimm function for c-strings.
1359 */
1360 char sc[409];
1361 int j=0;
1362 size_t len=strlen(s);
1363 strncpy(sc,s,400);
1364 for (size_t i=0; i<len; i++) if ((sc[i]!='\'')&&(!isspace(sc[i]))) s[j++]=static_cast<char>(toupper(sc[i]));
1365 s[j]='\0';
1366 }
1367
1368 void FourXle::deletes(char *s, int count){
1369 /*! deletes count characters at the begining of s.
1370 */
1371 if ((s==NULL)||(count <1)||(static_cast<size_t>(count)>strlen(s))) return;
1372 for (int i=0; i<count; i++) s[i]=' ';
1373 trimm(s);
1374 }
1375
1376 void FourXle::exportMaps(int na, const char filename[], const char atomlist[]){
1377 if ((datfo==NULL)||(datfo_fc==NULL)) return;
1378 FILE *fo,*fof1;//,*f1f2;
1379 char foname[4096];
1380 char fof1name[4096];
1381 // char f1f2name[4096];
1382 size_t len=strlen(filename);
1383 float factor=0.1481847095290449f;//a0**3
1384 double a0=0.52917720859; //bohr=0.5291775108
1385 int i=0;
1386 //
1387 //FO MAP
1388 //
1389 V3 dx1=V3(1.0/(n1),0,0);
1390 V3 dy1=V3(0,1.0/(n2),0);
1391 V3 dz1=V3(0,0,1.0/(n3));
1392 mole->frac2kart(dx1,dx1);
1393 mole->frac2kart(dy1,dy1);
1394 mole->frac2kart(dz1,dz1);
1395
1396 strncpy(foname,filename,len-4);
1397 foname[len-4]='\0';
1398 strcat(foname,"_fo_densitymap.cube");
1399 fo=fopen(foname,"w");
1400 if (fo==NULL) return ;
1401 double fomax=-9e37,fomin=9e37,em=0,ep=0,et=0;
1402 for (int i=0; i<n5; i++ ){
1403 if (datfo[i]>0.0f) ep+=static_cast<double>(datfo[i]);
1404 else em+=static_cast<double>(datfo[i]);
1405 et+=static_cast<double>(datfo[i]);
1406 fomax=fmax(static_cast<double>(datfo[i]),fomax);
1407 fomin=fmin(static_cast<double>(datfo[i]),fomin);
1408 }
1409 //printf("Fo %g %g %g %g %g\n",fomin,fomax,ep/n5*C[14],em/n5*C[14],et/n5*C[14] );
1410 fprintf(fo,"F observed map written by ShelXle\nDensity obtained from Fo in fcf with phases of model transformed using fft\n");
1411 fprintf(fo,"%5d%12.6f%12.6f%12.6f\n",na,
1412 (dx1.x+dy1.x+dz1.x)*0.5/a0,
1413 (dx1.y+dy1.y+dz1.y)*0.5/a0,
1414 (dx1.z+dy1.z+dz1.z)*0.5/a0
1415 //0.0,0.0,0.0
1416 );
1417 fprintf(fo,"%5d%12.6f%12.6f%12.6f\n",n1,dx1.x/a0,dx1.y/a0,dx1.z/a0);
1418 fprintf(fo,"%5d%12.6f%12.6f%12.6f\n",n2,dy1.x/a0,dy1.y/a0,dy1.z/a0);
1419 fprintf(fo,"%5d%12.6f%12.6f%12.6f" ,n3,dz1.x/a0,dz1.y/a0,dz1.z/a0);//no newline here because it is in atomlist
1420 fprintf(fo,"%s",atomlist);
1421 for (int xi=0;xi<n1;xi++)
1422 for (int yi=0;yi<n2;yi++)
1423 for (int zi=0;zi<n3;zi++)
1424 {
1425 //fprintf(fo,"%s%13.5E",(((i%6)==0)?"\n":""),datfo[dex(xi,yi,zi)]*factor);
1426 fprintf(fo,"%s",QString("%1%2").arg(((i%6)==0)?"\n":"").arg(static_cast<double>(datfo[dex(xi,yi,zi)]*factor),13,'E',5).toStdString().c_str());
1427 i++;
1428 }
1429 fclose(fo);
1430 //
1431 //FO-F1 MAP
1432 //
1433
1434 strncpy(fof1name,filename,len-4);
1435 fof1name[len-4]='\0';
1436 strcat(fof1name,"_fo-fc_densitymap.cube");
1437 fof1=fopen(fof1name,"w");
1438 if (fof1==NULL) return ;
1439 fomax=-9e37;
1440 fomin= 9e37;
1441 em=0;
1442 ep=0;
1443 et=0;
1444 for (int i=0; i<n5; i++ ){
1445 if (datfo_fc[i]>0.0f) ep+=static_cast<double>(datfo_fc[i]);
1446 else em+=static_cast<double>(datfo_fc[i]);
1447 et+=static_cast<double>(datfo_fc[i]);
1448 fomax=fmax(static_cast<double>(datfo_fc[i]),fomax);
1449 fomin=fmin(static_cast<double>(datfo_fc[i]),fomin);
1450 }
1451 printf("Fo-Fc %g %g %g %g %g\n",fomin,fomax,ep/n5*C[14],em/n5*C[14],et/n5*C[14] );
1452 fprintf(fof1,"F obs-fc map written by ShelXle\nDifferene density Fo-fc in fcf file transformed using fft\n");
1453 fprintf(fof1,"%5d%12.6f%12.6f%12.6f\n",na,
1454 (dx1.x+dy1.x+dz1.x)*0.5/a0,
1455 (dx1.y+dy1.y+dz1.y)*0.5/a0,
1456 (dx1.z+dy1.z+dz1.z)*0.5/a0
1457 //0.0,0.0,(dx.z+dy.z+dz.z)/a0
1458 );
1459 fprintf(fof1,"%5d%12.6f%12.6f%12.6f\n",n1,dx1.x/a0,dx1.y/a0,dx1.z/a0);
1460 fprintf(fof1,"%5d%12.6f%12.6f%12.6f\n",n2,dy1.x/a0,dy1.y/a0,dy1.z/a0);
1461 fprintf(fof1,"%5d%12.6f%12.6f%12.6f" ,n3,dz1.x/a0,dz1.y/a0,dz1.z/a0);//no newline here because it is in atomlist
1462 fprintf(fof1,"%s",atomlist);
1463 for (int xi=0;xi<n1;xi++)
1464 for (int yi=0;yi<n2;yi++)
1465 for (int zi=0;zi<n3;zi++)
1466 {
1467 //fprintf(fof1,"%s%13.5E",(((i%6)==0)?"\n":""),datfo_fc[dex(xi,yi,zi)]*factor);
1468 fprintf(fof1,"%s",QString("%1%2").arg(((i%6)==0)?"\n":"").arg(static_cast<double>(datfo_fc[dex(xi,yi,zi)]*factor),13,'E',5).toStdString().c_str());
1469 i++;
1470 }
1471 fclose(fof1);
1472 }
1473 // */
1474 //}
1475
1476 int FourXle::readHeader(const char *filename){
1477 /*! reads the header of an fcf file
1478 */
1479 FILE *f=NULL;
1480 char line[122],*dum=NULL;
1481 //size_t zlen=120;
1482 int ok=0;
1483 int i;double T,V;
1484 f=fopen(filename,"r");
1485 //printf("%d\n",__LINE__);
1486 if (f==NULL) return 3;
1487 //printf("%d\n",__LINE__);
1488 ns=0;
1489 sy[0][ns]=1.0;
1490 sy[1][ns]=0.0;
1491 sy[2][ns]=0.0;
1492
1493 sy[3][ns]=0.0;
1494 sy[4][ns]=1.0;
1495 sy[5][ns]=0.0;
1496
1497 sy[6][ns]=0.0;
1498 sy[7][ns]=0.0;
1499 sy[8][ns]=1.0;
1500
1501 sy[9][ns]=0.0;
1502 sy[10][ns]=0.0;
1503 sy[11][ns]=0.0;
1504 ns=1;
1505 int listcode=0;
1506 do{
1507 dum=fgets(line,120,f);
1508 //printf("%d\n",__LINE__);
1509 if (dum==NULL){fclose(f);return 2;};
1510 if (feof(f)){fclose(f);return 2;};
1511 while (dum[0]==' ') dum++;
1512 if (!strncmp(dum,"_shelx_title",12)) {
1513 sscanf(line,"_shelx_title %[^\r\n]",titl);
1514 trimm(titl);
1515 }
1516 if (!strncmp(dum,"_exptl_crystal_F_000",20)){
1517 sscanf(line,"_exptl_crystal_F_000 %f",&f000);
1518 if (overridef000!=-1.0) f000=overridef000;
1519 //printf("F000 = %g %g %d %s\n",f000,overridef000,(overridef000!=-1.0f),line);
1520 }
1521 if (!strncmp(dum,"_shelx_refln_list_code",22)) {
1522 sscanf(line,"_shelx_refln_list_code %d",&listcode);
1523 //qDebug()<<listcode;
1524 if (listcode!=6) {fclose(f);return 1;}
1525 }
1526 if (!strncmp(dum,"_cell_length_a",14)) {
1527 sscanf(line,"_cell_length_a %lf",&C[0]);
1528 }
1529 if (!strncmp(dum,"_cell_length_b",14)) {
1530 sscanf(line,"_cell_length_b %lf",&C[1]);
1531 }
1532 if (!strncmp(dum,"_cell_length_c",14)) {
1533 sscanf(line,"_cell_length_c %lf",&C[2]);
1534 }
1535 if (!strncmp(dum,"_cell_angle_alpha",17)) {
1536 sscanf(line,"_cell_angle_alpha %lf",&C[3]);
1537 }
1538 if (!strncmp(dum,"_cell_angle_beta",16)) {
1539 sscanf(line,"_cell_angle_beta %lf",&C[4]);
1540 }
1541 if (!strncmp(dum,"_cell_angle_gamma",17)) {
1542 sscanf(line,"_cell_angle_gamma %lf",&C[5]);
1543 for (i=0;i<3;i++){
1544 if (C[i]<0.1) return 2;
1545 T=.0174533*C[i+3];
1546 if (T<0.001) return 2;
1547 D[i]=sin(T);
1548 D[i+3]=cos(T);
1549 C[i+6]=(D[i]/(C[i]*C[i]));
1550 }
1551 V=1.-D[3]*D[3]-D[4]*D[4]-D[5]*D[5]+2.*D[3]*D[4]*D[5];
1552 C[6]/=V;
1553 C[7]/=V;
1554 C[8]/=V;
1555 C[9]= 2.*sqrt(C[7]*C[8])*(D[4]*D[5]-D[3])/(D[2]*D[2]);
1556 C[10]=2.*sqrt(C[6]*C[8])*(D[3]*D[5]-D[4])/(D[0]*D[2]);
1557 C[11]=2.*sqrt(C[6]*C[7])*(D[3]*D[4]-D[5])/(D[0]*D[1]);
1558 C[14]=C[1]*C[2]*C[0]*sqrt(V);
1559 D[6]=C[1]*C[2]*D[0]/C[14];
1560 D[7]=C[0]*C[2]*D[1]/C[14];
1561 D[8]=C[0]*C[1]*D[2]/C[14];
1562 }
1563 if ((!strncmp(dum,"_symmetry_equiv_pos_as_xyz",26))||(!strncmp(dum,"_space_group_symop_operation_xyz",32))){
1564 // char s1[50],s2[50],s3[50];
1565 // char *kill=NULL,*nom=NULL,*div=NULL ;
1566 dum=fgets(line,120,f);
1567 trimm(line);
1568 while (strchr(line,'Y')) {
1569 QString sc=QString(line).toUpper().remove("SYMM").trimmed();
1570 sc=sc.remove("'");
1571 sc=sc.remove(" ");
1572 QStringList axe=sc.split(",");
1573 QStringList bruch;
1574 if (axe.size()!=3) return false;
1575 double _sx[3],_sy[3],_sz[3],t[3];
1576 for (int i=0; i<3; i++){
1577 _sx[i]=0;_sy[i]=0;_sz[i]=0;t[i]=0;
1578 if (axe.at(i).contains("-X")) {_sx[i]=-1.0;axe[i].remove("-X");}
1579 else if (axe.at(i).contains("X")) {_sx[i]=1.0;axe[i].remove("X");}
1580 if (axe.at(i).contains("-Y")) {_sy[i]=-1.0;axe[i].remove("-Y");}
1581 else if (axe.at(i).contains("Y")) {_sy[i]=1.0;axe[i].remove("Y");}
1582 if (axe.at(i).contains("-Z")) {_sz[i]=-1.0;axe[i].remove("-Z");}
1583 else if (axe.at(i).contains("Z")) {_sz[i]=1.0;axe[i].remove("Z");}
1584 if (axe.at(i).endsWith("+")) axe[i].remove("+");
1585 if (axe.at(i).contains("/")) {
1586 bruch=axe.at(i).split("/");
1587 if (bruch.size()==2) t[i]=bruch.at(0).toDouble() / bruch.at(1).toDouble();
1588 }
1589 else if (!axe.at(i).isEmpty()) t[i]=axe.at(i).toDouble();
1590 }
1591 sy[0][ns]=_sx[0];
1592 sy[1][ns]=_sy[0];
1593 sy[2][ns]=_sz[0];
1594
1595 sy[3][ns]=_sx[1];
1596 sy[4][ns]=_sy[1];
1597 sy[5][ns]=_sz[1];
1598
1599 sy[6][ns]=_sx[2];
1600 sy[7][ns]=_sy[2];
1601 sy[8][ns]=_sz[2];
1602
1603
1604 sy[9][ns]=t[0];
1605 sy[10][ns]=t[1];
1606 sy[11][ns]=t[2];
1607
1608
1609 strcpy(line,"");
1610 dum=fgets(line,120,f);
1611 trimm(line);
1612 ns++;
1613
1614 }
1615 }
1616 if (!strncmp(dum,"_refln_phase_calc",17)) ok=1;
1617 }while((!ok)&&(!feof(f)));
1618
1619 if (listcode!=6) return 1;
1620 for (int i=0; i<ns;i++){
1621 for (int n=i+1; n<ns;n++){
1622 int u=0,v=0;
1623 for (int j=0; j<9; j++){
1624 u+=abs(sy[j][n]-sy[j][i]);
1625 v+=abs(sy[j][n]+sy[j][i]);
1626 }
1627 if (fmin(u,v)>0.01) continue;
1628 for (int j=0; j<12; j++){
1629 sy[j][n]=sy[j][ns-1];
1630 }
1631 ns--;
1632 }
1633 }
1634 fclose(f);
1635
1636 return 0;
1637 }
1638
1639 void FourXle::sorthkl(int nr, Rec r[]){
1640 /*! sorts the reflection list
1641 */
1642 Rec *hilf= (Rec*) malloc(sizeof(Rec)*nr);
1643 if (hilf==NULL)return ;
1644 int i,j,k,nj,ni,spalte;int index[4096];
1645 for (spalte=0; spalte<3; spalte++){
1646 j=-999999;
1647 k=999999;
1648 switch (spalte) {
1649 case 0: for (i=0; i<nr; i++){ j=(j<r[i].ih)?r[i].ih:j; k=(k>r[i].ih)?r[i].ih:k; } break;
1650 case 1: for (i=0; i<nr; i++){ j=(j<r[i].ik)?r[i].ik:j; k=(k>r[i].ik)?r[i].ik:k; } break;
1651 case 2: for (i=0; i<nr; i++){ j=(j<r[i].il)?r[i].il:j; k=(k>r[i].il)?r[i].il:k; } break;
1652 }
1653 nj=-k;
1654 ni=(nj+j+1);
1655 for (i=0; i<=ni; i++) index[i]=0;
1656 for (i=0; i<nr; i++){
1657 switch (spalte){
1658 case 0: j=r[i].ih+nj; break;
1659 case 1: j=r[i].ik+nj; break;
1660 case 2: j=r[i].il+nj; break;
1661 }
1662 index[j]++;/*brauch ich das? -->JA!*/
1663 hilf[i].ih=r[i].ih;
1664 hilf[i].ik=r[i].ik;
1665 hilf[i].il=r[i].il;
1666 hilf[i].fo=r[i].fo;
1667 hilf[i].so=r[i].so;
1668 hilf[i].fc=r[i].fc;
1669 hilf[i].phi=r[i].phi;
1670 }/*/4*/
1671 j=0;
1672 for (i=0; i<ni; i++){
1673 k=j;
1674 j+=index[i];
1675 index[i]=k;
1676 }/*/5*/
1677 for (i=0; i<nr;i++){
1678 switch (spalte) {
1679 case 0: j=hilf[i].ih +nj;break;
1680 case 1: j=hilf[i].ik +nj;break;
1681 case 2: j=hilf[i].il +nj;break;
1682 }
1683 index[j]++;
1684 j=index[j]-1;
1685 r[j].ih=hilf[i].ih;
1686 r[j].ik=hilf[i].ik;
1687 r[j].il=hilf[i].il;
1688 r[j].fo=hilf[i].fo;
1689 r[j].so=hilf[i].so;
1690 r[j].fc=hilf[i].fc;
1691 r[j].phi=hilf[i].phi;
1692 }/*/6*/
1693 }/*/spalten*/
1694 free(hilf);
1695 }
1696
1697 void FourXle::bewegt(V3 nm){/*!moves the rotation center to nm*/
1698 // printf("moved\n");
1699 V3 v , alturs=urs;
1700 mole->kart2frac(nm,v);
1701 urs=V3(1,1,1)-1.0*v;
1702 mole->frac2kart(urs,urs);
1703 //if ((chgl->objCnt==acnt)&&(maptrunc==2)) return;
1704 if (urs==alturs) return;
1705 gen_surface(false);
1706 // chgl->pause=false;
1707 chgl->update();
1708 }
1709
1710 void FourXle::inimap(){/*! reinitializes the display lists for screenshots*/
1711 gen_surface(false);
1712
1713 }
1714
1715 void FourXle::gen_surface(bool neu,int imin,int imax){
1716 GenMapWorker *w = new GenMapWorker(chgl, mole, this, neu, imin, imax);
1717 // chgl->habzutun=true;
1718 //connect(this,SIGNAL(haltMW()),w,SLOT(terminate()));
1719 connect(w, SIGNAL(finished()),this, SLOT(reportInfo()));
1720 connect(w, SIGNAL(finished()), chgl, SLOT(update()));
1721 connect(w, SIGNAL(finished()), w, SLOT(deleteLater()));
1722 connect(w, SIGNAL(finished()),chgl, SLOT(fertig()));
1723 connect(w, SIGNAL(finished()),chgl, SLOT(rebuf()));//fer(QVector< QVector< float > > &, QVector< QVector< float > > &)));
1724 w->start();
1725 }
1726 //GenMapWorker
1727
1728
1729
1730 void GenMapWorker::gen_surface(bool neu,int imin,int imax){
1731 if (fxle->noGoMap==NULL) return;
1732 /*! creates iso surfaces for fo-fc- fo-fc+ fo+ and fo- maps if neu then the iso values are calculated fro the sigma value of the map.
1733 *
1734 */
1735 if (!chgl->neutrons) imax=qMin(3,imax);
1736 V3 v=V3(0,0,0);
1737 mole->kart2frac(chgl->altemitte,v);
1738 fxle->urs=V3(1,1,1)-1.0*v;
1739 mole->frac2kart(fxle->urs,fxle->urs);
1740 //chgl->pause=true;
1741 chgl->fVertexes.resize(28);
1742 chgl->fNormals.resize(28);
1743 fxle->suti.start();
1744 fxle->disconnect(chgl,SIGNAL(diffscroll(int ,int )),0,0);
1745 fxle->disconnect(chgl,SIGNAL(neuemitte(V3)),0,0);
1746 fxle->disconnect(chgl,SIGNAL(inimibas()),0,0);
1747 // if ((neu)||(mole->showatoms.size()!=oldatomsize)||(chgl->unhide->isVisible())){
1748 for (int no=0;no<(fxle->n5*27);no++) fxle->noGoMap[no]=0;
1749 mole->kart2frac(fxle->dx,fxle->dxc);
1750 mole->kart2frac(fxle->dy,fxle->dyc);
1751 mole->kart2frac(fxle->dz,fxle->dzc);
1752 int incx = (int) (fxle->cutrange->value()/fxle->dx.x);
1753 int incy = (int) (fxle->cutrange->value()/fxle->dy.y);
1754 int incz = (int) (fxle->cutrange->value()/fxle->dz.z);
1755 int incmin=qMin(incx,qMin(incy,incz));
1756 incmin*=incmin;
1757 for (int g=0; g<mole->showatoms.size();g++){
1758 if (mole->showatoms.at(g).hidden) continue;
1759 mole->kart2frac(mole->showatoms.at(g).pos,fxle->oc);
1760 int ax=(int)((fxle->oc.x)/fxle->dxc.x-0.499), bx=(int)((fxle->oc.y)/fxle->dyc.y-0.499), cx=(int)((fxle->oc.z)/fxle->dzc.z-0.499);
1761 for (int aa=ax-incx; aa<ax+incx; aa++){
1762 for (int bb=bx-incy; bb<bx+incy; bb++){
1763 for (int cc=cx-incz; cc<cx+incz; cc++){
1764 if (incmin<((aa-ax)*(aa-ax)+(bb-bx)*(bb-bx)+(cc-cx)*(cc-cx))) continue;
1765 int dEx=fxle->dex3(aa,bb,cc);
1766 if ((dEx>0)&&(dEx<(27*fxle->n5-1)))
1767 fxle->noGoMap[dEx]=1;
1768 }
1769 }
1770 }
1771 }
1772 // oldatomsize=mole->showatoms.size();
1773 // }
1774 fxle->tri=0;
1775 float FXO=0.1f, FXD=0.01f;
1776 QString fxvaluesfile = fxle->resDir.absolutePath()+"_fourxle.fixv";
1777 // qDebug()<<fxvaluesfile ;
1778 if (fxle->keepIso->isChecked()){
1779 if (QFile::exists(fxvaluesfile)){
1780 QFile fxfi(fxvaluesfile);
1781 fxfi.open(QIODevice::ReadOnly|QIODevice::Text);
1782 QStringList lll = QString(fxfi.readAll()).split(' ');
1783 if (lll.size()==2){
1784 FXO=lll.at(0).toFloat();
1785 FXD=lll.at(1).toFloat();
1786 }
1787 fxfi.close();
1788 }else{
1789 QFile fxfi(fxvaluesfile);
1790 fxfi.open(QIODevice::WriteOnly|QIODevice::Text);
1791 FXO = fxle->sigma[1];
1792 FXD = fxle->sigma[0];
1793 fxfi.write(QString("%1 %2").arg(FXO,0,'g').arg(FXD,0,'g').toLocal8Bit());
1794 fxfi.close();
1795 }
1796 }else{
1797 QFile::remove(fxvaluesfile);
1798 }
1799 printf("sigma0 %f sigma1 %f \n",fxle->sigma[0]*2.7f,fxle->sigma[1]*1.2f);
1800 for (int fac=imin; fac<imax; fac++){
1801 switch (fac){
1802 case 0:
1803 if (neu) fxle->iso[1]=(fxle->keepIso->isChecked())?FXD*2.7f:fxle->sigma[0]*2.7f;
1804 else fxle->iso[1]=fabs(fxle->iso[1]);
1805 fxle->mtyp=1;
1806 break;
1807 case 1:
1808 if (neu) fxle->iso[1]=(fxle->keepIso->isChecked())?-FXD*2.7f:-fxle->sigma[0]*2.7f;
1809 else fxle->iso[1]=-fabs(fxle->iso[1]);
1810 fxle->mtyp=1;
1811 break;
1812 case 2:
1813 if (neu) fxle->iso[0]=(fxle->keepIso->isChecked())?FXO*1.2f:fxle->sigma[1]*1.2f;
1814 // printf("blau %g %d\n",fxle->iso[0],neu);
1815 fxle->mtyp=0;
1816 break;
1817 case 3:
1818 if (neu) fxle->iso[0]=(fxle->keepIso->isChecked())?-FXO*1.2f:-fxle->sigma[1]*1.2f;
1819 else fxle->iso[0]=-fabs(fxle->iso[0]);
1820 // printf("orange %g %d\n",fxle->iso[0],neu);
1821 fxle->mtyp=0;
1822 break;
1823 }
1824 {
1825 int ix,iy,iz;
1826 for (iz=0; iz<fxle->n3;iz++){
1827 for (iy=0; iy<fxle->n2;iy++){
1828 for (ix=0; ix<fxle->n1;ix++){
1829 fxle->CalcVertex(ix,iy,iz);
1830 }
1831 }
1832 }
1833 }
1834
1835 int mper=(chgl->niceTrans->isChecked())?6:1;
1836 for (int pers=0;pers<mper;pers++){
1837
1838 if (fxle->nodex==NULL) {fprintf(stderr,"NODE X is NULL!\n");return;}
1839 if (fxle->nodey==NULL) {fprintf(stderr,"NODE Y is NULL!\n");return;}
1840 if (fxle->nodez==NULL) {fprintf(stderr,"NODE Z is NULL!\n");return;}
1841 int facnpers=fac+pers*4;
1842 chgl->fVertexes[facnpers].clear();
1843 chgl->fNormals[facnpers].clear();
1844
1845 int h,k,l;
1846 int step=0;
1847 switch (pers) {
1848 case 0:
1849 //fprintf(stderr, "makeElement case 0 n1=%d n2=%d n3=%d N4=%d fac+pers=%d nodes %p %p %p\n",fxle->n1,fxle->n2,fxle->n3,fxle->n4,facnpers,fxle->nodex,fxle->nodey,fxle->nodez);
1850 for ( h=0; h<fxle->n1;h++){
1851 for ( k=0; k<fxle->n2;k++){
1852 for ( l=0; l<fxle->n3;l++){
1853 if (fxle->nodex==NULL) {fprintf(stderr,"NODE X is NULL!\n");return;}
1854 if (fxle->nodey==NULL) {fprintf(stderr,"NODE Y is NULL!\n");return;}
1855 if (fxle->nodez==NULL) {fprintf(stderr,"NODE Z is NULL!\n");return;}
1856 fxle->MakeElement(h,k,l,facnpers);
1857 }
1858 }
1859 step++;step%=mper;
1860 }
1861 //printf("makeElement made %d Vertexes %p %p %p\n", chgl->fVertexes[facnpers].size(), fxle->nodex, fxle->nodey, fxle->nodez);
1862 break;
1863 case 1:
1864 //fprintf(stderr, "makeElement case 1\n");
1865 for ( h=fxle->n1; h>=0;h--){
1866 for ( k=fxle->n2; k>=0;k--){
1867 for ( l=fxle->n3; l>=0;l--){
1868 if (fxle->nodex==NULL) {fprintf(stderr,"NODE X is NULL!\n");return;}
1869 if (fxle->nodey==NULL) {fprintf(stderr,"NODE Y is NULL!\n");return;}
1870 if (fxle->nodez==NULL) {fprintf(stderr,"NODE Z is NULL!\n");return;}
1871 fxle->MakeElement(h,k,l,facnpers);
1872 }
1873 }
1874 step++;step%=mper;
1875 }
1876 break;
1877 case 2:
1878 //fprintf(stderr, "makeElement case 2\n");
1879 for ( k=0; k<fxle->n2;k++){
1880 for ( h=0; h<fxle->n1;h++){
1881 for ( l=0; l<fxle->n3;l++){
1882 if (fxle->nodex==NULL) {fprintf(stderr,"NODE X is NULL!\n");return;}
1883 if (fxle->nodey==NULL) {fprintf(stderr,"NODE Y is NULL!\n");return;}
1884 if (fxle->nodez==NULL) {fprintf(stderr,"NODE Z is NULL!\n");return;}
1885 fxle->MakeElement(h,k,l,facnpers);
1886 }
1887 }
1888 step++;step%=mper;
1889 }
1890 break;
1891 case 3:
1892 //fprintf(stderr, "makeElement case 3\n");
1893 for ( k=fxle->n2; k>=0;k--){
1894 for ( h=fxle->n1; h>=0;h--){
1895 for ( l=fxle->n3; l>=0;l--){
1896 if (fxle->nodex==NULL) {fprintf(stderr,"NODE X is NULL!\n");return;}
1897 if (fxle->nodey==NULL) {fprintf(stderr,"NODE Y is NULL!\n");return;}
1898 if (fxle->nodez==NULL) {fprintf(stderr,"NODE Z is NULL!\n");return;}
1899 fxle->MakeElement(h,k,l,facnpers);
1900 }
1901 }
1902 step++;step%=mper;
1903 }
1904 break;
1905 case 4:
1906 //fprintf(stderr, "makeElement case 4\n");
1907 for ( l=0; l<fxle->n3;l++){
1908 for ( h=0; h<fxle->n1;h++){
1909 for ( k=0; k<fxle->n2;k++){
1910 if (fxle->nodex==NULL) {fprintf(stderr,"NODE X is NULL!\n");return;}
1911 if (fxle->nodey==NULL) {fprintf(stderr,"NODE Y is NULL!\n");return;}
1912 if (fxle->nodez==NULL) {fprintf(stderr,"NODE Z is NULL!\n");return;}
1913 fxle->MakeElement(h,k,l,facnpers);
1914 }
1915 }
1916 step++;step%=mper;
1917 }
1918 break;
1919 case 5:
1920 //fprintf(stderr, "makeElement case 5\n");
1921 for ( l=fxle->n3; l>=0;l--){
1922 for ( h=fxle->n1; h>=0;h--){
1923 for ( k=fxle->n2; k>=0;k--){
1924 if (fxle->nodex==NULL) {fprintf(stderr,"NODE X is NULL!\n");return;}
1925 if (fxle->nodey==NULL) {fprintf(stderr,"NODE Y is NULL!\n");return;}
1926 if (fxle->nodez==NULL) {fprintf(stderr,"NODE Z is NULL!\n");return;}
1927 fxle->MakeElement(h,k,l,facnpers);
1928 }
1929 }
1930 step++;step%=mper;
1931 }
1932 break;
1933 }
1934 }
1935 }
1936 fxle->iso[0]=fabs(fxle->iso[0]);
1937
1938 fxle->info=QString("<b>%13 Map:</b><font color=\"%12\">%1 e&Aring;<sup>-3</sup></font>"
1939 "<font color=\"%11\"> %2 e&Aring;<sup>-3</sup> (&sigma; = %7) </font><br><font color=grey> Hint: [%3 Scroll (up or down)] to change. </font><br>"
1940 "<b>Fo-Map:</b><font color=\"%10\">%4 e&Aring;<sup>-3</sup> (&sigma; = %8)</font><br><font color=grey> Hint: [%5 Scroll (up or down)] to change. </font><br>Time for creating map surfaces <b>%6 s</b>. %9 Triangles drawn.<br>")
1941 .arg(fxle->iso[1],6,'g',2)
1942 .arg(-fxle->iso[1],6,'g',2)
1943 .arg(QKeySequence(Qt::ControlModifier).toString(QKeySequence::NativeText))
1944 .arg(fxle->iso[0],6,'g',2)
1945 .arg(QKeySequence(Qt::ShiftModifier).toString(QKeySequence::NativeText))
1946 .arg(fxle->suti.elapsed()/1000.0,1,'f',1)
1947 .arg(fxle->sigma[0],6,'g',2)
1948 .arg(fxle->sigma[1],6,'g',2)
1949 .arg(fxle->tri)
1950 .arg(chgl->fopc.name())
1951 .arg(chgl->dipc.name())
1952 .arg(chgl->dimc.name())
1953 .arg((chgl->dipc.name() == QString("#008080"))?"BODD":"Fo-Fc1")//quick and dirty check for BODD
1954 ;
1955 //chgl->pause=false;
1956 fxle->connect(chgl,SIGNAL(inimibas()),fxle,SLOT(inimap()));
1957 fxle->connect(chgl,SIGNAL(neuemitte(V3)),fxle, SLOT(bewegt(V3)));
1958 fxle->connect(chgl,SIGNAL(diffscroll(int ,int )),fxle,SLOT(change_iso(int ,int )));
1959 chgl->fofcact->setVisible(!chgl->fVertexes[0].isEmpty()||!chgl->fVertexes[1].isEmpty());
1960 chgl->foact->setVisible(!chgl->fVertexes[2].isEmpty());
1961 //printf("wer ist empty %d %d %d %d\n",!chgl->fVertexes[0].isEmpty(),!chgl->fVertexes[1].isEmpty(),!chgl->fVertexes[2].isEmpty(),!chgl->fVertexes[0].isEmpty()||!chgl->fVertexes[1].isEmpty());
1962 // printf("Fomap ist da? %d Fo-Fcmap ist da? %d \n",chgl->fVertexes[2].isEmpty(),chgl->fVertexes[0].isEmpty());
1963
1964 //fxle->acnt=chgl->objCnt;
1965 }
1966
1967
1968 void FourXle::reportInfo(){
1969 emit bigmessage(info);
1970 }
1971
1972 void FourXle::change_iso(int numsteps,int diff){
1973 /*! canges the iso value of the fo or fo-fc maps and redraws them
1974 */
1975 //printf("isochaged\n");
1976 iso[diff]=fabs(iso[diff]);
1977 iso[diff]+=iso[diff]*numsteps/10.0f;
1978 int mi=0,ma=5;
1979 switch (diff) {
1980 case 0:
1981 mi=2;ma=4;
1982 break;
1983 case 1:
1984 mi=0; ma=2;
1985 break;
1986
1987 }
1988 gen_surface(false,mi,ma);
1989 chgl->update();
1990 }
1991
1992 void FourXle::foactDestroyed() {
1993 if (chgl!=NULL) chgl->foact = NULL;
1994 }
1995
1996 void FourXle::fofcactDestroyed() {
1997 if (chgl!=NULL)chgl->fofcact = NULL;
1998 }
1999
2000 void FourXle::chglDestroyed() {
2001 //fprintf(stderr,"chgl is dead omg ...argh...\n");
2002
2003 chgl = NULL;
2004 }
2005
2006 void FourXle::CalcVertex( int ix, int iy, int iz) {
2007 V3 mdz=(0.5*dx)+(0.5*dy)+(0.5*dz);
2008 V3 o,fl,m2u=V3(0.5,0.5,0.5);
2009 mole->frac2kart(m2u,m2u);
2010 double vo=0, vx=0,vy=0,vz=0;
2011 int idx=dex(ix,iy,iz);
2012 nodex[idx].flag=0;
2013 nodey[idx].flag=0;
2014 nodez[idx].flag=0;
2015 if (mtyp==0){//*datfo,*datfo_fc,*datf1_f2
2016 vo = datfo[ idx] -iso[mtyp];
2017 vx = datfo[ dex(ix+1,iy,iz)] -iso[mtyp];
2018 vy = datfo[ dex(ix,iy+1,iz)] -iso[mtyp];
2019 vz = datfo[ dex(ix,iy,iz+1)] -iso[mtyp];
2020 }else {
2021 vo = datfo_fc[idx] -iso[mtyp];
2022 vx = datfo_fc[dex(ix+1,iy,iz)] -iso[mtyp];
2023 vy = datfo_fc[dex(ix,iy+1,iz)] -iso[mtyp];
2024 vz = datfo_fc[dex(ix,iy,iz+1)] -iso[mtyp];
2025 }
2026 V3 nor=V3(0,0,0);//Normalize((vx-vo)*dx+(vy-vo)*dy+(vz-vo)*dz);
2027 if (Intersect(vo,vx)) {
2028 if (maptrunc==2) o=dx*((vo/(vo-vx))+ix) + dy*iy + dz*iz+m2u;
2029 else o=dx*((vo/(vo-vx))+ix) + dy*iy + dz*iz+urs;
2030
2031 mole->kart2frac(o,o);
2032 o+=V3(-0.5,-0.5,-0.5);
2033 fl=V3(floor(o.x),floor(o.y),floor(o.z));
2034 o+=-1.0*fl;
2035 o+=V3(0.5,0.5,0.5);
2036 mole->frac2kart(o,o);
2037 if (maptrunc!=2) o+=-1.0*urs;
2038 else o+=-1.0*m2u;
2039 o+=mdz;
2040 // orte.append(o);
2041 nodex[idx].vertex=o;
2042 nodex[idx].normal=nor;
2043 nodex[idx].flag=1;
2044 }
2045 if (Intersect(vo,vy)) {
2046 if (maptrunc==2)o=dx*ix + dy*((vo/(vo-vy))+iy) + dz*iz+m2u;
2047 else o=dx*ix + dy*((vo/(vo-vy))+iy) + dz*iz+urs;
2048 mole->kart2frac(o,o);
2049 o+=V3(-0.5,-0.5,-0.5);
2050 fl=V3(floor(o.x),floor(o.y),floor(o.z));
2051 o+=-1.0*fl;
2052 o+=V3(0.5,0.5,0.5);
2053 mole->frac2kart(o,o);
2054 if (maptrunc!=2) o+=-1.0*urs;
2055 else o+=-1.0*m2u;
2056 o+=mdz;
2057 // orte.append(o);
2058 nodey[idx].vertex=o;
2059 nodey[idx].normal=nor;
2060 nodey[idx].flag=1;
2061 }
2062 if (Intersect(vo,vz)) {
2063 if (maptrunc==2)o=dx*ix + dy*iy + dz*((vo/(vo-vz))+iz)+m2u;
2064 else o=dx*ix + dy*iy + dz*((vo/(vo-vz))+iz)+urs;
2065 mole->kart2frac(o,o);
2066 o+=V3(-0.5,-0.5,-0.5);
2067 fl=V3(floor(o.x),floor(o.y),floor(o.z));
2068 o+=-1.0*fl;
2069 o+=V3(0.5,0.5,0.5);
2070 mole->frac2kart(o,o);
2071 if (maptrunc!=2) o+=-1.0*urs;
2072 else o+=-1.0*m2u;
2073 o+=mdz;
2074 // orte.append(o);
2075 nodez[idx].vertex=o;
2076 nodez[idx].normal=nor;
2077 nodez[idx].flag=1;
2078 }
2079 }
2080
2081 void FourXle::makeFaces(int n, int faps, FNode poly[] ){
2082 if (n<3) return; //less then 3 vertices -> nothing to do
2083 V3 mid_ver = V3(0,0,0);
2084 V3 mid_nor2 = V3(0,0,0);
2085 for(int i=0; i<n; i++ ){
2086 if ((i>0)&&(i<n-1)) mid_nor2 += Normalize((poly[i].vertex-poly[0].vertex)%(poly[i+1].vertex-poly[0].vertex));
2087 mid_ver += poly[i].vertex;
2088 }
2089 mid_nor2=Normalize(mid_nor2);
2090 for(int i=0; i<n; i++ ){
2091 poly[i].normal = mid_nor2;
2092 }
2093 mid_ver *= (1.0/n);
2094 //mid_nor2= Normalize(mid_nor2);
2095 V3 mit=V3(1,1,1);
2096 mole->frac2kart(mit,mit);
2097 for (int w=0; w<27; w++){
2098 if (maptrunc==0){w=13;}
2099 else if ((maptrunc==1)&&(Distance(mit-urs,mid_ver+delDA[w])>(map_radius*map_radius))) continue;
2100 else if (maptrunc==2) {
2101 mole->kart2frac(mid_ver+delDA[w],oc);
2102 int ax = static_cast<int>((oc.x)/dxc.x-0.499),
2103 bx = static_cast<int>((oc.y)/dyc.y-0.499),
2104 cx = static_cast<int>((oc.z)/dzc.z-0.499);
2105 int DEX=dex3(ax,bx,cx);
2106 if (!noGoMap[DEX]) continue;
2107 }
2108 for (int k=1; k<n-1;k++){
2109 tri++;
2110
2111 chgl->fVertexes[faps].append(poly[k].vertex.x+delDA[w].x);
2112 chgl->fVertexes[faps].append(poly[k].vertex.y+delDA[w].y);
2113 chgl->fVertexes[faps].append(poly[k].vertex.z+delDA[w].z);
2114
2115 chgl->fVertexes[faps].append(poly[(k+1)].vertex.x+delDA[w].x);
2116 chgl->fVertexes[faps].append(poly[(k+1)].vertex.y+delDA[w].y);
2117 chgl->fVertexes[faps].append(poly[(k+1)].vertex.z+delDA[w].z);
2118
2119 chgl->fVertexes[faps].append(poly[0].vertex.x+delDA[w].x);
2120 chgl->fVertexes[faps].append(poly[0].vertex.y+delDA[w].y);
2121 chgl->fVertexes[faps].append(poly[0].vertex.z+delDA[w].z);
2122
2123
2124 chgl->fNormals[faps].append(poly[k].normal.x);
2125 chgl->fNormals[faps].append(poly[k].normal.y);
2126 chgl->fNormals[faps].append(poly[k].normal.z);
2127
2128 chgl->fNormals[faps].append(poly[(k+1)].normal.x);
2129 chgl->fNormals[faps].append(poly[(k+1)].normal.y);
2130 chgl->fNormals[faps].append(poly[(k+1)].normal.z);
2131
2132 chgl->fNormals[faps].append(poly[0].normal.x);
2133 chgl->fNormals[faps].append(poly[0].normal.y);
2134 chgl->fNormals[faps].append(poly[0].normal.z);
2135 }
2136 if (maptrunc==0) w=27;
2137 }
2138 }
2139
2140 int FourXle::IndexSelected( FNode& node0, FNode& node1, FNode& node2, FNode& node3 ) {
2141 if( node1 && node2 && node3 ){
2142 double d1 = Distance( node0.vertex, node1.vertex) + Distance( node3.vertex, node2.vertex) ;
2143 double d2 = Distance( node0.vertex, node2.vertex) + Distance( node3.vertex, node1.vertex );
2144 if( d1 > d2 ) return 2; else return 1;
2145 }else{
2146 if( node1 ) return 1;
2147 else if( node2 ) return 2;
2148 else if( node3 ) return 3;
2149 }
2150 return 0;
2151
2152 }
2153
2154 void FourXle::MakeElement(int ix, int iy, int iz , int faps) {
2155 QMutexLocker locker(&mutex);
2156 int conn[12][2][4] = {
2157 {{ 0, 1, 7, 6}, { 0, 2, 8, 3}}, // 0
2158 {{ 1, 2, 5, 4}, { 1, 0, 6, 7}}, // 1
2159 {{ 2, 0, 3, 8}, { 2, 1, 4, 5}}, // 2
2160 {{ 3, 8, 2, 0}, { 3, 4,10, 9}}, // 3
2161 {{ 4, 3, 9,10}, { 4, 5, 2, 1}}, // 4
2162 {{ 5, 4, 1, 2}, { 5, 6, 9,11}}, // 5
2163 {{ 6, 5,11, 9}, { 6, 7, 1, 0}}, // 6
2164 {{ 7, 6, 0, 1}, { 7, 8,11,10}}, // 7
2165 {{ 8, 7,10,11}, { 8, 3, 0, 2}}, // 8
2166 {{ 9,10, 4, 3}, { 9,11, 5, 6}}, // 9
2167 {{10,11, 8, 7}, {10, 9, 3, 4}}, // 10
2168 {{11, 9, 6, 5}, {11,10, 7, 8}} // 11
2169 };
2170 FNode node[12];
2171 FNode polygon[12];
2172 /*
2173 if (nodex==NULL) {fprintf(stderr,"NODE X is NULL!\n");return;}
2174 if (nodey==NULL) {fprintf(stderr,"NODE Y is NULL!\n");return;}
2175 if (nodez==NULL) {fprintf(stderr,"NODE Z is NULL!\n");return;}
2176 if (
2177 ((ix+iy*s1+iz*n4) %n5)<0||
2178 ((ix+iy*s1+iz*n4) %n5)<0||
2179 ((ix+iy*s1+iz*n4) %n5)<0||
2180 ((ix+iy*s1+((iz+1)%n3)*n4) %n5)<0||
2181 ((ix+iy*s1+((iz+1)%n3)*n4) %n5)<0||
2182 ((ix+((iy+1)%n2)*s1+iz*n4) %n5)<0||
2183 ((ix+((iy+1)%n2)*s1+iz*n4) %n5)<0||
2184 ((((1+ix)%n1)+iy*s1+iz*n4) %n5)<0||
2185 ((((1+ix)%n1)+iy*s1+iz*n4) %n5)<0||
2186 ((ix+((iy+1)%n2)*s1+((iz+1)%n3)*n4)%n5)<0||
2187 ((((ix+1)%n1)+iy*s1+((iz+1)%n3)*n4)%n5)<0||
2188 ((((ix+1)%n1)+((iy+1)%n2)*s1+iz*n4)%n5)<0
2189 )printf("EEEEK!\n");
2190 */
2191 node[ 0] = nodex[(ix+iy*n1+iz*n4) %n5]; // 000x
2192 node[ 1] = nodey[(ix+iy*n1+iz*n4) %n5]; // 000y
2193 node[ 2] = nodez[(ix+iy*n1+iz*n4) %n5]; // 000z
2194 node[ 3] = nodex[(ix+iy*n1+((iz+1)%n3)*n4) %n5]; // 001y
2195 node[ 4] = nodey[(ix+iy*n1+((iz+1)%n3)*n4) %n5]; // 001z
2196 node[ 5] = nodez[(ix+((iy+1)%n2)*n1+iz*n4) %n5]; // 010x
2197 node[ 6] = nodex[(ix+((iy+1)%n2)*n1+iz*n4) %n5]; // 010y
2198 node[ 7] = nodey[(((1+ix)%n1)+iy*n1+iz*n4) %n5]; // 100y
2199 node[ 8] = nodez[(((1+ix)%n1)+iy*n1+iz*n4) %n5]; // 100z
2200 node[ 9] = nodex[(ix+((iy+1)%n2)*n1+((iz+1)%n3)*n4)%n5];// 011x
2201 node[10] = nodey[(((ix+1)%n1)+iy*n1+((iz+1)%n3)*n4)%n5];// 101y
2202 node[11] = nodez[(((ix+1)%n1)+((iy+1)%n2)*n1+iz*n4)%n5];// 110z
2203 if ((static_cast<char>(node[0])+node[1]+node[2]+node[3]+node[4]+node[5]
2204 +node[6]+node[7]+node[8]+node[9]+node[10]+node[11])==0) return;
2205 for( int is=0; is<12; is++ ) {
2206 if( !node[is] ) continue;
2207
2208 int n=0, i=is, m=0;//,ai=i;
2209 double dis;
2210 dis=0.0;
2211 do {
2212 polygon[n++]= node[i];
2213 int sol = IndexSelected(
2214 node[conn[i][m][0]],
2215 node[conn[i][m][1]],
2216 node[conn[i][m][2]],
2217 node[conn[i][m][3]]);
2218 //ai=i;
2219 i = conn[i][m][sol];
2220 if( sol == 2 ) m ^= 1;
2221 dis+=Distance(polygon[0].vertex,node[i].vertex);
2222 node[i].flag= 0;
2223 }while( (i!=is)&&(n<11) );
2224 if (n>=3) {
2225 if (dis<5){
2226 //for (int polni=0; polni<n; polni++){polygon[polni].normal+=Normalize((polygon[(polni+1)%n].vertex-polygon[polni].vertex)%(polygon[(polni+n-1)%n].vertex-polygon[polni].vertex));}
2227 makeFaces( n, faps, polygon );
2228 }//*
2229 else {
2230 int axe=0;
2231 double delx=0,dely=0,delz=0;
2232 double mind=100000000;
2233 V3 minp=V3(10000,10000,10000),lihiun=V3(-10000,-10000,-10000);
2234 int minii=0;
2235 for (int polni=1; polni<=n; polni++){
2236 delx+=fabs(polygon[polni-1].vertex.x - polygon[polni%n].vertex.x);
2237 dely+=fabs(polygon[polni-1].vertex.y - polygon[polni%n].vertex.y);
2238 delz+=fabs(polygon[polni-1].vertex.z - polygon[polni%n].vertex.z);
2239 if (Distance(polygon[polni%n].vertex,lihiun)<mind) {
2240 mind=Distance(polygon[polni%n].vertex,minp);
2241 minii=polni%n;
2242 }
2243 }
2244 minp=polygon[minii].vertex;
2245 axe|=(delx>1)?1:0;
2246 axe|=(dely>1)?2:0;
2247 axe|=(delz>1)?4:0;
2248 for (int polni=0; polni<n; polni++){
2249 V3 neo=polygon[polni].vertex;
2250 double lang =Distance(minp,neo);
2251 if ((lang>Distance(minp,neo+dx*n1))&&(axe&1)) neo+=dx*n1;
2252 else if ((lang>Distance(minp,neo-dx*n1))&&(axe&1)) neo+=-n1*dx;
2253 lang =Distance(minp,neo);
2254 if ((lang>Distance(minp,neo+dy*n2))&&(axe&2)) neo+=n2*dy;
2255 else if ((lang>Distance(minp,neo-dy*n2))&&(axe&2)) neo+=-n2*dy;
2256 lang =Distance(minp,neo);
2257 if ((lang>Distance(minp,neo+n3*dz))&&(axe&4)) neo+=n3*dz;
2258 else if ((lang>Distance(minp,neo-n3*dz))&&(axe&4)) neo+=-n3*dz;
2259 polygon[polni].vertex=neo;
2260 }
2261 dis=0;
2262 for (int polni=1; polni<=n; polni++){
2263 dis+=Distance(polygon[polni-1].vertex , polygon[polni%n].vertex);
2264 }
2265 if (dis<5)
2266 makeFaces( n, faps, polygon );
2267 }
2268 // */
2269 }
2270 }
2271
2272 }
2273
2274 float FourXle::sigmaFo(){
2275 float DM=0.0f;
2276 float DS=0.0f;
2277 float f=0.0f;
2278 for (int i=0; i<n5; i++){
2279 f=datfo[i];
2280 DM+=f;
2281 DS+=f*f;
2282 }
2283 return sqrt((DS/n5)-((DM/n5)*(DM/n5)));
2284 }
2285
2286 float FourXle::sigmaFoFc(){
2287 float DM=0.0f;
2288 float DS=0.0f;
2289 float f=0.0f;
2290 for (int i=0; i<n5; i++){
2291 f=datfo_fc[i];
2292 DM+=f;
2293 DS+=f*f;
2294 }
2295 return sqrt((DS/n5)-((DM/n5)*(DM/n5)));
2296 }
2297
2298 void FourXle::jnk(){
2299 if(!n5)return;
2300 float mini=9e37f,maxi=-9e37f;
2301 float f,r,fstep;
2302 double DM,DS,sigma,w,e_net,e_gross;
2303 r=powf((3*(n1-1)*(n2-1)*(n3-1)),1.0f/3.0f);
2304 // printf("%d %d %d %d %f\n",n1,n2,n3,n5,r);
2305 float *datfo_fcstp=(float*) malloc(sizeof(float)*n5);
2306 if (datfo_fcstp==NULL)return ;
2307 float invstep=100.0f;
2308 float step=1.0f/invstep;
2309 float rhomind2=99999.0f,rhomaxd2=-99999.0f;
2310 QMap<float,int> hash;
2311 QMap<float,float> hashf;
2312 DM=0.0;
2313 DS=0.0;
2314 w=0.0;
2315 for (int i=0; i<n5; i++){
2316 f=datfo_fc[i];
2317 mini=qMin(f,mini);
2318 maxi=qMax(f,maxi);
2319 DM+=f;
2320 DS+=f*f;
2321 w+=fabs(f);
2322 datfo_fcstp[i]=floorf(f*invstep);
2323 }// */
2324 e_net=(DM/n5)*C[14];//C[14] ist das Volumen der UC
2325 e_gross=w/(2*n5)*C[14];
2326 sigma=sqrt((DS/n5)-((DM/n5)*(DM/n5)));
2327 //printf("%g %g %g",e_net,e_gross,sigma);
2328 for (int zi=0;zi<n3;zi++)
2329 for (int yi=0;yi<n2;yi++)
2330 for (int xi=0;xi<(n1-1);xi++){
2331 if (datfo_fcstp[dex(xi,yi,zi)]>datfo_fcstp[dex(xi+1,yi,zi)]){
2332 fstep=datfo_fcstp[dex(xi,yi,zi)];
2333 int ze=fstep-datfo_fcstp[dex(xi+1,yi,zi)];
2334 for (int zii=0; zii<ze; zii++) hash[(fstep-zii)*step]++;
2335 }else if (datfo_fcstp[dex(xi,yi,zi)]<datfo_fcstp[dex(xi+1,yi,zi)]){
2336 fstep=datfo_fcstp[dex(xi+1,yi,zi)];
2337 int ze=fstep-datfo_fcstp[dex(xi,yi,zi)];
2338 for (int zii=0; zii<ze; zii++) hash[(fstep-zii)*step]++;
2339 }
2340 }
2341 for (int xi=0;xi<n1;xi++)
2342 for (int zi=0;zi<n3;zi++)
2343 for (int yi=0;yi<(n2-1);yi++){
2344 if (datfo_fcstp[dex(xi,yi,zi)]>datfo_fcstp[dex(xi,yi+1,zi)]){
2345 fstep=datfo_fcstp[dex(xi,yi,zi)];
2346 int ze=fstep-datfo_fcstp[dex(xi,yi+1,zi)];
2347 for (int zii=0; zii<ze; zii++) hash[(fstep-zii)*step]++;
2348 }else if (datfo_fcstp[dex(xi,yi,zi)]<datfo_fcstp[dex(xi,yi+1,zi)]){
2349 fstep=datfo_fcstp[dex(xi,yi+1,zi)];
2350 int ze=fstep-datfo_fcstp[dex(xi,yi,zi)];
2351 for (int zii=0; zii<ze; zii++) hash[(fstep-zii)*step]++;
2352 }
2353 }
2354
2355 for (int yi=0;yi<n2;yi++)
2356 for (int xi=0;xi<n1;xi++)
2357 for (int zi=0;zi<(n3-1);zi++){
2358 if (datfo_fcstp[dex(xi,yi,zi)]>datfo_fcstp[dex(xi,yi,zi+1)]){
2359 fstep=datfo_fcstp[dex(xi,yi,zi)];
2360 int ze=fstep-datfo_fcstp[dex(xi,yi,zi+1)];
2361 for (int zii=0; zii<ze; zii++) hash[(fstep-zii)*step]++;
2362 }else if (datfo_fcstp[dex(xi,yi,zi)]<datfo_fcstp[dex(xi,yi,zi+1)]){
2363 fstep=datfo_fcstp[dex(xi,yi,zi+1)];
2364 int ze=fstep-datfo_fcstp[dex(xi,yi,zi)];
2365 for (int zii=0; zii<ze; zii++) hash[(fstep-zii)*step]++;
2366 }
2367 }
2368 free(datfo_fcstp);
2369 //float range=fmaxf(fabsf(mini),fabsf(maxi));
2370 QDialog *jnkdlg = new QDialog();
2371 QGraphicsScene*scene= new QGraphicsScene(-30,-50,550,586);
2372 scene->setBackgroundBrush(QBrush(QColor("#e9f7d6")));
2373 scene->clear ();
2374 QGraphicsItem *itm;
2375 for (int i=0; i<21;i++){
2376 itm=scene->addLine(i*25,0,i*25,500,(i%5)?QPen(QColor("#cbdbbb"),0):QPen(QColor("#959d9d"),0));
2377 itm->setData(0,-1);
2378 }
2379 for (int i=0; i<31;i++){
2380 itm=scene->addLine(0,i*16.66666666666667,500,i*16.66666666666667,(i%5)?QPen(QColor("#cbdbbb"),0):QPen(QColor("#959d9d"),0));
2381 itm->setData(0,-1);
2382 }
2383 itm=scene->addLine(250,0,250,500,QPen(QColor("#000000"),0));
2384 itm=scene->addLine(0,83.33333333333333,500,83.33333333333333,QPen(QColor("#000000"),0));
2385 itm=scene->addLine(0,250,500,250,QPen(QColor("#000000"),0));
2386 itm=scene->addLine(0,416.6666666666667,500,416.6666666666667,QPen(QColor("#000000"),0));
2387 QGraphicsTextItem *txt = scene->addText("3");
2388 txt->moveBy(-15,73.33333333333333);
2389 txt = scene->addText("2");
2390 txt->moveBy(-15,240);
2391 txt = scene->addText("1");
2392 txt->moveBy(-15,406.6666666666667);
2393 txt = scene->addText("-1.0");
2394 txt->moveBy(-15,500);
2395 txt = scene->addText("0");
2396 txt->moveBy(241,500);
2397 txt = scene->addText("1.0");
2398 txt->moveBy(485,500);
2399
2400
2401 QMapIterator<float, int> i(hash);
2402 while (i.hasNext()) {
2403 i.next();
2404 f=hashf[i.key()]=logf(i.value())/logf(r);
2405 scene->addEllipse(250+(i.key())*250,500-((f-0.5)/3.)*500,4,4,QPen(Qt::NoPen),QBrush(QColor("#0907e6")));
2406
2407 if (f>2){
2408 rhomind2=qMin(rhomind2,i.key());
2409 rhomaxd2=qMax(rhomaxd2,i.key());
2410 }
2411 // printf("jnk: %g %g %g %g %g %g\n",i.key(),f,rhomind2,rhomaxd2,250+(i.key())*250,500-((f-0.5)/3.)*500);
2412 }
2413 // printf("\ndf(0)= %g %d %g %g\n",hashf.value(0.0f),hash.value(0.0f),rhomind2,rhomaxd2);
2414
2415 float m,b;
2416 m=(hashf.value(rhomind2)-hashf.value(rhomind2-step))/step;
2417 b=hashf.value(rhomind2)-m*rhomind2;
2418 rhomind2=(2.0f-b)/m;
2419 m=(hashf.value(rhomaxd2)-hashf.value(rhomaxd2-step))/step;
2420 b=hashf.value(rhomaxd2)-m*(rhomaxd2);
2421 rhomaxd2=(2.0f-b)/m;
2422 // printf("df(0)= %g %d %g %g\n",hashf.value(0.0f),hash.value(0.0f),rhomind2,rhomaxd2);
2423 txt = scene->addText(QString("df(0) = %1").arg((double)hashf.value(0.0f),7,'f',2),QFont("Courier",10));
2424 txt->moveBy(328,2);
2425 txt = scene->addText(QString("min(d=2) = %1 eA^-3").arg((double)rhomind2,7,'f',3),QFont("Courier",10));
2426 txt->moveBy(305,18);
2427 txt = scene->addText(QString("max(d=2) = %1 eA^-3").arg((double)rhomaxd2,7,'f',3),QFont("Courier",10));
2428 txt->moveBy(305,34);
2429 txt = scene->addText(QString("min = %1 eA^-3").arg((double)mini,7,'f',3),QFont("Courier",10));
2430 txt->moveBy(305,50);
2431 txt = scene->addText(QString("max = %1 eA^-3").arg((double)maxi,7,'f',3),QFont("Courier",10));
2432 txt->moveBy(305,66);
2433 txt = scene->addText(QString("e_net = %1 e").arg((double)e_net,8,'g',3),QFont("Courier",10));
2434 txt->moveBy(295,82);
2435 txt = scene->addText(QString("e_gross = %1 e").arg((double)e_gross,8,'g',3),QFont("Courier",10));
2436 txt->moveBy(295,98);
2437 txt = scene->addText(QString(" = %1 eA^-3").arg((double)sigma,8,'f',3),QFont("Courier",10));
2438 txt->moveBy(295,116);
2439 txt = scene->addText(QString("nx ny nz %1 x %2 x %3 = %4").arg(n1).arg(n2).arg(n3).arg(n5),QFont("Courier",9));
2440 txt->moveBy(30,2);
2441 txt = scene->addText(QString("fractal dimension vs. residual density"),QFont("Helvetica",14,QFont::Bold));
2442 txt->moveBy(100,-40);
2443 txt = scene->addText(QString("df"),QFont("Helvetica",12,QFont::Bold));
2444 txt->moveBy(-20,20);
2445 txt = scene->addText(QString("0"),QFont("Helvetica",12,QFont::Bold));
2446 txt->moveBy(460,500);
2447
2448 #ifdef __APPLE__
2449 txt = scene->addText(QString::fromUtf8("𝛒"),QFont("Helvetica",16,QFont::Bold));
2450 txt->moveBy(450,490);
2451 txt = scene->addText(QString::fromUtf8("𝛒"),QFont("Helvetica",14));
2452 txt->moveBy(295,8);
2453 txt = scene->addText(QString::fromUtf8("𝛒"),QFont("Helvetica",14));
2454 txt->moveBy(295,24);
2455 txt = scene->addText(QString::fromUtf8("𝛒"),QFont("Helvetica",14));
2456 txt->moveBy(295,40);
2457 txt = scene->addText(QString::fromUtf8("𝛒"),QFont("Helvetica",14));
2458 txt->moveBy(295,56);
2459 txt = scene->addText(QString::fromUtf8("𝛔"),QFont("Helvetica",14));
2460 txt->moveBy(295,106);
2461 #else
2462 txt = scene->addText(QString::fromUtf8("ρ"),QFont("Helvetica",16,QFont::Bold));
2463 txt->moveBy(450,490);
2464 txt = scene->addText(QString::fromUtf8("ρ"),QFont("Helvetica",14));
2465 txt->moveBy(295,8);
2466 txt = scene->addText(QString::fromUtf8("ρ"),QFont("Helvetica",14));
2467 txt->moveBy(295,24);
2468 txt = scene->addText(QString::fromUtf8("ρ"),QFont("Helvetica",14));
2469 txt->moveBy(295,40);
2470 txt = scene->addText(QString::fromUtf8("ρ"),QFont("Helvetica",14));
2471 txt->moveBy(295,56);
2472 txt = scene->addText(QString::fromUtf8("σ"),QFont("Helvetica",14));
2473 txt->moveBy(295,106);
2474 #endif // */
2475 txt = scene->addText(QString("Please cite as: 'K. Meindl, J. Henn, Acta Cryst., 2008, A64, 404-418.'"),QFont("Helvetica",9));
2476 txt->moveBy(100,516);
2477 QGraphicsView *view = new QGraphicsView(scene,jnkdlg);
2478
2479 QVBoxLayout *lt = new QVBoxLayout(jnkdlg);
2480 lt->addWidget(view);
2481 jnkdlg->show();
2482
2483
2484 }
2485
2486
2487 inline int FourXle::dex(int x,int y, int z){
2488 /*! dex is used to adress elemennts of a one dimensional array by three indizes like it is a 3 dimensional array
2489 * @param x,y,z tree dimensional indices
2490 * if x is < 0 or > n1 it is not a problem because % is used to clamp it.
2491 * if y is < 0 or > n2 it is not a problem because % is used to clamp it.
2492 * if z is < 0 or > n3 it is not a problem because % is used to clamp it.
2493 * \returns index of an 1 dimensional array
2494 */
2495 x=(x+n1)%n1;
2496 y=(y+n2)%n2;
2497 z=(z+n3)%n3;
2498 return x+n1*(y+n2*z);
2499 }
2500
2501 inline int FourXle::dex3(int x,int y, int z){
2502 int n31=3*n1,n32=3*n2,n33=3*n3;
2503 x=(x+n31)%n31;
2504 y=(y+n32)%n32;
2505 z=(z+n33)%n33;
2506 return x+n31*(y+n32*z);
2507 }
2508
2509 /*=========================P=L=A=N=E===========================================/
2510 *
2511 * Contours lines on a plane
2512 *
2513 *=============================================================================*/
2514
2515 int FourXle::IndexSelectedP( Node& node0, Node& node1, Node& node2, Node& node3 ) {
2516 if( node1 && node2 && node3 ){
2517 GLfloat d1 = Distance( Planorte.at(node0.index).vertex, Planorte.at(node1.index).vertex ) +
2518 Distance( Planorte.at(node3.index).vertex, Planorte.at(node2.index).vertex );
2519 GLfloat d2 = Distance( Planorte.at(node0.index).vertex, Planorte.at(node2.index).vertex ) +
2520 Distance( Planorte.at(node3.index).vertex, Planorte.at(node1.index).vertex );
2521 if( d1 > d2 ) return 2; else return 1;
2522 }else{
2523 if( node1 ) return 1;
2524 else if( node2 ) return 2;
2525 else if( node3 ) return 3;
2526 }
2527 return 0;
2528 }
2529
2530 int cutTriangle(GLfloat va, GLfloat vb, GLfloat vc){
2531 if ((va<=0.0f)&&(vb<=0.0f)&&(vc<=0.0f)) return 0;
2532 if ((va>0.0f)&&(vb>0.0f)&&(vc>0.0f)) return 0;
2533
2534 if ((va<=0.0f)&&(vb>0.0f)&&(vc>0.0f)) return 1; //A
2535 if ((va>0.0f)&&(vb<=0.0f)&&(vc<=0.0f)) return 1;
2536
2537 if ((va>0.0f)&&(vb<=0.0f)&&(vc>0.0f)) return 2;
2538 if ((va<=0.0f)&&(vb>0.0f)&&(vc<=0.0f)) return 2;
2539
2540 if ((va>0.0f)&&(vb>0.0f)&&(vc<=0.0f)) return 3;
2541 if ((va<=0.0f)&&(vb<=0.0f)&&(vc>0.0f)) return 3;
2542
2543 return 4;
2544 }
2545
2546 void FourXle::findContour(QList<V3> &lines, GLfloat value){
2547 GLfloat Va,Vb,Vc,mix1,mix2;
2548 V3 sta,end;
2549 double scope=cScopeBx->value()*cScopeBx->value();
2550 for (int i=0; i<Planpgns.size();i++){
2551 int n=Planpgns.at(i).n;
2552 if (n==3){
2553 Va=Planorte.at(Planpgns.at(i).ii[0]).color-value;
2554 Vb=Planorte.at(Planpgns.at(i).ii[1]).color-value;
2555 Vc=Planorte.at(Planpgns.at(i).ii[2]).color-value;
2556 switch (cutTriangle(Va, Vb, Vc)){
2557 case 1:
2558 mix1=(Va/(Va-Vb));
2559 mix2=(Va/(Va-Vc));
2560 sta=(1.0f-mix1)*Planorte.at(Planpgns.at(i).ii[0]).vertex + (mix1)*Planorte.at(Planpgns.at(i).ii[1]).vertex;
2561 end=(1.0f-mix2)*Planorte.at(Planpgns.at(i).ii[0]).vertex + (mix2)*Planorte.at(Planpgns.at(i).ii[2]).vertex;
2562 if (Distance(sta,end)>1.0) break;
2563 if (scope > 0.0){
2564 if (Distance(sta,aufpunkt)> scope) break;
2565 if (Distance(end,aufpunkt)> scope) break;
2566 }
2567 sta+=pnormal*value*heightScale->value();
2568 end+=pnormal*value*heightScale->value();
2569 lines.append(sta);
2570 lines.append(end);
2571 break;
2572 case 2:
2573 mix1=(Va/(Va-Vb));
2574 mix2=(Vb/(Vb-Vc));
2575 sta=(1.0f-mix1)*Planorte.at(Planpgns.at(i).ii[0]).vertex + (mix1)*Planorte.at(Planpgns.at(i).ii[1]).vertex;
2576 end=(1.0f-mix2)*Planorte.at(Planpgns.at(i).ii[1]).vertex + (mix2)*Planorte.at(Planpgns.at(i).ii[2]).vertex;
2577 if (Distance(sta,end)>1.0) break;
2578 if (cScopeBx->value() > 0.0){
2579 if (Distance(sta,aufpunkt)> scope) break;
2580 if (Distance(end,aufpunkt)> scope) break;
2581 }
2582 sta+=pnormal*value*heightScale->value();
2583 end+=pnormal*value*heightScale->value();
2584 lines.append(sta);
2585 lines.append(end);
2586 break;
2587 case 3:
2588 mix1=(Vc/(Vc-Vb));
2589 mix2=(Va/(Va-Vc));
2590 sta=(1.0f-mix1)*Planorte.at(Planpgns.at(i).ii[2]).vertex + (mix1)*Planorte.at(Planpgns.at(i).ii[1]).vertex;
2591 end=(1.0f-mix2)*Planorte.at(Planpgns.at(i).ii[0]).vertex + (mix2)*Planorte.at(Planpgns.at(i).ii[2]).vertex;
2592 if (Distance(sta,end)>1.0) break;
2593 if (cScopeBx->value() > 0.0){
2594 if (Distance(sta,aufpunkt)> scope) break;
2595 if (Distance(end,aufpunkt)> scope) break;
2596 }
2597 sta+=pnormal*value*heightScale->value();
2598 end+=pnormal*value*heightScale->value();
2599 lines.append(sta);
2600 lines.append(end);
2601 break;
2602 }
2603 }else{
2604 V3 mid=V3(0.0,0.0,0.0);
2605 for (int j=0; j<n;j++) mid+=Planorte.at(Planpgns.at(i).ii[j]).vertex;
2606 mid*=1.0/n;
2607 GLfloat mixColor=0.0f;
2608 for (int j=0; j<n;j++) mixColor+=Planorte.at(Planpgns.at(i).ii[j]).color;
2609 mixColor*=1.0f/n;
2610 Va=mixColor-value;
2611 for (int k=0;k<n;k++){
2612 int kp=(k+1)%n;
2613 Vb=Planorte.at(Planpgns.at(i).ii[k]).color-value;
2614 Vc=Planorte.at(Planpgns.at(i).ii[kp]).color-value;
2615 switch (cutTriangle(Va, Vb, Vc)){
2616 case 1:
2617 mix1=(Va/(Va-Vb));
2618 mix2=(Va/(Va-Vc));
2619 sta=(1.0f-mix1)*mid + (mix1)*Planorte.at(Planpgns.at(i).ii[k]).vertex;
2620 end=(1.0f-mix2)*mid + (mix2)*Planorte.at(Planpgns.at(i).ii[kp]).vertex;
2621 if (Distance(sta,end)>1.0) break;
2622 if (cScopeBx->value() > 0.0){
2623 if (Distance(sta,aufpunkt)> scope) break;
2624 if (Distance(end,aufpunkt)> scope) break;
2625 }
2626 sta+=pnormal*value*heightScale->value();
2627 end+=pnormal*value*heightScale->value();
2628 lines.append(sta);
2629 lines.append(end);
2630 break;
2631 case 2:
2632 mix1=(Va/(Va-Vb));
2633 mix1=(Va/(Va-Vb));
2634 mix2=(Vb/(Vb-Vc));
2635 sta=(1.0f-mix1)*mid + (mix1)*Planorte.at(Planpgns.at(i).ii[k]).vertex;
2636 end=(1.0f-mix2)*Planorte.at(Planpgns.at(i).ii[k]).vertex + (mix2)*Planorte.at(Planpgns.at(i).ii[kp]).vertex;
2637 if (Distance(sta,end)>1.0) break;
2638 if (cScopeBx->value() > 0.0){
2639 if (Distance(sta,aufpunkt)> scope) break;
2640 if (Distance(end,aufpunkt)> scope) break;
2641 }
2642 sta+=pnormal*value*heightScale->value();
2643 end+=pnormal*value*heightScale->value();
2644 lines.append(sta);
2645 lines.append(end);
2646 break;
2647 case 3:
2648 mix1=(Vc/(Vc-Vb));
2649 mix2=(Va/(Va-Vc));
2650 sta=(1.0f-mix1)*Planorte.at(Planpgns.at(i).ii[kp]).vertex + (mix1)*Planorte.at(Planpgns.at(i).ii[k]).vertex;
2651 end=(1.0f-mix2)*mid + (mix2)*Planorte.at(Planpgns.at(i).ii[kp]).vertex;
2652 if (Distance(sta,end)>1.0) break;
2653 if (cScopeBx->value() > 0.0){
2654 if (Distance(sta,aufpunkt)> scope) break;
2655 if (Distance(end,aufpunkt)> scope) break;
2656 }
2657 sta+=pnormal*value*heightScale->value();
2658 end+=pnormal*value*heightScale->value();
2659 lines.append(sta);
2660 lines.append(end);
2661 break;
2662 case 4:
2663 printf("@@~~~~ %g %g %g\n",Va,Vb,Vc);
2664 }
2665 }
2666 }
2667 }
2668 }
2669
2670 void FourXle::CalcPlaneVertex( int ix, int iy, int iz , V3 n, V3 ap, V3 off){
2671 GLfloat vo, vx=0, vy=0, vz=0, mix;
2672 Ort o;
2673 //V3 xpo=V3(1,0,0);
2674 //mole->frac2kart(xpo,xpo);
2675 V3 mdz=0.25*dx+0.25*dy+0.25*dz;
2676 vo = n*(dx*ix + dy*iy + dz*iz-ap); //plane n dot (x - x1)
2677 vx = n*(dx*(ix+1) + dy*iy + dz*iz - ap);
2678 vy = n*(dx*ix + dy*(iy+1) + dz*iz - ap);
2679 vz = n*(dx*ix + dy*iy + dz*(iz+1) - ap);
2680 //V3 fl,mdz=(0.5*dx)+(0.5*dy)+(0.5*dz);
2681 if( ix != n1-1 && Intersect(vo,vx) ){
2682 mix=(vo/(vo-vx));
2683 o.vertex = dx*(mix+ix) + dy*iy + dz*iz +off;//+urs;
2684 /*
2685 mole->kart2frac(o.vertex,o.vertex);
2686 o.vertex+=V3(-0.5,-0.5,-0.5);
2687 fl=V3(floor(o.vertex.x),floor(o.vertex.y),floor(o.vertex.z));
2688 o.vertex+=-1.0*fl;
2689 o.vertex+=V3(0.5,0.5,0.5);
2690 mole->frac2kart(o.vertex,o.vertex);
2691 o.vertex+=-1.0*urs;
2692 // */
2693 o.vertex+=mdz;
2694 //o.vertex+=test3;
2695 //o.vertex+=-1.0*xpo;
2696 o.normal = n;
2697 if (sourceMap->currentIndex()==0)
2698 o.color = datfo_fc[(ix%n1)+(iy%n2)*n1+(iz%n3)*n4]*(1.0-mix)+mix*datfo_fc[((1+ix)%n1)+(iy%n2)*n1+(iz%n3)*n4];
2699 else o.color = datfo[(ix%n1)+(iy%n2)*n1+(iz%n3)*n4]*(1.0-mix)+mix*datfo_fc[((1+ix)%n1)+(iy%n2)*n1+(iz%n3)*n4];
2700 Planorte.append(o);
2701 nodeX[(ix%n1)+(iy%n2)*n1+(iz%n3)*n4].index=Planorte.size()-1;
2702 nodeX[(ix%n1)+(iy%n2)*n1+(iz%n3)*n4].flag=1;
2703 }else{
2704 nodeX[(ix%n1)+(iy%n2)*n1+(iz%n3)*n4].flag = 0;
2705 }
2706 if( iy != n2-1 && Intersect(vo,vy) ){
2707 mix=(vo/(vo-vy));
2708 o.vertex = dx*ix + dy*(mix+iy) + dz*iz+off;//+urs;
2709 /*
2710
2711 mole->kart2frac(o.vertex,o.vertex);
2712 o.vertex+=V3(-0.5,-0.5,-0.5);
2713 fl=V3(floor(o.vertex.x),floor(o.vertex.y),floor(o.vertex.z));
2714 o.vertex+=-1.0*fl;
2715 o.vertex+=V3(0.5,0.5,0.5);
2716 mole->frac2kart(o.vertex,o.vertex);
2717 o.vertex+=-1.0*urs;
2718 // */
2719 o.vertex+=mdz;
2720 //o.vertex+=test3;
2721
2722 //o.vertex+=-1.0*xpo;
2723 o.normal = n;
2724 if (sourceMap->currentIndex()==0)
2725 o.color = datfo_fc[(ix%n1)+(iy%n2)*n1+(iz%n3)*n4]*(1.0-mix)+ mix*datfo_fc[(ix%n1)+((iy+1)%n2)*n1+(iz%n3)*n4];
2726 else o.color = datfo[(ix%n1)+(iy%n2)*n1+(iz%n3)*n4]*(1.0-mix)+ mix*datfo_fc[(ix%n1)+((iy+1)%n2)*n1+(iz%n3)*n4];
2727 Planorte.append(o);
2728 nodeY[(ix%n1)+(iy%n2)*n1+(iz%n3)*n4].index=Planorte.size()-1;
2729 nodeY[(ix%n1)+(iy%n2)*n1+(iz%n3)*n4].flag=1;
2730 }else{
2731 nodeY[(ix%n1)+(iy%n2)*n1+(iz%n3)*n4].flag=0;
2732 }
2733 if( iz != n3-1 && Intersect(vo,vz) ){
2734 mix=(vo/(vo-vz));
2735 o.vertex = dx*ix + dy*iy + (mix+iz)*dz+off;//+urs;
2736 /*
2737 mole->kart2frac(o.vertex,o.vertex);
2738 o.vertex+=V3(-0.5,-0.5,-0.5);
2739 fl=V3(floor(o.vertex.x),floor(o.vertex.y),floor(o.vertex.z));
2740 o.vertex+=-1.0*fl;
2741 o.vertex+=V3(0.5,0.5,0.5);
2742 mole->frac2kart(o.vertex,o.vertex);
2743 o.vertex+=-1.0*urs;
2744 // */
2745
2746 o.vertex+=mdz;
2747 // o.vertex+=test3;
2748 //o.vertex+=-1.0*xpo;
2749 o.normal = n;
2750 if (sourceMap->currentIndex()==0)
2751 o.color = datfo_fc[(ix%n1)+(iy%n2)*n1+(iz%n3)*n4]*(1.0-mix)+mix*datfo_fc[(ix%n1)+(iy%n2)*n1+((iz+1)%n3)*n4];
2752 else o.color = datfo[(ix%n1)+(iy%n2)*n1+(iz%n3)*n4]*(1.0-mix)+mix*datfo_fc[(ix%n1)+(iy%n2)*n1+((iz+1)%n3)*n4];
2753 Planorte.append(o);
2754 nodeZ[(ix%n1)+(iy%n2)*n1+(iz%n3)*n4].index = Planorte.size()-1;
2755 nodeZ[(ix%n1)+(iy%n2)*n1+(iz%n3)*n4].flag=1;
2756 }else{
2757 nodeZ[(ix%n1)+(iy%n2)*n1+(iz%n3)*n4].flag = 0;
2758 }
2759 }
2760
2761 void FourXle::makeFacesp(int nn, Node poly[] ){
2762 // /*
2763 int n=0;
2764 int ly[13];
2765 for (int j=0;j<nn;j++)//zu nahe beieinander liegende verts ignorieren
2766 if (Distance(Planorte.at(poly[j].index).vertex,Planorte.at(poly[(j+1)%nn].index).vertex)>0.00)
2767 ly[n++]=poly[j].index;
2768 else{
2769 Planorte[poly[j].index].vertex=
2770 Planorte[poly[(j+1)%nn].index].vertex=
2771 (Planorte.at(poly[j].index).vertex+Planorte.at(poly[(j+1)%nn].index).vertex)*0.5f;
2772 Planorte[poly[j].index].color=
2773 Planorte[poly[(j+1)%nn].index].color=
2774 (Planorte.at(poly[j].index).color+Planorte.at(poly[(j+1)%nn].index).color)*0.5f;
2775 ly[n++]=poly[(j+1)%nn].index;
2776 j++;
2777 }
2778 GLfloat mid_col = 0.0;
2779 V3 mid_ver = V3(0,0,0);
2780 V3 mid_nor = V3(0,0,0);
2781 for(int i=0; i<n; i++ ){
2782 mid_ver += Planorte.at(ly[i]).vertex;
2783 mid_nor += Planorte.at(ly[i]).normal;
2784 mid_col += Planorte.at(ly[i]).color;
2785 }
2786 mid_ver *= (1.0/n);
2787 Normalize(mid_nor);
2788 mid_col *= (1.0/n);
2789 if (n<3) return; //weniger als 3 verts -> nichts zu tun
2790 Polygn neupoly;
2791 neupoly.vertex=mid_ver;
2792 neupoly.n=n;
2793 //if (Planorte.at(poly[0].index).direct*iso_level<0.0){//drehsinn der polygone abfragen* /
2794 for(int i=0; i<n; i++ ){
2795 neupoly.ii[i]=ly[i];
2796 }
2797 //}
2798 /*else{
2799 for(int i=n-1,k=0; i>=0; i-- ){
2800 neupoly.ii[i]=ly[k++];
2801 }
2802 }//else*/
2803 Planpgns.append(neupoly);
2804 // */
2805 }
2806
2807 void FourXle::MakeElementp( int ix, int iy, int iz ,int s1, int s2) {//das ist der Teil des japanischen Programms den ich nicht verstehe.
2808 //Hauptsache fuktioniert.
2809 // /*
2810 static int conn[12][2][4] = { //char->int wegen warning g++ >3.0
2811 {{ 0, 1, 7, 6}, { 0, 2, 8, 3}}, // 0
2812 {{ 1, 2, 5, 4}, { 1, 0, 6, 7}}, // 1
2813 {{ 2, 0, 3, 8}, { 2, 1, 4, 5}}, // 2
2814 {{ 3, 8, 2, 0}, { 3, 4,10, 9}}, // 3
2815 {{ 4, 3, 9,10}, { 4, 5, 2, 1}}, // 4
2816 {{ 5, 4, 1, 2}, { 5, 6, 9,11}}, // 5
2817 {{ 6, 5,11, 9}, { 6, 7, 1, 0}}, // 6
2818 {{ 7, 6, 0, 1}, { 7, 8,11,10}}, // 7
2819 {{ 8, 7,10,11}, { 8, 3, 0, 2}}, // 8
2820 {{ 9,10, 4, 3}, { 9,11, 5, 6}}, // 9
2821 {{10,11, 8, 7}, {10, 9, 3, 4}}, // 10
2822 {{11, 9, 6, 5}, {11,10, 7, 8}} // 11
2823 };
2824 static Node node[12];
2825 static Node polygon[12];
2826
2827 node[ 0] = nodeX[(ix+iy*s1+iz*s2) %n5];// 000x
2828 node[ 1] = nodeY[(ix+iy*s1+iz*s2) %n5];// 000y
2829 node[ 2] = nodeZ[(ix+iy*s1+iz*s2) %n5];// 000z
2830 node[ 3] = nodeX[(ix+iy*s1+((iz+1)%n3)*s2) %n5];// 001y
2831 node[ 4] = nodeY[(ix+iy*s1+((iz+1)%n3)*s2) %n5];// 001z
2832 node[ 5] = nodeZ[(ix+((iy+1)%n2)*s1+iz*s2) %n5];// 010x
2833 node[ 6] = nodeX[(ix+((iy+1)%n2)*s1+iz*s2) %n5];// 010y
2834 node[ 7] = nodeY[(((1+ix)%n1)+iy*s1+iz*s2) %n5];// 100y
2835 node[ 8] = nodeZ[(((1+ix)%n1)+iy*s1+iz*s2) %n5];// 100z
2836 node[ 9] = nodeX[(ix+((iy+1)%n2)*s1+((iz+1)%n3)*s2)%n5];// 011x
2837 node[10] = nodeY[(((ix+1)%n1)+iy*s1+((iz+1)%n3)*s2)%n5];// 101y
2838 node[11] = nodeZ[(((ix+1)%n1)+((iy+1)%n2)*s1+iz*s2)%n5];// 110z
2839
2840 if (((char)node[0]+node[1]+node[2]+node[3]+node[4]+node[5]
2841 +node[6]+node[7]+node[8]+node[9]+node[10]+node[11])==0) return;
2842 for( int is=0; is<12; is++ ) {
2843 if( !node[is] ) continue;
2844
2845 int n=0, i=is, m=0;//,ai=i;
2846 do {
2847 polygon[n++]= node[i];
2848 int sol = IndexSelectedP(node[conn[i][m][0]],node[conn[i][m][1]],
2849 node[conn[i][m][2]],node[conn[i][m][3]]);
2850 // ai=i;
2851 i = conn[i][m][sol];
2852
2853 if( sol == 2 ) m ^= 1;
2854 node[i].flag = 0;
2855 }while( (i!=is)&&(n<11) );
2856 {
2857 makeFacesp( n, polygon );
2858 }
2859 }
2860 // */
2861 }
2862
2863 void FourXle::makePlane(QList<V3> &lines,int a1, int a2, int a3) {
2864 /*
2865 farbe[0][0]=0.6;
2866 farbe[0][1]=0.0;
2867 farbe[0][2]=0.0;
2868 farbe[0][3]=1.0;
2869
2870 farbe[1][0]=0.6;
2871 farbe[1][1]=0.0;
2872 farbe[1][2]=0.0;
2873 farbe[1][3]=1.0;
2874
2875 farbe[2][0]=0.6;
2876 farbe[2][1]=0.0;
2877 farbe[2][2]=0.0;
2878 farbe[2][3]=1.0;
2879
2880 farbe[3][0]=0.0;
2881 farbe[3][1]=0.0;
2882 farbe[3][2]=0.0;
2883 farbe[3][3]=1.0;
2884
2885 farbe[4][0]=0.0;
2886 farbe[4][1]=0.0;
2887 farbe[4][2]=1.0;
2888 farbe[4][3]=1.0;
2889
2890 farbe[5][0]=0.0;
2891 farbe[5][1]=0.0;
2892 farbe[5][2]=1.0;
2893 farbe[5][3]=1.0;
2894
2895 farbe[6][0]=0.0;
2896 farbe[6][1]=0.0;
2897 farbe[6][2]=1.0;
2898 farbe[6][3]=1.0;
2899
2900 Farben=7;
2901 */
2902
2903 // fprintf(stderr, "makePlane %d %d %d %d %d\n",n1,n2,n3,n4,n5);
2904 //orig=V3(0,0,0);
2905 // n4=n1*n2;
2906 // data.clear();
2907
2908 if (( nodeX =(Node*)malloc(sizeof(Node)*n5))==NULL) {
2909 qDebug()<<"Less Memory(X) ";
2910 exit(1);
2911 }
2912 if (( nodeY =(Node*)malloc(sizeof(Node)*n5))==NULL) {
2913 qDebug()<<"Less Memory(Y)!!";
2914 exit(1);
2915 }
2916 if (( nodeZ =(Node*)malloc(sizeof(Node)*n5))==NULL) {
2917 qDebug()<<"Less Memory(Z)!!";
2918 exit(1);
2919 }
2920 // printf("UIUI %p %p %p\n",nodeX,nodeY,nodeZ);
2921 for (int ix=0; ix<n5; ix++){
2922 nodeX[ix].index=0;
2923 nodeX[ix].flag=0;
2924 nodeY[ix].index=0;
2925 nodeY[ix].flag=0;
2926 nodeZ[ix].index=0;
2927 nodez[ix].flag=0;
2928 }
2929 // printf("__\n");
2930 Planorte.clear();
2931 Planpgns.clear();
2932 lines.clear();
2933 chgl->contval.clear();
2934 if (ogl) ogl->contval.clear();
2935
2936 //test3= ((n1-1)/-2.0) * dx + ((n2-1)/-2.0) * dy + ((n3-1)/-2.0) * dz + orig;
2937 //test3=orig;
2938 // printf("Atomindices: %d %d %d < %d\n",a1,a2,a3,mole->showatoms.size());
2939 if ((a1>=mole->showatoms.size())||(a2>=mole->showatoms.size())||(a3>=mole->showatoms.size())) return;
2940 if ((a1<0)||(a2<0)||(a3<0)) return;
2941 if (mole->showatoms[a1].pos==mole->showatoms[a2].pos){
2942 mole->frac2kart(mole->showatoms[a1].frac,mole->showatoms[a1].pos);
2943 mole->frac2kart(mole->showatoms[a2].frac,mole->showatoms[a2].pos);
2944 mole->frac2kart(mole->showatoms[a3].frac,mole->showatoms[a3].pos);
2945 }
2946 V3 a1v=V3(mole->showatoms.at(a1).pos.x,mole->showatoms.at(a1).pos.y,mole->showatoms.at(a1).pos.z);
2947 V3 a2v=V3(mole->showatoms.at(a2).pos.x,mole->showatoms.at(a2).pos.y,mole->showatoms.at(a2).pos.z);
2948 V3 a3v=V3(mole->showatoms.at(a3).pos.x,mole->showatoms.at(a3).pos.y,mole->showatoms.at(a3).pos.z);
2949 pnormal = Normalize((a2v - a1v) % (a3v - a1v));
2950 switch (centerIsOn->currentIndex()){
2951 case 0: aufpunkt = V3(mole->showatoms.at(a1).pos.x,mole->showatoms.at(a1).pos.y,mole->showatoms.at(a1).pos.z);break;
2952 case 1: aufpunkt = V3(mole->showatoms.at(a2).pos.x,mole->showatoms.at(a2).pos.y,mole->showatoms.at(a2).pos.z);break;
2953 case 2: aufpunkt = V3(mole->showatoms.at(a3).pos.x,mole->showatoms.at(a3).pos.y,mole->showatoms.at(a3).pos.z);break;
2954 case 3: {
2955 aufpunkt = (1.0/3.0)*
2956 (V3(mole->showatoms.at(a1).pos.x,mole->showatoms.at(a1).pos.y,mole->showatoms.at(a1).pos.z)+
2957 V3(mole->showatoms.at(a2).pos.x,mole->showatoms.at(a2).pos.y,mole->showatoms.at(a2).pos.z)+
2958 V3(mole->showatoms.at(a3).pos.x,mole->showatoms.at(a3).pos.y,mole->showatoms.at(a3).pos.z));
2959 break;
2960 }
2961
2962 }
2963 // aufpunkt = V3(mole->showatoms.at(a1).kart.x,mole->showatoms.at(a1).kart.y,mole->showatoms.at(a1).kart.z);
2964 // printf("%g %g %g %g %g %g %g\n",Norm(pnormal),pnormal.x,pnormal.y,pnormal.z,aufpunkt.x,aufpunkt.y,aufpunkt.z);
2965 double angle = winkel(pnormal, V3(0,0,1));
2966 V3 ax= Normalize(pnormal % V3(0,0,1));
2967 double cp = cos(angle), cp1 = 1.0 - cos(angle), sp = sin(angle);
2968 double X=ax.x,Y=ax.y,Z=ax.z;
2969 Matrix ROT = Matrix(
2970 cp+cp1*X*X, -Z*sp+cp1*X*Y, Y*sp+cp1*X*Z,
2971 Z*sp+cp1*X*Y, cp+cp1*Y*Y, -X*sp+cp1*Y*Z,
2972 -Y*sp+cp1*X*Z, X*sp+cp1*Y*Z, cp+cp1*Z*Z);
2973 V3 bv=ROT*Normalize(V3(a2v.x-a1v.x,a2v.y-a1v.y,a2v.z-a1v.z));
2974 //printf("BV %g %g %g\n",bv.x,bv.y,bv.z);
2975 double bww=winkel(bv,V3( 1,0,0));
2976 cp=cos(bww);
2977 sp=sin(bww);
2978 //printf("%g %g %g\n",bww*180.0/M_PI,cp,sp);
2979 Matrix R2 = Matrix(
2980 cp, sp, 0,
2981 -sp, cp, 0,
2982 0, 0, 1);//*/
2983 bv=R2*bv;
2984 bww=winkel(bv,V3( 1,0,0));
2985 if (fabs(bww)>1) {
2986 R2 = Matrix(
2987 cp,-sp, 0,
2988 sp, cp, 0,
2989 0, 0, 1);//*/
2990
2991 }
2992 //printf("BV %g %g %g %g\n",bv.x,bv.y,bv.z,bww);
2993 V3 vt = ROT * V3(pnormal.x, pnormal.y, pnormal.z);
2994 vt = R2*vt;
2995 //printf("ang %g %g %g \n%12.6f %12.6f %12.6f \n%g %g\n%g\n",angle/M_PI*180.0, pnormal*ax,ax*V3(0,0,1), vt.x, vt.y, vt.z,determinant(ROT),Norm(ax),winkel(a1v,V3(0,1,0)));
2996 // fprintf(stderr, "makePlane\n");
2997 int qii=0;V3 ap;
2998 int aa=-1,ee=2;
2999 if (!extendUnit->isChecked()){aa++;ee--;}
3000 for (int iix=aa; iix<ee; iix++){
3001 for (int iiy=aa; iiy<ee; iiy++){
3002 for (int iiz=aa; iiz<ee; iiz++){
3003 V3 propo=V3(iix,iiy,iiz)+V3(0.5,0.5,0.5);
3004 V3 pp=V3(iix,iiy,iiz);
3005 mole->frac2kart(propo,propo);
3006 mole->frac2kart(pp,pp);
3007 double abst=pnormal*(propo-aufpunkt);
3008 V3 da=propo-abst*pnormal;
3009 mole->kart2frac(da,da);
3010 qii++;
3011 // printf("PLANE %2d %2d %2d %12g %12g %12g %g %12g %12g %12g\n",iix,iiy,iiz,da.x,da.y,da.z,abst,da.x-iix,da.y-iiy,da.z-iiz);
3012 ap=da-V3(iix,iiy,iiz);
3013 mole->frac2kart(ap,ap);
3014 //printf("H%d' 1 %8.5f %8.5f %8.5f 11.0 0.05 %5.3f \n",qii, da.x, da.y, da.z,abst);
3015 // if ((da.x-iix<1.0)&&(da.x-iix>0.0)&&(da.y-iiy<1.0)&&(da.y-iiy>0.0)&&(da.z-iiz<1.0)&&(da.z-iiz>0.0)){
3016 for( int ix=0; ix<=n1; ix++ ){
3017 for( int iy=0; iy<=n2; iy++ ){
3018 for( int iz=0; iz<=n3; iz++ ){
3019 CalcPlaneVertex(ix,iy,iz,pnormal,ap,pp);//
3020 //CalcPlaneVertex(ix,iy,iz,pnormal,aufpunkt,V3(0,0,0));
3021 }
3022 }
3023 }
3024 //printf("%3d %3d %3d Planorte.size = %d\n",iix,iiy,iiz,Planorte.size());
3025 //fprintf(stderr, "makePlane\n");
3026 for( int ix=0; ix<n1-1; ix++ )
3027 for( int iy=0; iy<n2-1; iy++ )
3028 for( int iz=0; iz<n3-1; iz++ )
3029 MakeElementp(ix,iy,iz,n1,n4);
3030 //}
3031 }
3032 }
3033 }
3034 double minP=1e37,maxP=-1e38;
3035 for (int i=0; i<Planorte.size(); i++) {
3036 minP=fmin(Planorte.at(i).color,minP);
3037 maxP=fmax(Planorte.at(i).color,maxP);
3038 }
3039 //fprintf(stderr, "makePlane Planpgns.size = %d Planorte.size = %d minP = %g maxP = %g\n",Planpgns.size(),Planorte.size(),minP,maxP);
3040 min= 1e37;
3041 max=-1e37;
3042 QStringList numbers = QString(contourValueEdit->text()).split(" ",skipEmptyParts);
3043 int z=0;
3044 // printf("ok\n");
3045 if (!numbers.isEmpty()) chgl->contval[0]=numbers.at(0).toFloat();
3046 if ((ogl)&&(!numbers.isEmpty())) ogl->contval[0]=numbers.at(0).toFloat();
3047 for (int i = 0; i < numbers.size(); i++){
3048 float contour = numbers.at(i).toFloat();
3049 findContour(lines,contour);
3050 chgl->contval[lines.size()]=contour;
3051 if (ogl) ogl->contval[lines.size()]=contour;
3052 if ((lines.size()-z)>0){
3053 min=fmin(contour,min);
3054 max=fmax(contour,max);
3055 }
3056 z=lines.size();
3057 }
3058 chgl->contMax=max;
3059 chgl->contMin=min;
3060 if (ogl){
3061 ogl->contMax=max;
3062 ogl->contMin=min;
3063 ogl->cont = lines;
3064 ogl->makeContours();
3065 }
3066 chgl->cont = lines;
3067 chgl->makeContours();
3068 // printf("ok %f %f\n",min,max);
3069 //legende();
3070 free(nodeX);
3071 nodeX=NULL;
3072 free(nodeY);
3073 nodeY=NULL;
3074 free(nodeZ);
3075 nodeZ=NULL;
3076 Planpgns.clear();
3077 Planorte.clear();
3078 //printf("ok\n");
3079 QList<V3> lin2d;
3080 int aspect1=3,aspect2=4;//todo make aspect ratio changable
3081 switch (aspectRatios->currentIndex()) {
3082 case 0: aspect1=3,aspect2=4; break;
3083 case 1: aspect1=9,aspect2=16; break;
3084 case 2: aspect1=1,aspect2=1; break;
3085 }
3086 int width=1024*aspect1/aspect2;
3087 double miX = 9.e30;
3088 double maX = -9.e30;
3089 double miY = 9.e30;
3090 double maY = -9.e30;
3091 V3 v1;//,v2=V3(99,99,99);
3092 for (int i=0; i<lines.size(); i++){
3093 v1=R2*(ROT * V3(lines.at(i).x-aufpunkt.x,lines.at(i).y-aufpunkt.y,lines.at(i).z-aufpunkt.z));
3094 //if (Distance(v1,v2)>0.0)
3095 lin2d.append(v1);
3096 miX=fmin(v1.x,miX);
3097 maX=fmax(v1.x,maX);
3098 miY=fmin(v1.y,miY);
3099 maY=fmax(v1.y,maY);
3100
3101
3102 //v2=v1;
3103 }
3104 //printf("!%d == %d! %f < X < %f, %f < Y < %f \n",lin2d.size(),lines.size(),miX,maX,miY,maY);
3105 if (cScopeBx->value() > 0.0){
3106 double XX=cScopeBx->value();
3107 double YY=(XX*aspect1)/aspect2;//todo make aspect ratio changable
3108 miX=-XX;
3109 miY=-YY;
3110 maX= XX;
3111 maY= YY;
3112 }
3113 //printf("!%d == %d! %f < X < %f, %f < Y < %f \n",lin2d.size(),lines.size(),miX,maX,miY,maY);
3114 if (contEPSFile->text().isEmpty()){
3115 // qDebug()<<"contEPSFile->text() is Empty()";
3116 QString contourDescription1;
3117 for (int i=0; i<lin2d.size()/2; i++){
3118 //(wrt-min)/(max-min)
3119 if (chgl->contval.contains(i*2)) {
3120 if (chgl->contval.value(i*2)>0.00001f) {
3121 contourDescription1.append(QString("<font color=blue>blue contours at %1 e&Aring;<sup>-3</sup></font> <br>\n").arg(chgl->contval.value(i*2)));
3122 }
3123 else if (chgl->contval.value(i*2)<-0.00001f){
3124 contourDescription1.append(QString("<font color=red>red contours at %1 e&Aring;<sup>-3</sup></font> <br>\n").arg(chgl->contval.value(i*2)));
3125 }
3126 else {
3127 contourDescription1.append(QString("<font color=black>black contours at 0 e&Aring;<sup>-3</sup></font> <br>\n"));
3128 }
3129 }
3130 }
3131 emit bigmessage(QString("%1<br>").arg(contourDescription1));
3132 return;
3133 }
3134
3135 // ||(!QFile::exists (contEPSFile->text())))
3136 //qDebug()<<QDate::currentDate().toString(Qt::ISODate);
3137 FILE *f=fopen(contEPSFile->text().toLocal8Bit(),"wt");
3138 fprintf(f,"%s%d\n","%!PS-Adobe-3.0 EPSF-3.0\n%%BoundingBox: 0 0 1024 ",width);
3139 char whoiam[1000];
3140 sprintf(whoiam,
3141 "%%Title: %s Contour Plot\n"
3142 "%%Creator: %s by Christian B. Hubschle\n",PROGRAM_NAME,PROGRAM_NAME);
3143 fprintf(f,"%s",whoiam);
3144 fprintf(f,"%%%%CreationDate: %s\n",QDate::currentDate().toString(Qt::ISODate).toStdString().c_str());
3145
3146 fprintf(f,"%s",
3147 //"%%Pages: 1\n"
3148 "%%EndComments\n"
3149 "%%BeginProlog\n"
3150 //"/l { newpath moveto lineto stroke } bind def\n"
3151 //"/nm { newpath moveto } bind def\n"
3152 "/cp {closepath} bind def\n"
3153 "/ef {eofill} bind def\n"
3154 "/gr {grestore} bind def\n"
3155 "/gs {gsave} bind def\n"
3156 "/sa {save} bind def\n"
3157 "/rs {restore} bind def\n"
3158 "/l {lineto} bind def\n"
3159 "/m {moveto} bind def\n"
3160 "/rm {rmoveto} bind def\n"
3161 "/n {newpath} bind def\n"
3162 "/s {stroke} bind def\n"
3163 "/sh {show} bind def\n"
3164 "/slc {setlinecap} bind def\n"
3165 "/slj {setlinejoin} bind def\n"
3166 "/slw {setlinewidth} bind def\n"
3167 "/srgb {setrgbcolor} bind def\n"
3168 "/rot {rotate} bind def\n"
3169 "/sc {scale} bind def\n"
3170 "/sd {setdash} bind def\n"
3171 "/ff {findfont} bind def\n"
3172 "/sf {setfont} bind def\n"
3173 "/scf {scalefont} bind def\n"
3174 "/sw {stringwidth} bind def\n"
3175 //"%%EndSetup\n"
3176 "%%EndProlog\n"
3177 //"%%Page: 1 1\n"
3178 //"gsave\n"
3179 //"20 20 scale\n"
3180 //"10 10 translate\n"
3181 "save\n0 slc 0 slj\n/Helvetica ff 18 scf sf\n");
3182 fprintf(f,"n 0 0 m 1024 0 l 1024 %d l 0 %d l cp clip s\n",width,width);
3183 fprintf(f,"n 2 2 m 1023 2 l 1023 %d l 2 %d l cp s \n",width-2,width-2);
3184 //"0 setgray\n"
3185
3186
3187 //Atoms
3188 for (int i=0; i<mole->showatoms.size(); i++){
3189 V3 ato=R2*(ROT*(mole->showatoms.at(i).pos-V3(aufpunkt.x,aufpunkt.y,aufpunkt.z)));
3190 if ((ato.x>maX)||(ato.x<miX)||(ato.y>maY)||(ato.y<miY)) continue;
3191 //Acol[xdinp[j].OrdZahl]
3192 if (fabs(ato.z)<0.2){
3193 double rad=(mole->showatoms.at(i).an>-1)?mole->arad[mole->showatoms.at(i).an]:0.15;
3194 QColor col=mole->AtomColor[mole->showatoms.at(i).an];
3195 fprintf(f,"n %G %G %G 0 360 arc cp gs %g %g %g srgb fill s gr%% %g %s\n",
3196 (ato.x-miX)/(maX-miX)*1024, (ato.y-miY)/(maY-miY)*width, rad*50,
3197 col.redF(),
3198 col.greenF(),
3199 col.blueF(),ato.z,
3200 mole->showatoms.at(i).Label.toStdString().c_str());
3201 }
3202 // 4 5 3 0 360 arc closepath
3203 }
3204 //Bonds
3205 for (int k=0;k<mole->showbonds.size();k++){
3206 V3 anf=R2*(ROT*(mole->showbonds[k].ato1->pos-V3(aufpunkt.x,aufpunkt.y,aufpunkt.z)));
3207 V3 end=R2*(ROT*(mole->showbonds[k].ato2->pos-V3(aufpunkt.x,aufpunkt.y,aufpunkt.z)));
3208 if ((anf.x>maX)||(anf.x<miX)||(anf.y>maY)||(anf.y<miY)) continue;
3209 if ((end.x>maX)||(end.x<miX)||(end.y>maY)||(end.y<miY)) continue;
3210 if ((fabs(anf.z)<0.2)&&(fabs(end.z)<0.2))
3211 fprintf(f,"n %G %G m %G %G l cp s\n",
3212 (anf.x-miX)/(maX-miX)*1024, (anf.y-miY)/(maY-miY)*width,
3213 (end.x-miX)/(maX-miX)*1024, (end.y-miY)/(maY-miY)*width);
3214
3215 }
3216
3217 // V3 v1,v2;
3218 //qDebug()<<contval;
3219 float red=0.0f,green=0.0f,blue=0.0f;
3220 QString contourDescription;
3221 for (int i=0; i<lin2d.size()/2; i++){
3222 //(wrt-min)/(max-min)
3223 if (chgl->contval.contains(i*2)) {
3224 if (chgl->contval.value(i*2)>0.00001f) {
3225 red=0.0f;green=0.0f;blue=1.0f;
3226 contourDescription.append(QString("% blue@%1, %2 lines\n").arg(chgl->contval.value(i*2)).arg(i));
3227 // printf("blau %f %d\n",contval.value(i*2),i);
3228 }
3229 else if (chgl->contval.value(i*2)<-0.00001f){
3230 red=1.0f;green=0.0f;blue=0.0f;
3231 contourDescription.append(QString("% red@%1, %2 lines\n").arg(chgl->contval.value(i*2)).arg(i));
3232 // printf("rot %f %d\n",contval.value(i),i);
3233 }
3234 else {
3235 red=0.0f;green=0.0f;blue=0.0f;
3236 contourDescription.append(QString("% black@%1, %2 lines\n").arg(chgl->contval.value(i*2)).arg(i));
3237 // printf("schwarz %f %d\n",chgl->contval.value(i*2),i);
3238 }
3239 }
3240 if ((lin2d.at(2*i ).x>maX)||(lin2d.at(2*i ).x<miX)||(lin2d.at(2*i ).y>maY)||(lin2d.at(2*i ).y<miY)) continue;
3241 if ((lin2d.at(2*i+1).x>maX)||(lin2d.at(2*i+1).x<miX)||(lin2d.at(2*i+1).y>maY)||(lin2d.at(2*i+1).y<miY)) continue;
3242 fprintf(f,"n %G %G m %G %G l cp gs %g %g %g srgb 0.5 slw s gr\n",
3243 (lin2d.at(2*i ).x-miX)/(maX-miX)*1024, (lin2d.at(i*2 ).y-miY)/(maY-miY)*width,
3244 (lin2d.at(2*i+1).x-miX)/(maX-miX)*1024, (lin2d.at(i*2+1).y-miY)/(maY-miY)*width,red,green,blue);
3245 }
3246 for (int i=0; i<mole->showatoms.size(); i++){
3247 V3 ato=R2*(ROT*(mole->showatoms.at(i).pos-V3(aufpunkt.x,aufpunkt.y,aufpunkt.z)));
3248 if ((ato.x>maX)||(ato.x<miX)||(ato.y>maY)||(ato.y<miY)) continue;
3249 if (fabs(ato.z)<0.2){
3250 double rad=(mole->showatoms.at(i).an>-1)?mole->arad[mole->showatoms.at(i).an]:0.15;
3251 fprintf(f,"gs n %G %G m (%s) true charpath 1 slw 1 setgray s gr\n",(ato.x-miX)/(maX-miX)*1024+rad*50, (ato.y-miY)/(maY-miY)*width,mole->showatoms.at(i).Label.toStdString().c_str());
3252 fprintf(f,"gs %G %G m (%s) sh gr\n",(ato.x-miX)/(maX-miX)*1024+rad*50, (ato.y-miY)/(maY-miY)*width,mole->showatoms.at(i).Label.toStdString().c_str());
3253
3254 }
3255 // 4 5 3 0 360 arc closepath
3256 }
3257 fprintf(f,"%s",
3258 "restore\n"
3259 "showpage\n"
3260 "%%Trailer\n"
3261 "%%EOF\n"
3262 );
3263 fprintf(f,"%% plane: %s %s %s\n%% contours: %s\n",
3264 mole->showatoms.at(a1).Label.toStdString().c_str(),
3265 mole->showatoms.at(a2).Label.toStdString().c_str(),
3266 mole->showatoms.at(a3).Label.toStdString().c_str(),
3267 contourDescription.toStdString().c_str());
3268 //printf("->%d\n",fclose(f));
3269 //printf("ok3074\n");
3270 QString contourDescription1;
3271 for (int i=0; i<lin2d.size()/2; i++){
3272 //(wrt-min)/(max-min)
3273 if (chgl->contval.contains(i*2)) {
3274 if (chgl->contval.value(i*2)>0.00001f) {
3275 contourDescription1.append(QString("<font color=blue>blue contours at %1 e&Aring;<sup>-3</sup></font> <br>\n").arg(chgl->contval.value(i*2)));
3276 }
3277 else if (chgl->contval.value(i*2)<-0.00001f){
3278 contourDescription1.append(QString("<font color=red>red contours at %1 e&Aring;<sup>-3</sup></font> <br>\n").arg(chgl->contval.value(i*2)));
3279 }
3280 else {
3281 contourDescription1.append(QString("<font color=black>black contours at 0 e&Aring;<sup>-3</sup></font> <br>\n"));
3282 }
3283 }
3284 }
3285 emit bigmessage(QString("%1<br>").arg(contourDescription1));
3286
3287 }
3288
3289
3290