| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 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 |
|
| 28 |
#include "kissfft/kiss_fftnd.h" |
| 29 |
#include "molecule.h" |
| 30 |
|
| 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 |
|
| 44 |
typedef struct { |
| 45 |
int ih, |
| 46 |
ik, |
| 47 |
il; |
| 48 |
float fo, |
| 49 |
so, |
| 50 |
fc, |
| 51 |
phi; |
| 52 |
} Rec; |
| 53 |
#define LM 2000000 |
| 54 |
|
| 55 |
struct FNode { |
| 56 |
V3 vertex; |
| 57 |
V3 normal; |
| 58 |
char flag; |
| 59 |
inline operator char (){ |
| 60 |
|
| 61 |
return flag; |
| 62 |
} |
| 63 |
inline operator V3(){ |
| 64 |
|
| 65 |
return vertex; |
| 66 |
} |
| 67 |
friend inline double Distance( const FNode& n1, const FNode& n2 ){ |
| 68 |
|
| 69 |
|
| 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 |
|
| 96 |
class FourXle:public QObject{ |
| 97 |
Q_OBJECT |
| 98 |
public: |
| 99 |
int HKLMX; |
| 100 |
float *datfo, |
| 101 |
*datfo_fc; |
| 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 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 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; |
| 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; |
| 137 |
float sigma[3]; |
| 138 |
float iso[3]; |
| 139 |
|
| 140 |
V3 urs; |
| 141 |
double rr, |
| 142 |
rw; |
| 143 |
|
| 144 |
QCheckBox *doMaps; |
| 145 |
Molecule *mole; |
| 146 |
|
| 147 |
PlayOpenGL *chgl=nullptr; |
| 148 |
PlayOpenGL *ogl=nullptr; |
| 149 |
void setOGL(PlayOpenGL *_ogl){ |
| 150 |
ogl=_ogl; |
| 151 |
} |
| 152 |
QString voxelstr; |
| 153 |
|
| 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, |
| 160 |
n2, |
| 161 |
n3, |
| 162 |
n4; |
| 163 |
int n5; |
| 164 |
V3 dx, |
| 165 |
dy, |
| 166 |
dz; |
| 167 |
QVector<Ort> Planorte; |
| 168 |
QVector<Polygn> Planpgns; |
| 169 |
|
| 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); |
| 200 |
void mapDefault(); |
| 201 |
void schnittart(int trunc); |
| 202 |
void controlMap(); |
| 203 |
void keepIsoValues(bool b); |
| 204 |
void killFourXleFirst(); |
| 205 |
void colorDLGFOP(); |
| 206 |
void colorDLGFOM(); |
| 207 |
void colorDLGDIP(); |
| 208 |
void colorDLGDIM(); |
| 209 |
void defaultColors(); |
| 210 |
void openMapControl(); |
| 211 |
void updateLines(); |
| 212 |
void reportInfo(); |
| 213 |
signals: |
| 214 |
void bigmessage(const QString &); |
| 215 |
void reloadRes(); |
| 216 |
void haltMW(); |
| 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 |
|
| 245 |
void gen_surface(bool neu,int imin=0, int imax=4); |
| 246 |
void CalcVertex( int ix, int iy, int iz); |
| 247 |
|
| 248 |
|
| 249 |
|
| 250 |
int IndexSelected( FNode& node0, FNode& node1, FNode& node2, FNode& node3); |
| 251 |
|
| 252 |
void MakeElement( int ix, int iy, int iz, int faps); |
| 253 |
void makeFaces(int n, int faps, FNode poly[] ); |
| 254 |
char titl[80]; |
| 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; |
| 272 |
neu=neu_; |
| 273 |
imin=imin_; |
| 274 |
imax=imax_; |
| 275 |
} |
| 276 |
~GenMapWorker(){ |
| 277 |
|
| 278 |
} |
| 279 |
|
| 280 |
void run() { |
| 281 |
|
| 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; |
| 287 |
Molecule *mole; |
| 288 |
bool neu; |
| 289 |
int imin,imax; |
| 290 |
}; |
| 291 |
|
| 292 |
|
| 293 |
#endif |