Debian Codegraph @

fourxle.h

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 #ifndef FOURXLE_H
20 #define FOURXLE_H 1
21 #include <stdio.h>
22 #include <stdlib.h>
23 #include <math.h>
24 #include <ctype.h>
25 #include <string.h>
26 #include <locale.h>
27 //#include <fftw3.h> //if you want you can try to uncoment this, but then you have to coment the following line
28 #include "kissfft/kiss_fftnd.h"
29 #include "molecule.h"
30 //#include "chgl.h"
31 #include "opengltestwidget.h"
32 #include <QObject>
33 #include <QCheckBox>
34 #include <QComboBox>
35 #include <QMutex>
36 #include <QMutexLocker>
37 #include <QToolBar>
38 #include <QDialogButtonBox>
39 #include <QPushButton>
40 #include <QGridLayout>
41 #include <QVBoxLayout>
42
43 //! Rec is a reflection type of a fcf 6 file.
44 typedef struct {
45 int ih,//!< h
46 ik,//!< k
47 il;//!< l
48 float fo,//!< F observed
49 so,//!< \f$\sigma(observed)\f$
50 fc,//!< F calculated
51 phi; //!< \f$\varphi\f$
52 } Rec;
53 #define LM 2000000
54 //! FNode is a struct for the 3 different edges of a cube
55 struct FNode {
56 V3 vertex;//!< vertex is the 3d position of the node
57 V3 normal;//!< normal is the plane normal of the surface
58 char flag;//!< this flag is set when the surface crosses this node
59 inline operator char (){
60 //! \returns the flag parameter. No Coala ;-)
61 return flag;
62 }
63 inline operator V3(){
64 //! \returns the vertex of the node.
65 return vertex;
66 }
67 friend inline double Distance( const FNode& n1, const FNode& n2 ){
68 /*! @param n1,n2 nodes vor which the squared distance should be calculated.
69 \returns te positional squared distance between two nodes
70 */
71 return Norm(n1.vertex-n2.vertex);
72 }
73 };
74
75 struct Polygn {
76 V3 vertex;
77 int n;
78 int ii[13];
79 };
80
81 struct Ort {
82 V3 vertex;
83 V3 normal;
84 GLfloat color;
85 char direct;
86 };
87
88 struct Node {
89 int index;
90 unsigned char flag;
91 inline operator unsigned char (){return flag;}
92 };
93
94 //
95 //! FourXle is an QObject that loads a fcf 6 file and creates iso-surfaces in meshed style \inherit QObject
96 class FourXle:public QObject{
97 Q_OBJECT
98 public:
99 int HKLMX;//!< Maximum of h,k and l values can be used to make a resulution cut.
100 float *datfo,//!<data pointer for the fobs map in real space
101 *datfo_fc;//!<data pointer for the fobs-fcalc map in real space
102 float f000;
103 float overridef000;
104 bool isBelo;
105 FourXle(Molecule *mole_, PlayOpenGL *chgl_,QToolBar *toolView, double resol=2.5, double wght=1.1);
106 /*!< @param mole_ pointer to the Molecule of ShelXle
107 * @param chgl_ pointer to the ChGL widged of ShelXle
108 * @param toolView pointer to the View Toolbar of ShelXle
109 * @param resol resolution factor (the higher the more grid points)
110 * @param wght a parameter to downweight weak reflections
111 */
112 ~FourXle();
113 QDialogButtonBox *buttonBoxMC;
114 QPushButton *applyMC;
115 QPushButton *applyDF;
116 QPushButton *jnkButton;
117 QLabel *wl, *pl, *dl, *ol, *rl, *sl, *lw, *ltz;
118 QDialog *md;
119 bool MYFCF;
120 QDoubleSpinBox *maprad,*fomaps,*difmaps,*weak,*mapprec,*lineTrans,*lineWidth,*cutrange;
121 QPushButton *foPlusButton,*foMinusButton,*diffPlusButton,*diffMinusButton, *defColorButton;
122 QComboBox *mapSchnitt;
123 QGridLayout *mdl;
124 QVBoxLayout *amdl;
125 QAction *keepiso;
126 QAction *mapcontrol;
127 QCheckBox *ownfcf6, *ownfcf6_;
128 QString fouName;
129 void drawMap(int faps);
130 int maptrunc;
131 double map_radius; //!< radius of the map in Angstrom around the rotaion center (used only in a mode of FourXle).
132
133 bool loadFouAndPerform(const char filename[],bool neu=true);
134 bool loadMap(int NX, int NY, int NZ, float *dat);
135 QDir resDir;
136 QCheckBox *keepIso;//!<keeps the initial iso values good for idieal presentations
137 float sigma[3];//!<sigma values
138 float iso[3];//!<iso values
139 // double mInimum[2],mAximum[2];
140 V3 urs;//!< origin
141 double rr,//!< resolution factor (the higher the more grid points)
142 rw;//!< a parameter to downweight weak reflections
143
144 QCheckBox *doMaps;//!< do or notthing todo is the question
145 Molecule *mole;//!< pointer to the Molecule object
146 //ChGL *chgl=nullptr;//!< pointer to the ChGL widget
147 PlayOpenGL *chgl=nullptr;//!< pointer to the ChGL widget
148 PlayOpenGL *ogl=nullptr;
149 void setOGL(PlayOpenGL *_ogl){
150 ogl=_ogl;
151 }
152 QString voxelstr;//!< a string to fix dimensions to desired values by comand line option '-voxel 92x92x92 '
153 //void deleteLists();
154 void killmaps();
155 void jnk();
156 float sigmaFo();
157 float sigmaFoFc();
158 void exportMaps(int na, const char filename[], const char atomlist[]);
159 int n1,//!< dimension of the map in a diRection
160 n2,//!< dimension of the map in b diRection
161 n3,//!< dimension of the map in c diRection
162 n4;//!< \f$ n4 = n1 \times n2\f$
163 int n5;//!< \f$ n5 = n1 \times n2 \times n3\f$
164 V3 dx,//!< vector in a direction for each map voxel
165 dy,//!< vector in b direction for each map voxel
166 dz;//!< vector in c direction for each map voxel
167 QVector<Ort> Planorte;
168 QVector<Polygn> Planpgns;
169 // QList<double> data;
170 inline int Intersect( GLfloat& vm, GLfloat& vp ){
171 return vm*vp <= 0.0 && (vm<0.0 || vp<0.0);
172 }
173 Node *nodeX;
174 Node *nodeY;
175 Node *nodeZ;
176 QCheckBox *extendUnit;
177 void CalcPlaneVertex( int ix, int iy, int iz ,V3 n,V3 ap,V3 off);
178 void makeFacesp(int nn, Node poly[] );
179 void MakeElementp( int ix, int iy, int iz ,int s1, int s2);
180 int IndexSelectedP( Node& node0, Node& node1, Node& node2, Node& node3 );
181 void findContour(QList<V3> &lines, GLfloat value);
182 void makePlane(QList<V3> &lines,int a1, int a2, int a3);
183 double min,max;
184 V3 orig,test3;
185 V3 pnormal,aufpunkt;
186 QLineEdit *contMapFile, *contourValueEdit, *contEPSFile;
187 QComboBox *aspectRatios, *centerIsOn, *sourceMap;
188 QDoubleSpinBox *cScopeBx, *heightScale;
189 inline double winkel(V3 a,V3 b){
190 return acos((a.x*b.x+a.y*b.y+a.z*b.z)/(sqrt(a.x*a.x+a.y*a.y+a.z*a.z)*sqrt(b.x*b.x+b.y*b.y+b.z*b.z)));
191 }
192 public slots:
193 void bewegt(V3 v);
194 void inimap();
195 void change_iso(int numsteps,int diff);
196 void chglDestroyed();
197 void foactDestroyed();
198 void fofcactDestroyed();
199 void doMapsNow(bool b);//!<destroys maps or (re)calculates them freshly.
200 void mapDefault();//!< restores the defaults of the Map Control dialog.
201 void schnittart(int trunc);//!< the truncation type of the electron density maps changes to trunc @param trunc new truncation type.
202 void controlMap();//!<Shows the Map-Control Dialog.
203 void keepIsoValues(bool b);
204 void killFourXleFirst();//!< attempt to run killmaps before chgl gets destryed
205 void colorDLGFOP();//!<Color Dialog for Fobs plus. Positive values of Fo map are drawn with a mesh in this color.
206 void colorDLGFOM();//!<Color Dialog for Fobs minus. Negative values of Fo map are drawn with a mesh in this color.
207 void colorDLGDIP();//!<Color Dialog for Fobs-Fcalc plus. Positive values of Fo-Fc map are drawn with a mesh in this color.
208 void colorDLGDIM();//!<Color Dialog for Fobs-Fcalc minus. Negative values of Fo-Fc map are drawn with a mesh in this color.
209 void defaultColors();//!<Restores the default colors of the electron density maps (Fo+ blue Fo- yellow Fo-Fc+ green Fo-Fc- red).
210 void openMapControl();//!< shows the Map Control dialog.
211 void updateLines();
212 void reportInfo();
213 signals:
214 void bigmessage(const QString &);//!< to comunicate with the informaton window
215 void reloadRes();
216 void haltMW();//stop the map worker
217
218 private:
219 mutable QMutex mutex;
220 double C[15],D[9],sy[12][192],wave;
221 inline int Intersect( double& vm, double& vp ){ return vm*vp <= 0.0 && (vm<0.0 || vp<0.0); }
222 inline int dex(int x,int y,int z);
223 inline int dex3(int x,int y,int z);
224 int oldatomsize;
225 int acnt;
226 QString info;
227 V3 oc,dxc,dyc,dzc;
228 V3 delDA[27];
229 #ifdef FFTW3_H
230 fftwf_plan fwd_plan;//!!!
231 fftwf_complex *B;//!!!
232 #else
233 kiss_fftnd_cfg fwd_plan;//!!!
234 kiss_fft_cpx *B;//!!!
235 #endif
236 FNode *nodex,*nodey,*nodez;
237 int *noGoMap;
238 QSettings *einstellung;
239 Rec lr[LM];
240 char cen,git;
241 int nr,nc,ns;
242 int mtyp,tri;
243 QElapsedTimer foti,suti;
244 // double minnor,maxnor;
245 void gen_surface(bool neu,int imin=0, int imax=4);
246 void CalcVertex( int ix, int iy, int iz);
247 // V3 CalcNormalX( int ix, int iy, int iz );
248 // V3 CalcNormalY( int ix, int iy, int iz );
249 // V3 CalcNormalZ( int ix, int iy, int iz );
250 int IndexSelected( FNode& node0, FNode& node1, FNode& node2, FNode& node3);
251 // V3& VectorSelected( FNode& node0, FNode& node1, FNode& node2, FNode& node3);
252 void MakeElement( int ix, int iy, int iz, int faps);
253 void makeFaces(int n, int faps, FNode poly[] );
254 char titl[80];/*fcmax=0,f000=0,resmax=99999.0,*/
255 void trimm(char s[]);
256 void deletes(char *s, int count);
257 int readHeader(const char *filename);
258 void sorthkl(int nr, Rec r[]);
259
260 friend class GenMapWorker;
261 };
262
263
264
265 class GenMapWorker : public QThread{
266 Q_OBJECT
267 public:
268 GenMapWorker(PlayOpenGL *chgl_,Molecule *mol_, FourXle *parent, bool neu_=true,int imin_=0, int imax_=4){
269 chgl = chgl_;
270 mole=mol_;
271 fxle = parent;// maybe I need it later?
272 neu=neu_;
273 imin=imin_;
274 imax=imax_;
275 }
276 ~GenMapWorker(){
277 //printf("destruct GenMapWorker\n");
278 }
279
280 void run() {
281 /* expensive or blocking operation */
282 gen_surface(neu, imin,imax);
283 }
284 void gen_surface(bool neu,int imin=0, int imax=4);
285 PlayOpenGL *chgl;
286 FourXle *fxle;//parent
287 Molecule *mole;
288 bool neu;
289 int imin,imax;
290 };
291
292
293 #endif