/**************************************************************************** ** ** Copyright (C) 2011 Christian B. Huebschle & George M. Sheldrick ** All rights reserved. ** Contact: chuebsch@moliso.de ** ** This file is part of the ShelXle ** ** This file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software ** Foundation and appearing in the file COPYING included in the ** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** ****************************************************************************/ #include "molecule.h" #include #include #include #include "partcolor.h" const double g2r=180.0/M_PI; #include "itsme.h" Molecule::Molecule(){ printf("Molecule contsructor \n"); proba=50; program_in_use=false; fibo=(sqrt(5.0f)+1.0f)*0.5f; fibom1=fibo-1.0f; //useShaders=true; mynewnameis=QString(PROGRAM_NAME); if (mynewnameis=="shelXle"){ theIconPath=QString(":/xle-icons/"); }else{ theIconPath=QString(":/bicons/"); } mist=false; g_program=0; g_Program=nullptr; shaders_work=false; qPeakRad=0.05; growQPeak=false; tubes=0; planeTransparence=0.25; qboMin=0.97; qboMax=1.67; HAWink=135; HAMax=2.5; dratom=0; deuteriumColor=QColor("palegreen"); LOD=4; highlightEquivalents = true; mQolor=QColor(128,76,76); monoQrom=false; nopm1=false; bondColorStyle=0; bondStrength=0.05; beloRad=0.04; noQPeaksPlease=false; HFixSuitableAtomsOnly=false; for (int i=0,j=0; i<18; i++){ if ((i>5)&&(j%5==0)) j++; int colori=27+j; symmColors.append(QColor::colorNames().at(colori)); j++; } theseAreAcceptors.append(6);//NOF theseAreAcceptors.append(7); theseAreAcceptors.append(8); theseAreDonors.append(5);//CNOF theseAreDonors.append(6); theseAreDonors.append(7); theseAreDonors.append(8); //QList theseAreDonors; beloColor= QColor("teal"); beloColorByDefden=true; beloLabels=true; //nonPositiveDefinite=0; Kovalenz_Radien[0 ]=32 ;Kovalenz_Radien[1 ]=1 ;Kovalenz_Radien[2 ]=123 ;Kovalenz_Radien[3 ]=90 ; Kovalenz_Radien[4 ]=80 ;Kovalenz_Radien[5 ]=77 ;Kovalenz_Radien[6 ]=74 ;Kovalenz_Radien[7 ]=66 ; Kovalenz_Radien[8 ]=72 ;Kovalenz_Radien[9 ]=1 ;Kovalenz_Radien[10 ]=154 ;Kovalenz_Radien[11 ]=149 ; Kovalenz_Radien[12 ]=118 ;Kovalenz_Radien[13 ]=111 ;Kovalenz_Radien[14 ]=106 ;Kovalenz_Radien[15 ]=102 ; Kovalenz_Radien[16 ]=99 ;Kovalenz_Radien[17 ]=1 ;Kovalenz_Radien[18 ]=203 ;Kovalenz_Radien[19 ]=174 ; Kovalenz_Radien[20 ]=144 ;Kovalenz_Radien[21 ]=132 ;Kovalenz_Radien[22 ]=122 ;Kovalenz_Radien[23 ]=118 ; Kovalenz_Radien[24 ]=117 ;Kovalenz_Radien[25 ]=117 ;Kovalenz_Radien[26 ]=116 ;Kovalenz_Radien[27 ]=124 ; Kovalenz_Radien[28 ]=117 ;Kovalenz_Radien[29 ]=125 ;Kovalenz_Radien[30 ]=126 ;Kovalenz_Radien[31 ]=122 ; Kovalenz_Radien[32 ]=120 ;Kovalenz_Radien[33 ]=116 ;Kovalenz_Radien[34 ]=114 ;Kovalenz_Radien[35 ]=1 ; Kovalenz_Radien[36 ]=218 ;Kovalenz_Radien[37 ]=191 ;Kovalenz_Radien[38 ]=162 ;Kovalenz_Radien[39 ]=145 ; Kovalenz_Radien[40 ]=134 ;Kovalenz_Radien[41 ]=130 ;Kovalenz_Radien[42 ]=127 ;Kovalenz_Radien[43 ]=125 ; Kovalenz_Radien[44 ]=125 ;Kovalenz_Radien[45 ]=128 ;Kovalenz_Radien[46 ]=134 ;Kovalenz_Radien[47 ]=148 ; Kovalenz_Radien[48 ]=144 ;Kovalenz_Radien[49 ]=141 ;Kovalenz_Radien[50 ]=140 ;Kovalenz_Radien[51 ]=136 ; Kovalenz_Radien[52 ]=133 ;Kovalenz_Radien[53 ]=1 ;Kovalenz_Radien[54 ]=235 ;Kovalenz_Radien[55 ]=198 ; Kovalenz_Radien[56 ]=169 ;Kovalenz_Radien[57 ]=165 ;Kovalenz_Radien[58 ]=165 ;Kovalenz_Radien[59 ]=164 ; Kovalenz_Radien[60 ]=164 ;Kovalenz_Radien[61 ]=162 ;Kovalenz_Radien[62 ]=185 ;Kovalenz_Radien[63 ]=161 ; Kovalenz_Radien[64 ]=159 ;Kovalenz_Radien[65 ]=159 ;Kovalenz_Radien[66 ]=157 ;Kovalenz_Radien[67 ]=157 ; Kovalenz_Radien[68 ]=156 ;Kovalenz_Radien[69 ]=170 ;Kovalenz_Radien[70 ]=156 ;Kovalenz_Radien[71 ]=144 ; Kovalenz_Radien[72 ]=134 ;Kovalenz_Radien[73 ]=130 ;Kovalenz_Radien[74 ]=128 ;Kovalenz_Radien[75 ]=126 ; Kovalenz_Radien[76 ]=127 ;Kovalenz_Radien[77 ]=130 ;Kovalenz_Radien[78 ]=134 ;Kovalenz_Radien[79 ]=149 ; Kovalenz_Radien[80 ]=148 ;Kovalenz_Radien[81 ]=147 ;Kovalenz_Radien[82 ]=146 ;Kovalenz_Radien[83 ]=146 ; Kovalenz_Radien[84 ]=145 ;Kovalenz_Radien[85 ]=1 ;Kovalenz_Radien[86 ]=0 ;Kovalenz_Radien[87 ]=1 ; Kovalenz_Radien[88 ]=188 ;Kovalenz_Radien[89 ]=165 ;Kovalenz_Radien[90 ]=161 ;Kovalenz_Radien[91 ]=142 ; Kovalenz_Radien[92 ]=130 ;Kovalenz_Radien[93 ]=151 ;Kovalenz_Radien[94 ]=182 ; //printf("Kovalenz_Radien H hat :%d \n",Kovalenz_Radien[0]); //printf("Kovalenz_Radien N hat :%d \n",Kovalenz_Radien[6]); /* //EN{ ElNeg[0]=220; ElNeg[1]=550; ElNeg[2]= 97; ElNeg[3]=147; ElNeg[4]=201; ElNeg[5]=250; ElNeg[6]=307; ElNeg[7]=350; ElNeg[8]=410; ElNeg[9]=480; ElNeg[10]=101;ElNeg[11]=123; ElNeg[12]=147;ElNeg[13]=174;ElNeg[14]=206;ElNeg[15]=244; ElNeg[16]=283;ElNeg[17]=320;ElNeg[18]= 91;ElNeg[19]=104; ElNeg[20]=120;ElNeg[21]=132;ElNeg[22]=145;ElNeg[23]=156; ElNeg[24]=160;ElNeg[25]=164;ElNeg[26]=170;ElNeg[27]=175; ElNeg[28]=175;ElNeg[29]=166;ElNeg[30]=182;ElNeg[31]=202; ElNeg[32]=220;ElNeg[33]=248;ElNeg[34]=274;ElNeg[35]=290; ElNeg[36]= 89;ElNeg[37]= 99;ElNeg[38]=111;ElNeg[39]=122; ElNeg[40]=123;ElNeg[41]=130;ElNeg[42]=136;ElNeg[43]=142; ElNeg[44]=145;ElNeg[45]=130;ElNeg[46]=142;ElNeg[47]=146; ElNeg[48]=149;ElNeg[49]=172;ElNeg[50]=182;ElNeg[51]=201; ElNeg[52]=221;ElNeg[53]=240;ElNeg[54]= 86;ElNeg[55]= 97; ElNeg[56]=108;ElNeg[57]=108;ElNeg[58]=107;ElNeg[59]=107; ElNeg[60]=107;ElNeg[61]=107;ElNeg[62]=110;ElNeg[63]=111; ElNeg[64]=110;ElNeg[65]=110;ElNeg[66]=110;ElNeg[67]=111; ElNeg[68]=111;ElNeg[69]=106;ElNeg[70]=114;ElNeg[71]=123; ElNeg[72]=133;ElNeg[73]=140;ElNeg[74]=146;ElNeg[75]=152; ElNeg[76]=155;ElNeg[77]=142;ElNeg[78]=142;ElNeg[79]=144; ElNeg[80]=144;ElNeg[81]=155;ElNeg[82]=167; */ for (int i=0; i<103; i++){ if (i<95) arad[i]=Kovalenz_Radien[i]/(250.0); else arad[i]=0.5; AtomStyle[i]=ATOM_STYLE_WALLS|ATOM_STYLE_RINGS|ATOM_STYLE_SPHERE; switch (i){ case 0://H AtomColor[i]=QColor(Qt::white).darker(20); break; case 2://Li AtomColor[i]=QColor(Qt::darkRed); AtomStyle[i]|=ATOM_STYLE_METAL; break; case 3://Be AtomColor[i]=QColor("silver"); AtomStyle[i]|=ATOM_STYLE_METAL; break; case 4://B AtomColor[i]=QColor(Qt::darkBlue); break; case 5://C AtomColor[i]=QColor("#242424"); AtomStyle[i]|=ATOM_STYLE_WHITERING; break; case 6://N AtomColor[i]=QColor(Qt::blue); AtomStyle[i]|=ATOM_STYLE_WHITERING; break; case 7://O AtomColor[i]=QColor(Qt::red); AtomStyle[i]|=ATOM_STYLE_WHITERING; break; case 8://F AtomColor[i]=QColor("chartreuse"); break; case 9://ne AtomColor[i]=QColor(192,192,192,128); AtomStyle[i]|=ATOM_STYLE_METAL; break; case 10://na AtomColor[i]=QColor(239,154,251,128); AtomStyle[i]|=ATOM_STYLE_METAL; break; case 11://mg AtomColor[i]=QColor(51,153,255,128); AtomStyle[i]|=ATOM_STYLE_METAL; break; case 12://al AtomColor[i]=QColor(102,179,255,128); break; case 13://si AtomColor[i]=QColor(128,128,128,128); break; case 14://p AtomColor[i]=QColor(183,41,244,128); break; case 15://s AtomColor[i]=QColor(190,190,0,128); break; case 16://cl AtomColor[i]=QColor( 65,111, 65,128); //printf("CL dots on\n"); //AtomStyle[i]|=ATOM_STYLE_METAL; break; case 18://k AtomColor[i]=QColor(192,46,180,128); AtomStyle[i]|=ATOM_STYLE_METAL; break; case 19://ca AtomColor[i]=QColor(170,170,128,128); AtomStyle[i]|=ATOM_STYLE_METAL; break; case 20: AtomColor[i]=QColor(236,136,171,128); AtomStyle[i]|=ATOM_STYLE_METAL; break; case 21: AtomColor[i]=QColor(242,59,3,128); AtomStyle[i]|=ATOM_STYLE_METAL; break; case 22: AtomColor[i]=QColor(100,128,0,128); AtomStyle[i]|=ATOM_STYLE_METAL; break; case 23: AtomColor[i]=QColor(255,255,0,128); AtomStyle[i]|=ATOM_STYLE_METAL; break; case 24: AtomColor[i]=QColor(204,153,153,128); AtomStyle[i]|=ATOM_STYLE_METAL; break; case 25: AtomColor[i]=QColor(0,162,0,128); AtomStyle[i]|=ATOM_STYLE_METAL; break; case 26: AtomColor[i]=QColor(109,0,109,128); AtomStyle[i]|=ATOM_STYLE_METAL; break; case 27: AtomColor[i]=QColor(170,82,64,128); AtomStyle[i]|=ATOM_STYLE_METAL; break; case 28://Cu AtomColor[i]=QColor("salmon"); AtomStyle[i]|=ATOM_STYLE_METAL; break; case 29: AtomColor[i]=QColor(63,123,111,128); AtomStyle[i]|=ATOM_STYLE_METAL; break; case 30: AtomColor[i]=QColor(78,254,208,128); AtomStyle[i]|=ATOM_STYLE_METAL; break; case 31: AtomColor[i]=QColor(136,136,136,128); AtomStyle[i]|=ATOM_STYLE_METAL; break; case 32: AtomColor[i]=QColor(191,218,255,128); break; case 33: AtomColor[i]=QColor(90,23,23,128); break; case 34: AtomColor[i]=QColor(222,188,133,128); break; case 35: AtomColor[i]=QColor(240,120,0,128); break; case 36: AtomColor[i]=QColor(50,15,0,128); AtomStyle[i]|=ATOM_STYLE_METAL; break; case 37: AtomColor[i]=QColor(192,192,192,128); AtomStyle[i]|=ATOM_STYLE_METAL; break; case 38: AtomColor[i]=QColor(204,113,32,128); AtomStyle[i]|=ATOM_STYLE_METAL; break; case 39: AtomColor[i]=QColor(236,97,59,128); AtomStyle[i]|=ATOM_STYLE_METAL; break; case 40: AtomColor[i]=QColor("silver"); AtomStyle[i]|=ATOM_STYLE_METAL; break; case 41: AtomColor[i]=QColor("silver"); AtomStyle[i]|=ATOM_STYLE_METAL; break; case 42: AtomColor[i]=QColor("silver"); AtomStyle[i]|=ATOM_STYLE_METAL; break; case 43: AtomColor[i]=QColor("silver"); AtomStyle[i]|=ATOM_STYLE_METAL; break; case 44: AtomColor[i]=QColor("silver"); AtomStyle[i]|=ATOM_STYLE_METAL; break; case 45: AtomColor[i]=QColor("silver"); AtomStyle[i]|=ATOM_STYLE_METAL; break; case 46: AtomColor[i]=QColor("silver"); AtomStyle[i]|=ATOM_STYLE_METAL; break; case 47: AtomColor[i]=QColor("silver"); AtomStyle[i]|=ATOM_STYLE_METAL; break; case 48: AtomColor[i]=QColor("silver"); AtomStyle[i]|=ATOM_STYLE_METAL; break; case 49: AtomColor[i]=QColor("silver"); AtomStyle[i]|=ATOM_STYLE_METAL; break; case 54: AtomColor[i]=QColor("silver"); AtomStyle[i]|=ATOM_STYLE_METAL; break; case 55: AtomColor[i]=QColor("silver"); AtomStyle[i]|=ATOM_STYLE_METAL; break; case 56: AtomColor[i]=QColor("silver"); AtomStyle[i]|=ATOM_STYLE_METAL; break; case 57: AtomColor[i]=QColor("silver"); AtomStyle[i]|=ATOM_STYLE_METAL; break; case 58: AtomColor[i]=QColor("silver"); AtomStyle[i]|=ATOM_STYLE_METAL; break; case 59: AtomColor[i]=QColor("silver"); AtomStyle[i]|=ATOM_STYLE_METAL; break; case 61: AtomColor[i]=QColor("silver"); AtomStyle[i]|=ATOM_STYLE_METAL; break; case 62: AtomColor[i]=QColor("silver"); AtomStyle[i]|=ATOM_STYLE_METAL; break; case 63: AtomColor[i]=QColor("silver"); AtomStyle[i]|=ATOM_STYLE_METAL; break; case 67: AtomColor[i]=QColor("silver"); AtomStyle[i]|=ATOM_STYLE_METAL; break; case 68: AtomColor[i]=QColor("silver"); AtomStyle[i]|=ATOM_STYLE_METAL; break; case 69: AtomColor[i]=QColor("silver"); AtomStyle[i]|=ATOM_STYLE_METAL; break; case 70: AtomColor[i]=QColor("silver"); AtomStyle[i]|=ATOM_STYLE_METAL; break; case 71: AtomColor[i]=QColor("silver"); AtomStyle[i]|=ATOM_STYLE_METAL; break; case 72: AtomColor[i]=QColor("silver"); AtomStyle[i]|=ATOM_STYLE_METAL; break; case 73: AtomColor[i]=QColor("silver"); AtomStyle[i]|=ATOM_STYLE_METAL; break; case 74: AtomColor[i]=QColor("silver"); AtomStyle[i]|=ATOM_STYLE_METAL; break; case 75: AtomColor[i]=QColor("silver"); AtomStyle[i]|=ATOM_STYLE_METAL; break; case 76: AtomColor[i]=QColor("silver"); AtomStyle[i]|=ATOM_STYLE_METAL; break; case 77: AtomColor[i]=QColor("silver"); AtomStyle[i]|=ATOM_STYLE_METAL; break; case 79: AtomStyle[i]|=ATOM_STYLE_METAL; AtomColor[i]=QColor("silver"); break; case 80: AtomStyle[i]|=ATOM_STYLE_METAL; AtomColor[i]=QColor("silver"); break; case 81: AtomStyle[i]|=ATOM_STYLE_METAL; AtomColor[i]=QColor("silver"); break; case 82: AtomColor[i]=QColor("silver"); AtomStyle[i]|=ATOM_STYLE_METAL; break; case 83: AtomColor[i]=QColor("silver"); AtomStyle[i]|=ATOM_STYLE_METAL; break; case 86: AtomStyle[i]|=ATOM_STYLE_METAL; AtomColor[i]=QColor("silver"); break; case 87: AtomColor[i]=QColor("silver"); AtomStyle[i]|=ATOM_STYLE_METAL; break; case 88: AtomColor[i]=QColor("silver"); AtomStyle[i]|=ATOM_STYLE_METAL; break; case 89: AtomColor[i]=QColor("silver"); AtomStyle[i]|=ATOM_STYLE_METAL; break; case 91: AtomColor[i]=QColor("silver"); AtomStyle[i]|=ATOM_STYLE_METAL; break; case 92: AtomColor[i]=QColor("silver"); AtomStyle[i]|=ATOM_STYLE_METAL; break; case 93: AtomColor[i]=QColor("silver"); AtomStyle[i]|=ATOM_STYLE_METAL; break; case 97: AtomColor[i]=QColor("silver"); AtomStyle[i]|=ATOM_STYLE_METAL; break; case 78://Au AtomColor[i]=QColor("goldenrod"); AtomStyle[i]|=ATOM_STYLE_METAL; break; default: AtomColor[i]=QColor("silver"); break; } AtomColor[i].setAlpha(63); } AtomStyle[0]=ATOM_STYLE_SPHERE|ATOM_STYLE_NOLABEL|ATOM_STYLE_NOADP; PSE<<"H"<<"He"<<"Li"<<"Be"<<"B"<<"C"<<"N"<<"O"<<"F"<<"Ne"<<"Na"<<"Mg"<<"Al"<<"Si"<<"P"<<"S"<<"Cl"<<"Ar"<< "K"<<"Ca"<<"Sc"<<"Ti"<<"V"<<"Cr"<<"Mn"<<"Fe"<<"Co"<<"Ni"<<"Cu"<<"Zn"<<"Ga"<<"Ge"<<"As"<<"Se"<<"Br"<<"Kr"<< "Rb"<<"Sr"<<"Y"<<"Zr"<<"Nb"<<"Mo"<<"Tc"<<"Ru"<<"Rh"<<"Pd"<<"Ag"<<"Cd"<<"In"<<"Sn"<<"Sb"<<"Te"<<"I"<<"Xe"<< "Cs"<<"Ba"<< "La"<<"Ce"<<"Pr"<<"Nd"<<"Pm"<<"Sm"<<"Eu"<<"Gd"<<"Tb"<<"Dy"<<"Ho"<<"Er"<<"Tm"<<"Yb"<<"Lu"<< "Hf"<<"Ta"<<"W"<<"Re"<<"Os"<<"Ir"<<"Pt"<<"Au"<<"Hg"<<"Tl"<<"Pb"<<"Bi"<<"Po"<<"At"<<"Rn"<<"Fr"<<"Ra"<< "Ac"<<"Th"<<"Pa"<<"U"<<"Np"<<"Pu"<<"Am"<<"Cm"<<"Bk"<<"Cf"<<"Es"<<"Fm"<<"Md"<<"No"<<"Lr";//no need of these I guess--> <<"Ku"<<"Ha"<<"Rf"<<"Ns"<<"Hs"<<"Mt"; } QColor Molecule::atomColor(int an, bool isD){ if ((an == 0) && (isD)) { //printf("D has %s\n",deuteriumColor.name().toStdString().c_str()); return deuteriumColor; } return AtomColor[an]; } int Molecule::afix5(int idx){ int f5 = 0,m,cnt = 0,aafx=-1; if (showatoms.at(idx).afix==0) return 0; // printf("AFIXm5 %d (%s)\n",showatoms.at(idx).afix,showatoms.at(idx).Label.toStdString().c_str()); for (int i = 0; (i <= idx) && (i < showatoms.size()); i++){ if (showatoms.at(i).an > 0){ if (aafx != showatoms.at(i).afix) cnt = 0;// afix is different than before => reset the counter aafx = showatoms.at(i).afix; m = showatoms.at(i).afix / 10; switch (m) { case 0://afix 6 afix 9 //printf("ehm m is zero?\n"); f5=5; break; case 6://66 for phenyl rings cnt++; f5 = (cnt % 6)? m * 10 + 5: 0; // printf("cnt%d %s\n",cnt,showatoms.at(i).Label.toStdString().c_str()); break; case 5://56 planar regular 5 membered ring (cp) cnt++; f5 = (cnt % 5)? m * 10 + 5: 0; break; case 10://cp* cnt++; f5 = (cnt % 10)? m * 10 + 5: 0; break; case 11://naphtyl cnt++; f5 = (cnt % 10)? m * 10 + 5: 0; break; } } } // printf("==> %d aafx%d m%d cnt%d idx%d %s\n",f5,aafx,m,cnt,idx,showatoms.at(idx).Label.toStdString().c_str()); return f5; } QString Molecule::nameSymmOp(Matrix m,int &fld,V3 &axis){ QList so; so<< Matrix( 1, 0, 0, 0, 1, 0, 0, 0, 1)<axn; axn<< V3( 0, 0, 0)<-1) { fld=fold[i]; axis=axn[i]; return n.at(i); } fld=0; axis=V3(0,0,0); return QString("none"); } int Molecule::afix5(const CEnvironment &atm, int idx){ int f5 = 0,m,cnt = 0,aafx=-1; if (atm.at(idx).afix==0) return 0; // printf("AFIXm5 %d (%s)\n",showatoms.at(idx).afix,showatoms.at(idx).Label.toStdString().c_str()); for (int i = 0; (i <= idx) && (i < atm.size()); i++){ if (atm.at(i).an > 0){ if (aafx != atm.at(i).afix) cnt = 0;// afix is different than before => reset the counter aafx = atm.at(i).afix; m = atm.at(i).afix / 10; switch (m) { case 0://afix 6 afix 9 //printf("ehm m is zero?\n"); f5=5; break; case 6://66 for phenyl rings cnt++; f5 = (cnt % 6)? m * 10 + 5: 0; // printf("cnt%d %s\n",cnt,showatoms.at(i).Label.toStdString().c_str()); break; case 5://56 planar regular 5 membered ring (cp) cnt++; f5 = (cnt % 5)? m * 10 + 5: 0; break; case 10://cp* cnt++; f5 = (cnt % 10)? m * 10 + 5: 0; break; case 11://naphtyl cnt++; f5 = (cnt % 10)? m * 10 + 5: 0; break; } } } // printf("==> %d aafx%d m%d cnt%d idx%d %s\n",f5,aafx,m,cnt,idx,showatoms.at(idx).Label.toStdString().c_str()); return f5; } Matrix Molecule::rotarb(double *arr){ double phi=arr[0]/180*M_PI; double c=cos(phi); double s=sin(phi); double omc=1-c; Matrix m(c+arr[1]*arr[1]*omc,arr[1]*arr[2]*omc-s*arr[3],arr[1]*arr[3]*omc+s*arr[2], arr[1]*arr[2]*omc+s*arr[3],c+arr[2]*arr[2]*omc,arr[2]*arr[3]*omc-s*arr[1], arr[1]*arr[3]*omc-s*arr[2],arr[2]*arr[3]*omc+s*arr[1],c+arr[3]*arr[3]*omc); return m; } Matrix Molecule::rotarb(double angle, V3 &arr){ double phi=angle/180*M_PI; double c=cos(phi); double s=sin(phi); double omc=1-c; Matrix m(c+arr.x*arr.x*omc,arr.x*arr.y*omc-s*arr.z,arr.x*arr.z*omc+s*arr.y, arr.x*arr.y*omc+s*arr.z,c+arr.y*arr.y*omc,arr.y*arr.z*omc-s*arr.x, arr.x*arr.z*omc-s*arr.y,arr.y*arr.z*omc+s*arr.x,c+arr.z*arr.z*omc); return m; } void Molecule::rotarb(Matrix &mat, double angle, V3 &arr){ double phi=angle/180*M_PI; double c=cos(phi); double s=sin(phi); double omc=1-c; Matrix oma=mat; mat.m11= c + arr.x * arr.x * omc; mat.m12= arr.x * arr.y * omc - s * arr.z; mat.m13= arr.x * arr.z * omc + s * arr.y; mat.m21= arr.y * arr.x * omc + s * arr.z; mat.m22= c + arr.y * arr.y * omc; mat.m23= arr.y * arr.z * omc - s * arr.x; mat.m31= arr.z * arr.x * omc - s * arr.y; mat.m32= arr.z * arr.y * omc + s * arr.x; mat.m33= c + arr.z * arr.z * omc; mat=mat*oma; } void Molecule::exportOBJ(QString fileName,const CEnvironment &_atoms, const Connection &_bonds){ const GLuint idx2[960] = { 1, 42, 44,// 0 0.275904 0.321244 0.275904 42, 12, 43,// 1 0.275904 0.312869 0.285473 43, 14, 44,// 2 0.312869 0.275904 0.285473 42, 43, 44,// 3 0.285473 0.285473 0.321244 12, 45, 47,// 4 0.275904 0.285473 0.312869 45, 0, 46,// 5 0.275904 0.275904 0.321244 46, 13, 47,// 6 0.275904 0.312869 0.285473 45, 46, 47,// 7 0.321244 0.285473 0.285473 13, 48, 50,// 8 0.275904 0.285473 0.312869 48, 5, 49,// 9 0.275904 0.275904 0.321244 49, 14, 50,// 10 0.275904 0.312869 0.285473 48, 49, 50,// 11 0.321244 0.285473 0.285473 12, 47, 43,// 12 0.312869 0.324920 0.312869 47, 13, 50,// 13 0.312869 0.312869 0.324920 50, 14, 43,// 14 0.312869 0.312869 0.324920 47, 50, 43,// 15 0.324920 0.324920 0.324920 0, 45, 52,// 16 0.275904 0.321244 0.275904 45, 12, 51,// 17 0.275904 0.312869 0.285473 51, 16, 52,// 18 0.312869 0.275904 0.285473 45, 51, 52,// 19 0.285473 0.285473 0.321244 12, 42, 54,// 20 0.275904 0.285473 0.312869 42, 1, 53,// 21 0.275904 0.275904 0.321244 53, 15, 54,// 22 0.275904 0.312869 0.285473 42, 53, 54,// 23 0.321244 0.285473 0.285473 15, 55, 57,// 24 0.275904 0.285473 0.312869 55, 7, 56,// 25 0.275904 0.275904 0.321244 56, 16, 57,// 26 0.275904 0.312869 0.285473 55, 56, 57,// 27 0.321244 0.285473 0.285473 12, 54, 51,// 28 0.312869 0.324920 0.312869 54, 15, 57,// 29 0.312869 0.312869 0.324920 57, 16, 51,// 30 0.312869 0.312869 0.324920 54, 57, 51,// 31 0.324920 0.324920 0.324920 10, 58, 60,// 32 0.275904 0.321244 0.275904 58, 17, 59,// 33 0.275904 0.312869 0.285473 59, 18, 60,// 34 0.312869 0.275904 0.285473 58, 59, 60,// 35 0.285473 0.285473 0.321244 17, 61, 62,// 36 0.275904 0.285473 0.312869 61, 0, 52,// 37 0.275904 0.275904 0.321244 52, 16, 62,// 38 0.275904 0.312869 0.285473 61, 52, 62,// 39 0.321244 0.285473 0.285473 16, 56, 64,// 40 0.275904 0.285473 0.312869 56, 7, 63,// 41 0.275904 0.275904 0.321244 63, 18, 64,// 42 0.275904 0.312869 0.285473 56, 63, 64,// 43 0.321244 0.285473 0.285473 17, 62, 59,// 44 0.312869 0.324920 0.312869 62, 16, 64,// 45 0.312869 0.312869 0.324920 64, 18, 59,// 46 0.312869 0.312869 0.324920 62, 64, 59,// 47 0.324920 0.324920 0.324920 0, 61, 66,// 48 0.275904 0.321244 0.275904 61, 17, 65,// 49 0.275904 0.312869 0.285473 65, 20, 66,// 50 0.312869 0.275904 0.285473 61, 65, 66,// 51 0.285473 0.285473 0.321244 17, 58, 68,// 52 0.275904 0.285473 0.312869 58, 10, 67,// 53 0.275904 0.275904 0.321244 67, 19, 68,// 54 0.275904 0.312869 0.285473 58, 67, 68,// 55 0.321244 0.285473 0.285473 19, 69, 71,// 56 0.275904 0.285473 0.312869 69, 11, 70,// 57 0.275904 0.275904 0.321244 70, 20, 71,// 58 0.275904 0.312869 0.285473 69, 70, 71,// 59 0.321244 0.285473 0.285473 17, 68, 65,// 60 0.312869 0.324920 0.312869 68, 19, 71,// 61 0.312869 0.312869 0.324920 71, 20, 65,// 62 0.312869 0.312869 0.324920 68, 71, 65,// 63 0.324920 0.324920 0.324920 11, 72, 70,// 64 0.275904 0.321244 0.275904 72, 21, 73,// 65 0.275904 0.312869 0.285473 73, 20, 70,// 66 0.312869 0.275904 0.285473 72, 73, 70,// 67 0.285473 0.285473 0.321244 21, 74, 75,// 68 0.275904 0.285473 0.312869 74, 5, 48,// 69 0.275904 0.275904 0.321244 48, 13, 75,// 70 0.275904 0.312869 0.285473 74, 48, 75,// 71 0.321244 0.285473 0.285473 13, 46, 76,// 72 0.275904 0.285473 0.312869 46, 0, 66,// 73 0.275904 0.275904 0.321244 66, 20, 76,// 74 0.275904 0.312869 0.285473 46, 66, 76,// 75 0.321244 0.285473 0.285473 21, 75, 73,// 76 0.312869 0.324920 0.312869 75, 13, 76,// 77 0.312869 0.312869 0.324920 76, 20, 73,// 78 0.312869 0.312869 0.324920 75, 76, 73,// 79 0.324920 0.324920 0.324920 5, 74, 78,// 80 0.275904 0.321244 0.275904 74, 21, 77,// 81 0.275904 0.312869 0.285473 77, 23, 78,// 82 0.312869 0.275904 0.285473 74, 77, 78,// 83 0.285473 0.285473 0.321244 21, 72, 80,// 84 0.275904 0.285473 0.312869 72, 11, 79,// 85 0.275904 0.275904 0.321244 79, 22, 80,// 86 0.275904 0.312869 0.285473 72, 79, 80,// 87 0.321244 0.285473 0.285473 22, 81, 83,// 88 0.275904 0.285473 0.312869 81, 4, 82,// 89 0.275904 0.275904 0.321244 82, 23, 83,// 90 0.275904 0.312869 0.285473 81, 82, 83,// 91 0.321244 0.285473 0.285473 21, 80, 77,// 92 0.312869 0.324920 0.312869 80, 22, 83,// 93 0.312869 0.312869 0.324920 83, 23, 77,// 94 0.312869 0.312869 0.324920 80, 83, 77,// 95 0.324920 0.324920 0.324920 2, 84, 86,// 96 0.275904 0.321244 0.275904 84, 24, 85,// 97 0.275904 0.312869 0.285473 85, 25, 86,// 98 0.312869 0.275904 0.285473 84, 85, 86,// 99 0.285473 0.285473 0.321244 24, 87, 88,//100 0.275904 0.285473 0.312869 87, 11, 69,//101 0.275904 0.275904 0.321244 69, 19, 88,//102 0.275904 0.312869 0.285473 87, 69, 88,//103 0.321244 0.285473 0.285473 19, 67, 90,//104 0.275904 0.285473 0.312869 67, 10, 89,//105 0.275904 0.275904 0.321244 89, 25, 90,//106 0.275904 0.312869 0.285473 67, 89, 90,//107 0.321244 0.285473 0.285473 24, 88, 85,//108 0.312869 0.324920 0.312869 88, 19, 90,//109 0.312869 0.312869 0.324920 90, 25, 85,//110 0.312869 0.312869 0.324920 88, 90, 85,//111 0.324920 0.324920 0.324920 11, 87, 79,//112 0.275904 0.321244 0.275904 87, 24, 91,//113 0.275904 0.312869 0.285473 91, 22, 79,//114 0.312869 0.275904 0.285473 87, 91, 79,//115 0.285473 0.285473 0.321244 24, 84, 93,//116 0.275904 0.285473 0.312869 84, 2, 92,//117 0.275904 0.275904 0.321244 92, 26, 93,//118 0.275904 0.312869 0.285473 84, 92, 93,//119 0.321244 0.285473 0.285473 26, 94, 95,//120 0.275904 0.285473 0.312869 94, 4, 81,//121 0.275904 0.275904 0.321244 81, 22, 95,//122 0.275904 0.312869 0.285473 94, 81, 95,//123 0.321244 0.285473 0.285473 24, 93, 91,//124 0.312869 0.324920 0.312869 93, 26, 95,//125 0.312869 0.312869 0.324920 95, 22, 91,//126 0.312869 0.312869 0.324920 93, 95, 91,//127 0.324920 0.324920 0.324920 10, 96, 89,//128 0.275904 0.321244 0.275904 96, 27, 97,//129 0.275904 0.312869 0.285473 97, 25, 89,//130 0.312869 0.275904 0.285473 96, 97, 89,//131 0.285473 0.285473 0.321244 27, 98, 100,//132 0.275904 0.285473 0.312869 98, 6, 99,//133 0.275904 0.275904 0.321244 99, 28, 100,//134 0.275904 0.312869 0.285473 98, 99, 100,//135 0.321244 0.285473 0.285473 28, 101, 102,//136 0.275904 0.285473 0.312869 101, 2, 86,//137 0.275904 0.275904 0.321244 86, 25, 102,//138 0.275904 0.312869 0.285473 101, 86, 102,//139 0.321244 0.285473 0.285473 27, 100, 97,//140 0.312869 0.324920 0.312869 100, 28, 102,//141 0.312869 0.312869 0.324920 102, 25, 97,//142 0.312869 0.312869 0.324920 100, 102, 97,//143 0.324920 0.324920 0.324920 6, 98, 104,//144 0.275904 0.321244 0.275904 98, 27, 103,//145 0.275904 0.312869 0.285473 103, 29, 104,//146 0.312869 0.275904 0.285473 98, 103, 104,//147 0.285473 0.285473 0.321244 27, 96, 105,//148 0.275904 0.285473 0.312869 96, 10, 60,//149 0.275904 0.275904 0.321244 60, 18, 105,//150 0.275904 0.312869 0.285473 96, 60, 105,//151 0.321244 0.285473 0.285473 18, 63, 107,//152 0.275904 0.285473 0.312869 63, 7, 106,//153 0.275904 0.275904 0.321244 106, 29, 107,//154 0.275904 0.312869 0.285473 63, 106, 107,//155 0.321244 0.285473 0.285473 27, 105, 103,//156 0.312869 0.324920 0.312869 105, 18, 107,//157 0.312869 0.312869 0.324920 107, 29, 103,//158 0.312869 0.312869 0.324920 105, 107, 103,//159 0.324920 0.324920 0.324920 7, 108, 106,//160 0.275904 0.321244 0.275904 108, 30, 109,//161 0.275904 0.312869 0.285473 109, 29, 106,//162 0.312869 0.275904 0.285473 108, 109, 106,//163 0.285473 0.285473 0.321244 30, 110, 112,//164 0.275904 0.285473 0.312869 110, 8, 111,//165 0.275904 0.275904 0.321244 111, 31, 112,//166 0.275904 0.312869 0.285473 110, 111, 112,//167 0.321244 0.285473 0.285473 31, 113, 114,//168 0.275904 0.285473 0.312869 113, 6, 104,//169 0.275904 0.275904 0.321244 104, 29, 114,//170 0.275904 0.312869 0.285473 113, 104, 114,//171 0.321244 0.285473 0.285473 30, 112, 109,//172 0.312869 0.324920 0.312869 112, 31, 114,//173 0.312869 0.312869 0.324920 114, 29, 109,//174 0.312869 0.312869 0.324920 112, 114, 109,//175 0.324920 0.324920 0.324920 8, 110, 116,//176 0.275904 0.321244 0.275904 110, 30, 115,//177 0.275904 0.312869 0.285473 115, 32, 116,//178 0.312869 0.275904 0.285473 110, 115, 116,//179 0.285473 0.285473 0.321244 30, 108, 117,//180 0.275904 0.285473 0.312869 108, 7, 55,//181 0.275904 0.275904 0.321244 55, 15, 117,//182 0.275904 0.312869 0.285473 108, 55, 117,//183 0.321244 0.285473 0.285473 15, 53, 119,//184 0.275904 0.285473 0.312869 53, 1, 118,//185 0.275904 0.275904 0.321244 118, 32, 119,//186 0.275904 0.312869 0.285473 53, 118, 119,//187 0.321244 0.285473 0.285473 30, 117, 115,//188 0.312869 0.324920 0.312869 117, 15, 119,//189 0.312869 0.312869 0.324920 119, 32, 115,//190 0.312869 0.312869 0.324920 117, 119, 115,//191 0.324920 0.324920 0.324920 9, 120, 122,//192 0.275904 0.321244 0.275904 120, 33, 121,//193 0.275904 0.312869 0.285473 121, 34, 122,//194 0.312869 0.275904 0.285473 120, 121, 122,//195 0.285473 0.285473 0.321244 33, 123, 124,//196 0.275904 0.285473 0.312869 123, 1, 44,//197 0.275904 0.275904 0.321244 44, 14, 124,//198 0.275904 0.312869 0.285473 123, 44, 124,//199 0.321244 0.285473 0.285473 14, 49, 126,//200 0.275904 0.285473 0.312869 49, 5, 125,//201 0.275904 0.275904 0.321244 125, 34, 126,//202 0.275904 0.312869 0.285473 49, 125, 126,//203 0.321244 0.285473 0.285473 33, 124, 121,//204 0.312869 0.324920 0.312869 124, 14, 126,//205 0.312869 0.312869 0.324920 126, 34, 121,//206 0.312869 0.312869 0.324920 124, 126, 121,//207 0.324920 0.324920 0.324920 1, 123, 118,//208 0.275904 0.321244 0.275904 123, 33, 127,//209 0.275904 0.312869 0.285473 127, 32, 118,//210 0.312869 0.275904 0.285473 123, 127, 118,//211 0.285473 0.285473 0.321244 33, 120, 129,//212 0.275904 0.285473 0.312869 120, 9, 128,//213 0.275904 0.275904 0.321244 128, 35, 129,//214 0.275904 0.312869 0.285473 120, 128, 129,//215 0.321244 0.285473 0.285473 35, 130, 131,//216 0.275904 0.285473 0.312869 130, 8, 116,//217 0.275904 0.275904 0.321244 116, 32, 131,//218 0.275904 0.312869 0.285473 130, 116, 131,//219 0.321244 0.285473 0.285473 33, 129, 127,//220 0.312869 0.324920 0.312869 129, 35, 131,//221 0.312869 0.312869 0.324920 131, 32, 127,//222 0.312869 0.312869 0.324920 129, 131, 127,//223 0.324920 0.324920 0.324920 4, 132, 82,//224 0.275904 0.321244 0.275904 132, 36, 133,//225 0.275904 0.312869 0.285473 133, 23, 82,//226 0.312869 0.275904 0.285473 132, 133, 82,//227 0.285473 0.285473 0.321244 36, 134, 135,//228 0.275904 0.285473 0.312869 134, 9, 122,//229 0.275904 0.275904 0.321244 122, 34, 135,//230 0.275904 0.312869 0.285473 134, 122, 135,//231 0.321244 0.285473 0.285473 34, 125, 136,//232 0.275904 0.285473 0.312869 125, 5, 78,//233 0.275904 0.275904 0.321244 78, 23, 136,//234 0.275904 0.312869 0.285473 125, 78, 136,//235 0.321244 0.285473 0.285473 36, 135, 133,//236 0.312869 0.324920 0.312869 135, 34, 136,//237 0.312869 0.312869 0.324920 136, 23, 133,//238 0.312869 0.312869 0.324920 135, 136, 133,//239 0.324920 0.324920 0.324920 9, 134, 138,//240 0.275904 0.321244 0.275904 134, 36, 137,//241 0.275904 0.312869 0.285473 137, 38, 138,//242 0.312869 0.275904 0.285473 134, 137, 138,//243 0.285473 0.285473 0.321244 36, 132, 140,//244 0.275904 0.285473 0.312869 132, 4, 139,//245 0.275904 0.275904 0.321244 139, 37, 140,//246 0.275904 0.312869 0.285473 132, 139, 140,//247 0.321244 0.285473 0.285473 37, 141, 143,//248 0.275904 0.285473 0.312869 141, 3, 142,//249 0.275904 0.275904 0.321244 142, 38, 143,//250 0.275904 0.312869 0.285473 141, 142, 143,//251 0.321244 0.285473 0.285473 36, 140, 137,//252 0.312869 0.324920 0.312869 140, 37, 143,//253 0.312869 0.312869 0.324920 143, 38, 137,//254 0.312869 0.312869 0.324920 140, 143, 137,//255 0.324920 0.324920 0.324920 3, 144, 142,//256 0.275904 0.321244 0.275904 144, 39, 145,//257 0.275904 0.312869 0.285473 145, 38, 142,//258 0.312869 0.275904 0.285473 144, 145, 142,//259 0.285473 0.285473 0.321244 39, 146, 147,//260 0.275904 0.285473 0.312869 146, 8, 130,//261 0.275904 0.275904 0.321244 130, 35, 147,//262 0.275904 0.312869 0.285473 146, 130, 147,//263 0.321244 0.285473 0.285473 35, 128, 148,//264 0.275904 0.285473 0.312869 128, 9, 138,//265 0.275904 0.275904 0.321244 138, 38, 148,//266 0.275904 0.312869 0.285473 128, 138, 148,//267 0.321244 0.285473 0.285473 39, 147, 145,//268 0.312869 0.324920 0.312869 147, 35, 148,//269 0.312869 0.312869 0.324920 148, 38, 145,//270 0.312869 0.312869 0.324920 147, 148, 145,//271 0.324920 0.324920 0.324920 8, 146, 111,//272 0.275904 0.321244 0.275904 146, 39, 149,//273 0.275904 0.312869 0.285473 149, 31, 111,//274 0.312869 0.275904 0.285473 146, 149, 111,//275 0.285473 0.285473 0.321244 39, 144, 151,//276 0.275904 0.285473 0.312869 144, 3, 150,//277 0.275904 0.275904 0.321244 150, 40, 151,//278 0.275904 0.312869 0.285473 144, 150, 151,//279 0.321244 0.285473 0.285473 40, 152, 153,//280 0.275904 0.285473 0.312869 152, 6, 113,//281 0.275904 0.275904 0.321244 113, 31, 153,//282 0.275904 0.312869 0.285473 152, 113, 153,//283 0.321244 0.285473 0.285473 39, 151, 149,//284 0.312869 0.324920 0.312869 151, 40, 153,//285 0.312869 0.312869 0.324920 153, 31, 149,//286 0.312869 0.312869 0.324920 151, 153, 149,//287 0.324920 0.324920 0.324920 3, 154, 150,//288 0.275904 0.321244 0.275904 154, 41, 155,//289 0.275904 0.312869 0.285473 155, 40, 150,//290 0.312869 0.275904 0.285473 154, 155, 150,//291 0.285473 0.285473 0.321244 41, 156, 157,//292 0.275904 0.285473 0.312869 156, 2, 101,//293 0.275904 0.275904 0.321244 101, 28, 157,//294 0.275904 0.312869 0.285473 156, 101, 157,//295 0.321244 0.285473 0.285473 28, 99, 158,//296 0.275904 0.285473 0.312869 99, 6, 152,//297 0.275904 0.275904 0.321244 152, 40, 158,//298 0.275904 0.312869 0.285473 99, 152, 158,//299 0.321244 0.285473 0.285473 41, 157, 155,//300 0.312869 0.324920 0.312869 157, 28, 158,//301 0.312869 0.312869 0.324920 158, 40, 155,//302 0.312869 0.312869 0.324920 157, 158, 155,//303 0.324920 0.324920 0.324920 2, 156, 92,//304 0.275904 0.321244 0.275904 156, 41, 159,//305 0.275904 0.312869 0.285473 159, 26, 92,//306 0.312869 0.275904 0.285473 156, 159, 92,//307 0.285473 0.285473 0.321244 41, 154, 160,//308 0.275904 0.285473 0.312869 154, 3, 141,//309 0.275904 0.275904 0.321244 141, 37, 160,//310 0.275904 0.312869 0.285473 154, 141, 160,//311 0.321244 0.285473 0.285473 37, 139, 161,//312 0.275904 0.285473 0.312869 139, 4, 94,//313 0.275904 0.275904 0.321244 94, 26, 161,//314 0.275904 0.312869 0.285473 139, 94, 161,//315 0.321244 0.285473 0.285473 41, 160, 159,//316 0.312869 0.324920 0.312869 160, 37, 161,//317 0.312869 0.312869 0.324920 161, 26, 159,//318 0.312869 0.312869 0.324920 160, 161, 159 //319 0.324920 0.324920 0.324920 }; const GLuint idxc[60] = { 0, 20, 2, 2, 20, 22, 2, 22, 4, 4, 22, 24, 4, 24, 6, 6, 24, 26, 6, 26, 8, 8, 26, 28, 8, 28, 10, 10, 28, 30, 10, 30, 12, 12, 30, 32, 12, 32, 14, 14, 32, 34, 14, 34, 16, 16, 34, 36, 16, 36, 18, 18, 36, 38, 18, 38, 0, 0, 38, 20, }; const GLfloat vc[120] = { 1.000000000f, 0.000000000f, 0.000000000f,//0 0.951056516f, 0.309016994f, 0.000000000f,//18 0.809016994f, 0.587785252f, 0.000000000f,//36 0.587785252f, 0.809016994f, 0.000000000f,//54 0.309016994f, 0.951056516f, 0.000000000f,//72 0.000000000f, 1.000000000f, 0.000000000f,//90 -0.309016994f, 0.951056516f, 0.000000000f,//108 -0.587785252f, 0.809016994f, 0.000000000f,//126 -0.809016994f, 0.587785252f, 0.000000000f,//144 -0.951056516f, 0.309016994f, 0.000000000f,//162 -1.000000000f, 0.000000000f, 0.000000000f,//180 -0.951056516f,-0.309016994f, 0.000000000f,//198 -0.809016994f,-0.587785252f, 0.000000000f,//216 -0.587785252f,-0.809016994f, 0.000000000f,//234 -0.309016994f,-0.951056516f, 0.000000000f,//252 -0.000000000f,-1.000000000f, 0.000000000f,//270 0.309016994f,-0.951056516f, 0.000000000f,//288 0.587785252f,-0.809016994f, 0.000000000f,//306 0.809016994f,-0.587785252f, 0.000000000f,//324 0.951056516f,-0.309016994f, 0.000000000f,//342 1.000000000f, 0.000000000f, 1.000000000f,//0 0.951056516f, 0.309016994f, 1.000000000f,//18 0.809016994f, 0.587785252f, 1.000000000f,//36 0.587785252f, 0.809016994f, 1.000000000f,//54 0.309016994f, 0.951056516f, 1.000000000f,//72 0.000000000f, 1.000000000f, 1.000000000f,//90 -0.309016994f, 0.951056516f, 1.000000000f,//108 -0.587785252f, 0.809016994f, 1.000000000f,//126 -0.809016994f, 0.587785252f, 1.000000000f,//144 -0.951056516f, 0.309016994f, 1.000000000f,//162 -1.000000000f, 0.000000000f, 1.000000000f,//180 -0.951056516f,-0.309016994f, 1.000000000f,//198 -0.809016994f,-0.587785252f, 1.000000000f,//216 -0.587785252f,-0.809016994f, 1.000000000f,//234 -0.309016994f,-0.951056516f, 1.000000000f,//252 -0.000000000f,-1.000000000f, 1.000000000f,//270 0.309016994f,-0.951056516f, 1.000000000f,//288 0.587785252f,-0.809016994f, 1.000000000f,//306 0.809016994f,-0.587785252f, 1.000000000f,//324 0.951056516f,-0.309016994f, 1.000000000f//342 }; /* const GLfloat nc[120] = { -1.000000000f,-0.000000000f, 0.000000000f,//0 -0.951056516f,-0.309016994f, 0.000000000f,//18 -0.809016994f,-0.587785252f, 0.000000000f,//36 -0.587785252f,-0.809016994f, 0.000000000f,//54 -0.309016994f,-0.951056516f, 0.000000000f,//72 0.000000000f,-1.000000000f, 0.000000000f,//90 0.309016994f,-0.951056516f, 0.000000000f,//108 0.587785252f,-0.809016994f, 0.000000000f,//126 0.809016994f,-0.587785252f, 0.000000000f,//144 0.951056516f,-0.309016994f, 0.000000000f,//162 1.000000000f, 0.000000000f, 0.000000000f,//180 0.951056516f, 0.309016994f, 0.000000000f,//198 0.809016994f, 0.587785252f, 0.000000000f,//216 0.587785252f, 0.809016994f, 0.000000000f,//234 0.309016994f, 0.951056516f, 0.000000000f,//252 0.000000000f, 1.000000000f, 0.000000000f,//270 -0.309016994f, 0.951056516f, 0.000000000f,//288 -0.587785252f, 0.809016994f, 0.000000000f,//306 -0.809016994f, 0.587785252f, 0.000000000f,//324 -0.951056516f, 0.309016994f, 0.000000000f,//342 -1.000000000f, 0.000000000f, 0.000000000f,//0 -0.951056516f,-0.309016994f, 0.000000000f,//18 -0.809016994f,-0.587785252f, 0.000000000f,//36 -0.587785252f,-0.809016994f, 0.000000000f,//54 -0.309016994f,-0.951056516f, 0.000000000f,//72 0.000000000f,-1.000000000f, 0.000000000f,//90 0.309016994f,-0.951056516f, 0.000000000f,//108 0.587785252f,-0.809016994f, 0.000000000f,//126 0.809016994f,-0.587785252f, 0.000000000f,//144 0.951056516f,-0.309016994f, 0.000000000f,//162 1.000000000f, 0.000000000f, 0.000000000f,//180 0.951056516f, 0.309016994f, 0.000000000f,//198 0.809016994f, 0.587785252f, 0.000000000f,//216 0.587785252f, 0.809016994f, 0.000000000f,//234 0.309016994f, 0.951056516f, 0.000000000f,//252 0.000000000f, 1.000000000f, 0.000000000f,//270 -0.309016994f, 0.951056516f, 0.000000000f,//288 -0.587785252f, 0.809016994f, 0.000000000f,//306 -0.809016994f, 0.587785252f, 0.000000000f,//324 -0.951056516f, 0.309016994f, 0.000000000f//342 }; */ const GLfloat vs[486] ={ //v[1926] = { -0.525731f, 0.850651f, 0.000000f,//0 0.525731f, 0.850651f, 0.000000f,//1 -0.525731f, -0.850651f, 0.000000f,//2 0.525731f, -0.850651f, 0.000000f,//3 0.000000f, -0.525731f, 0.850651f,//4 0.000000f, 0.525731f, 0.850651f,//5 0.000000f, -0.525731f, -0.850651f,//6 0.000000f, 0.525731f, -0.850651f,//7 0.850651f, 0.000000f, -0.525731f,//8 0.850651f, 0.000000f, 0.525731f,//9 -0.850651f, 0.000000f, -0.525731f,//10 -0.850651f, 0.000000f, 0.525731f,//11 0.000000f, 1.000000f, 0.000000f,//12 -0.309017f, 0.809017f, 0.500000f,//13 0.309017f, 0.809017f, 0.500000f,//14 0.309017f, 0.809017f, -0.500000f,//15 -0.309017f, 0.809017f, -0.500000f,//16 -0.809017f, 0.500000f, -0.309017f,//17 -0.500000f, 0.309017f, -0.809017f,//18 -1.000000f, 0.000000f, 0.000000f,//19 -0.809017f, 0.500000f, 0.309017f,//20 -0.500000f, 0.309017f, 0.809017f,//21 -0.500000f, -0.309017f, 0.809017f,//22 0.000000f, 0.000000f, 1.000000f,//23 -0.809017f, -0.500000f, 0.309017f,//24 -0.809017f, -0.500000f, -0.309017f,//25 -0.309017f, -0.809017f, 0.500000f,//26 -0.500000f, -0.309017f, -0.809017f,//27 -0.309017f, -0.809017f, -0.500000f,//28 0.000000f, 0.000000f, -1.000000f,//29 0.500000f, 0.309017f, -0.809017f,//30 0.500000f, -0.309017f, -0.809017f,//31 0.809017f, 0.500000f, -0.309017f,//32 0.809017f, 0.500000f, 0.309017f,//33 0.500000f, 0.309017f, 0.809017f,//34 1.000000f, 0.000000f, 0.000000f,//35 0.500000f, -0.309017f, 0.809017f,//36 0.309017f, -0.809017f, 0.500000f,//37 0.809017f, -0.500000f, 0.309017f,//38 0.809017f, -0.500000f, -0.309017f,//39 0.309017f, -0.809017f, -0.500000f,//40 0.000000f, -1.000000f, 0.000000f,//41 0.273267f, 0.961938f, 0.000000f,//42 0.162460f, 0.951057f, 0.262866f,//43 0.433889f, 0.862668f, 0.259892f,//44 -0.273267f, 0.961938f, 0.000000f,//45 -0.433889f, 0.862668f, 0.259892f,//46 -0.162460f, 0.951057f, 0.262866f,//47 -0.160622f, 0.693780f, 0.702046f,//48 0.160622f, 0.693780f, 0.702046f,//49 0.000000f, 0.850651f, 0.525731f,//50 -0.162460f, 0.951057f, -0.262866f,//51 -0.433889f, 0.862668f, -0.259892f,//52 0.433889f, 0.862668f, -0.259892f,//53 0.162460f, 0.951057f, -0.262866f,//54 0.160622f, 0.693780f, -0.702046f,//55 -0.160622f, 0.693780f, -0.702046f,//56 0.000000f, 0.850651f, -0.525731f,//57 -0.862668f, 0.259892f, -0.433889f,//58 -0.688191f, 0.425325f, -0.587785f,//59 -0.702046f, 0.160622f, -0.693780f,//60 -0.693780f, 0.702046f, -0.160622f,//61 -0.587785f, 0.688191f, -0.425325f,//62 -0.259892f, 0.433889f, -0.862668f,//63 -0.425325f, 0.587785f, -0.688191f,//64 -0.850651f, 0.525731f, 0.000000f,//65 -0.693780f, 0.702046f, 0.160622f,//66 -0.961938f, 0.000000f, -0.273267f,//67 -0.951057f, 0.262866f, -0.162460f,//68 -0.961938f, 0.000000f, 0.273267f,//69 -0.862668f, 0.259892f, 0.433889f,//70 -0.951057f, 0.262866f, 0.162460f,//71 -0.702046f, 0.160622f, 0.693780f,//72 -0.688191f, 0.425325f, 0.587785f,//73 -0.259892f, 0.433889f, 0.862668f,//74 -0.425325f, 0.587785f, 0.688191f,//75 -0.587785f, 0.688191f, 0.425325f,//76 -0.262866f, 0.162460f, 0.951057f,//77 0.000000f, 0.273267f, 0.961938f,//78 -0.702046f, -0.160622f, 0.693780f,//79 -0.525731f, 0.000000f, 0.850651f,//80 -0.259892f, -0.433889f, 0.862668f,//81 0.000000f, -0.273267f, 0.961938f,//82 -0.262866f, -0.162460f, 0.951057f,//83 -0.693780f, -0.702046f, 0.160622f,//84 -0.850651f, -0.525731f, 0.000000f,//85 -0.693780f, -0.702046f, -0.160622f,//86 -0.862668f, -0.259892f, 0.433889f,//87 -0.951057f, -0.262866f, 0.162460f,//88 -0.862668f, -0.259892f, -0.433889f,//89 -0.951057f, -0.262866f, -0.162460f,//90 -0.688191f, -0.425325f, 0.587785f,//91 -0.433889f, -0.862668f, 0.259892f,//92 -0.587785f, -0.688191f, 0.425325f,//93 -0.160622f, -0.693780f, 0.702046f,//94 -0.425325f, -0.587785f, 0.688191f,//95 -0.702046f, -0.160622f, -0.693780f,//96 -0.688191f, -0.425325f, -0.587785f,//97 -0.259892f, -0.433889f, -0.862668f,//98 -0.160622f, -0.693780f, -0.702046f,//99 -0.425325f, -0.587785f, -0.688191f,//100 -0.433889f, -0.862668f, -0.259892f,//101 -0.587785f, -0.688191f, -0.425325f,//102 -0.262866f, -0.162460f, -0.951057f,//103 0.000000f, -0.273267f, -0.961938f,//104 -0.525731f, 0.000000f, -0.850651f,//105 0.000000f, 0.273267f, -0.961938f,//106 -0.262866f, 0.162460f, -0.951057f,//107 0.259892f, 0.433889f, -0.862668f,//108 0.262866f, 0.162460f, -0.951057f,//109 0.702046f, 0.160622f, -0.693780f,//110 0.702046f, -0.160622f, -0.693780f,//111 0.525731f, 0.000000f, -0.850651f,//112 0.259892f, -0.433889f, -0.862668f,//113 0.262866f, -0.162460f, -0.951057f,//114 0.688191f, 0.425325f, -0.587785f,//115 0.862668f, 0.259892f, -0.433889f,//116 0.425325f, 0.587785f, -0.688191f,//117 0.693780f, 0.702046f, -0.160622f,//118 0.587785f, 0.688191f, -0.425325f,//119 0.862668f, 0.259892f, 0.433889f,//120 0.688191f, 0.425325f, 0.587785f,//121 0.702046f, 0.160622f, 0.693780f,//122 0.693780f, 0.702046f, 0.160622f,//123 0.587785f, 0.688191f, 0.425325f,//124 0.259892f, 0.433889f, 0.862668f,//125 0.425325f, 0.587785f, 0.688191f,//126 0.850651f, 0.525731f, 0.000000f,//127 0.961938f, 0.000000f, 0.273267f,//128 0.951057f, 0.262866f, 0.162460f,//129 0.961938f, 0.000000f, -0.273267f,//130 0.951057f, 0.262866f, -0.162460f,//131 0.259892f, -0.433889f, 0.862668f,//132 0.262866f, -0.162460f, 0.951057f,//133 0.702046f, -0.160622f, 0.693780f,//134 0.525731f, 0.000000f, 0.850651f,//135 0.262866f, 0.162460f, 0.951057f,//136 0.688191f, -0.425325f, 0.587785f,//137 0.862668f, -0.259892f, 0.433889f,//138 0.160622f, -0.693780f, 0.702046f,//139 0.425325f, -0.587785f, 0.688191f,//140 0.433889f, -0.862668f, 0.259892f,//141 0.693780f, -0.702046f, 0.160622f,//142 0.587785f, -0.688191f, 0.425325f,//143 0.693780f, -0.702046f, -0.160622f,//144 0.850651f, -0.525731f, 0.000000f,//145 0.862668f, -0.259892f, -0.433889f,//146 0.951057f, -0.262866f, -0.162460f,//147 0.951057f, -0.262866f, 0.162460f,//148 0.688191f, -0.425325f, -0.587785f,//149 0.433889f, -0.862668f, -0.259892f,//150 0.587785f, -0.688191f, -0.425325f,//151 0.160622f, -0.693780f, -0.702046f,//152 0.425325f, -0.587785f, -0.688191f,//153 0.273267f, -0.961938f, 0.000000f,//154 0.162460f, -0.951057f, -0.262866f,//155 -0.273267f, -0.961938f, 0.000000f,//156 -0.162460f, -0.951057f, -0.262866f,//157 0.000000f, -0.850651f, -0.525731f,//158 -0.162460f, -0.951057f, 0.262866f,//159 0.162460f, -0.951057f, 0.262866f,//160 0.000000f, -0.850651f, 0.525731f//,//161 }; QString selFilter; QString name=fileName; const QFileDialog::Options noneopt = QFileDialog::Options(); name=name.replace(QRegularExpression("ins$|res$"),"obj"); QString wfobj = QFileDialog::getSaveFileName ( 0, "Export Isosurfaces to WaveFront .obj file", name, "Wavefront (*.obj)",&selFilter, noneopt); if (wfobj.isEmpty()) return; if (!wfobj.contains (QRegularExpression(".obj$"))) wfobj.append(".obj"); QString wfmtl=wfobj; wfmtl=wfmtl.replace(QRegularExpression("obj$"),"mtl"); QString wfmtlbase=wfmtl.section('/', -1); QString base= wfmtlbase; base=base.remove(QRegularExpression("mtl$")); QString path=wfmtl.section('/',0, -2); //qDebug()<hidden) continue; if (_bonds.at(j).ato2->hidden) continue; if ((nopm1)&&(_bonds.at(j).ato1->symmGroup)&&(_bonds.at(j).ato1->part<0))continue; if ((nopm1)&&(_bonds.at(j).ato2->symmGroup)&&(_bonds.at(j).ato2->part<0))continue; V3 bondir= Normalize(_bonds.at(j).ato1->pos-_bonds.at(j).ato2->pos); bondir*=_bonds.at(j).length/2; V3 vec1; vec1.x=(_bonds.at(j).ato2->pos.y-_bonds.at(j).ato1->pos.y); vec1.y=(_bonds.at(j).ato1->pos.x-_bonds.at(j).ato2->pos.x); vec1.z=0; if (Norm(vec1)>0.00000001) vec1=Normalize(vec1); else vec1=V3(0,1,0); V3 anf=_bonds.at(j).ato1->pos - centr -bondir; V3 anf2=_bonds.at(j).ato2->pos - centr +bondir; double arr[4]; arr[0]=acos(((_bonds.at(j).ato1->pos.z-_bonds.at(j).ato2->pos.z)/ (sqrt((_bonds.at(j).ato1->pos.x-_bonds.at(j).ato2->pos.x)*(_bonds.at(j).ato1->pos.x-_bonds.at(j).ato2->pos.x)+ (_bonds.at(j).ato1->pos.y-_bonds.at(j).ato2->pos.y)*(_bonds.at(j).ato1->pos.y-_bonds.at(j).ato2->pos.y)+ (_bonds.at(j).ato1->pos.z-_bonds.at(j).ato2->pos.z)*(_bonds.at(j).ato1->pos.z-_bonds.at(j).ato2->pos.z)))))/M_PI*180.0; arr[1]=vec1.x; arr[2]=vec1.y; arr[3]=vec1.z; Matrix m2=rotarb(arr); of.write(QString("\no %1=%2\n").arg(_bonds.at(j).ato1->Label).arg(_bonds.at(j).ato2->Label).toLatin1()); of.write(QString("\nusemtl %1\n").arg((bondColorStyle)?"bond": PSE.at(_bonds.at(j).ato1->an)).toLatin1()); Matrix m1(bondStrength,0,0, 0,bondStrength,0, 0,0,_bonds.at(j).length/2); for (int i=0; i<40; i++){ V3 vec(vc[3*i],vc[3*i+1],vc[3*i+2]); vec=(m2*m1)*vec; of.write(QString("v %1 %2 %3\n") .arg(anf.x + vec.x ,12,'f',6) .arg(anf.y + vec.y ,12,'f',6) .arg(anf.z + vec.z ,12,'f',6) .toLatin1() ); kk++; } for (int i=0; i<20;i++){ uint n= idxc[3*i]+1+kk0; uint m= idxc[3*i+1]+1+kk0; uint o= idxc[3*i+2]+1+kk0; of.write(QString("f %1 %2 %3\n") .arg(n).arg(m).arg(o) .toLatin1()); //of.write(QString("f %1//%4 %2//%5 %3//%6\n") //.arg(n-kk0).arg(m-kk0).arg(o-kk0) } kk0=kk; //* vec1.x=(_bonds.at(j).ato1->pos.y-_bonds.at(j).ato2->pos.y); vec1.y=(_bonds.at(j).ato2->pos.x-_bonds.at(j).ato1->pos.x); vec1.z=0; if (Norm(vec1)>0.00000001) vec1=Normalize(vec1); else vec1=V3(0,1,0); arr[0]=acos(((_bonds.at(j).ato2->pos.z-_bonds.at(j).ato1->pos.z)/ (sqrt((_bonds.at(j).ato2->pos.x-_bonds.at(j).ato1->pos.x)*(_bonds.at(j).ato2->pos.x-_bonds.at(j).ato1->pos.x)+ (_bonds.at(j).ato2->pos.y-_bonds.at(j).ato1->pos.y)*(_bonds.at(j).ato2->pos.y-_bonds.at(j).ato1->pos.y)+ (_bonds.at(j).ato2->pos.z-_bonds.at(j).ato1->pos.z)*(_bonds.at(j).ato2->pos.z-_bonds.at(j).ato1->pos.z)))))/M_PI*180.0; arr[1]=vec1.x; arr[2]=vec1.y; arr[3]=vec1.z; Matrix m3=rotarb(arr); of.write(QString("\no %1=%2\n").arg(_bonds.at(j).ato2->Label).arg(_bonds.at(j).ato1->Label).toLatin1()); of.write(QString("\nusemtl %1\n").arg((bondColorStyle)?"bond": PSE.at(_bonds.at(j).ato2->an)).toLatin1()); for (int i=0; i<40; i++){ V3 vec(vc[3*i],vc[3*i+1],vc[3*i+2]); vec=(m3*m1)*vec; of.write(QString("v %1 %2 %3\n") .arg(anf2.x + vec.x ,12,'f',6) .arg(anf2.y + vec.y ,12,'f',6) .arg(anf2.z + vec.z ,12,'f',6) .toLatin1() ); kk++; } for (int i=0; i<20;i++){ uint n= idxc[3*i]+1+kk0; uint m= idxc[3*i+1]+1+kk0; uint o= idxc[3*i+2]+1+kk0; of.write(QString("f %1 %2 %3\n") .arg(n).arg(m).arg(o) .toLatin1()); //of.write(QString("f %1//%4 %2//%5 %3//%6\n") //.arg(n-kk0).arg(m-kk0).arg(o-kk0) } kk0=kk; // */ } of.close(); QFile mf(wfmtl); mf.open(QIODevice::WriteOnly|QIODevice::Text); for (int i=0; isetUniformValue(lichtH, 1); g_Program->setUniformValue(wallH, 0); g_Program->setUniformValue(ballH, ((ATOM_STYLE_SPHERE&style))?1:0); g_Program->setUniformValue(ringH, ((ATOM_STYLE_RINGS&style))?1:0); g_Program->setUniformValue(openH, ((ATOM_STYLE_SOLID&style))?0:1); g_Program->setUniformValue(adpsH, ((ATOM_STYLE_NOADP&style))?0:1); g_Program->setUniformValue(whiteringH, (ATOM_STYLE_WHITERING&style)?1:0); g_Program->setUniformValue(fogH, mist?1:0); g_Program->setUniformValue(fograngeH, fogrange); g_Program->setUniformValue(lodH, qMin(LOD-1,3)); /* int total = -1,program_id=g_program; glGetProgramiv( program_id, GL_ACTIVE_UNIFORMS, &total ); for(int i=0; i=0)&&((type==GL_INT)||(type==GL_BOOL))){glGetUniformiv(program_id,location,&val); } if (location>=0)printf("%2d/%2d %-42s=%d size%d %s loc%d\n",i,total,name,val,num,ts,location); if ((0==strcmp(name,"lighting"))&&val==0) return; }*/ } if (adp) glEnable(GL_BLEND); if (dratom){ // glPolygonMode(GL_FRONT_AND_BACK,GL_LINE); glEnable(GL_BLEND); glDisable(GL_DEPTH_TEST); if (dratom==3)glColor4d(0.4,0.8,1.0,0.3); if (dratom<3) glColor4d(1.0,1.0,0.0,0.7); if (dratom==3)triacontaeder(0.106f);//gluSphere(q,0.33,7,7); else if (dratom==5) { triacontaeder(0.618f);//gluSphere(q,1.00,7,7); //gluSphere(q,1.0,4*LOD,9*LOD); }else if (dratom==76){ triacontaeder(1.0f); } else triacontaeder(0.09f);//gluSphere(q,0.3,5,5); glEnable(GL_DEPTH_TEST); // glPolygonMode(GL_FRONT_AND_BACK,GL_FILL); } else{ //gluSphere(q,1.0,4*LOD,9*LOD); mySphere(qMin(LOD-1,3)); glDisable(GL_BLEND); } } void Molecule::dodecaeder(GLfloat r){ if (program_in_use&&(g_Program!=NULL)){ g_Program->setUniformValue(lichtH, 1); g_Program->setUniformValue(wallH, 0); g_Program->setUniformValue(ringH, 0); g_Program->setUniformValue(openH, 0); g_Program->setUniformValue(adpsH, 0); } static const GLfloat dodev[324]={ 0.000000f, -fibom1, fibo, 1.000000f, -1.000000f, 1.000000f, fibo, 0.000000f, fibom1, 0.000000f, -fibom1, fibo, fibo, 0.000000f, fibom1, 1.000000f, 1.000000f, 1.000000f, 0.000000f, -fibom1, fibo, 1.000000f, 1.000000f, 1.000000f, 0.000000f, fibom1, fibo, 0.000000f, fibom1, fibo, -1.000000f, 1.000000f, 1.000000f, -fibo, 0.000000f, fibom1, 0.000000f, fibom1, fibo, -fibo, 0.000000f, fibom1, -1.000000f, -1.000000f, 1.000000f, 0.000000f, fibom1, fibo, -1.000000f, -1.000000f, 1.000000f, 0.000000f, -fibom1, fibo, 0.000000f, fibom1, fibo, 1.000000f, 1.000000f, 1.000000f, fibom1, fibo, 0.000000f, 0.000000f, fibom1, fibo, fibom1, fibo, 0.000000f, -fibom1, fibo, 0.000000f, 0.000000f, fibom1, fibo, -fibom1, fibo, 0.000000f, -1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, fibo, 0.000000f, fibom1, fibo, 0.000000f, -fibom1, 1.000000f, 1.000000f, 1.000000f, fibo, 0.000000f, -fibom1, 1.000000f, 1.000000f, -1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, -1.000000f, fibom1, fibo, 0.000000f, 0.000000f, -fibom1, fibo, -1.000000f, -1.000000f, 1.000000f, -fibom1, -fibo, 0.000000f, 0.000000f, -fibom1, fibo, -fibom1, -fibo, 0.000000f, fibom1, -fibo, 0.000000f, 0.000000f, -fibom1, fibo, fibom1, -fibo, 0.000000f, 1.000000f, -1.000000f, 1.000000f, -1.000000f, 1.000000f, 1.000000f, -fibom1, fibo, 0.000000f, -1.000000f, 1.000000f, -1.000000f, -1.000000f, 1.000000f, 1.000000f, -1.000000f, 1.000000f, -1.000000f, -fibo, 0.000000f, -fibom1, -1.000000f, 1.000000f, 1.000000f, -fibo, 0.000000f, -fibom1, -fibo, 0.000000f, fibom1, -1.000000f, -1.000000f, 1.000000f, -fibo, 0.000000f, fibom1, -fibo, 0.000000f, -fibom1, -1.000000f, -1.000000f, 1.000000f, -fibo, 0.000000f, -fibom1, -1.000000f, -1.000000f, -1.000000f, -1.000000f, -1.000000f, 1.000000f, -1.000000f, -1.000000f, -1.000000f, -fibom1, -fibo, 0.000000f, fibo, 0.000000f, fibom1, 1.000000f, -1.000000f, 1.000000f, fibom1, -fibo, 0.000000f, fibo, 0.000000f, fibom1, fibom1, -fibo, 0.000000f, 1.000000f, -1.000000f, -1.000000f, fibo, 0.000000f, fibom1, 1.000000f, -1.000000f, -1.000000f, fibo, 0.000000f, -fibom1, -fibom1, fibo, 0.000000f, fibom1, fibo, 0.000000f, 1.000000f, 1.000000f, -1.000000f, -fibom1, fibo, 0.000000f, 1.000000f, 1.000000f, -1.000000f, 0.000000f, fibom1, -fibo, -fibom1, fibo, 0.000000f, 0.000000f, fibom1, -fibo, -1.000000f, 1.000000f, -1.000000f, 0.000000f, fibom1, -fibo, 1.000000f, 1.000000f, -1.000000f, fibo, 0.000000f, -fibom1, 0.000000f, fibom1, -fibo, fibo, 0.000000f, -fibom1, 1.000000f, -1.000000f, -1.000000f, 0.000000f, fibom1, -fibo, 1.000000f, -1.000000f, -1.000000f, 0.000000f, -fibom1, -fibo, -fibo, 0.000000f, -fibom1, -1.000000f, 1.000000f, -1.000000f, 0.000000f, fibom1, -fibo, -fibo, 0.000000f, -fibom1, 0.000000f, fibom1, -fibo, 0.000000f, -fibom1, -fibo, -fibo, 0.000000f, -fibom1, 0.000000f, -fibom1, -fibo, -1.000000f, -1.000000f, -1.000000f, 0.000000f, -fibom1, -fibo, 1.000000f, -1.000000f, -1.000000f, fibom1, -fibo, 0.000000f, 0.000000f, -fibom1, -fibo, fibom1, -fibo, 0.000000f, -fibom1, -fibo, 0.000000f, 0.000000f, -fibom1, -fibo, -fibom1, -fibo, 0.000000f, -1.000000f, -1.000000f, -1.000000f}; static const GLfloat doden[324]={ 0.525731f, -0.000000f, 0.850651f, 0.525731f, -0.000000f, 0.850651f, 0.525731f, -0.000000f, 0.850651f, 0.525731f, -0.000000f, 0.850651f, 0.525731f, -0.000000f, 0.850651f, 0.525731f, -0.000000f, 0.850651f, 0.525731f, -0.000000f, 0.850651f, 0.525731f, -0.000000f, 0.850651f, 0.525731f, -0.000000f, 0.850651f, -0.525731f, -0.000000f, 0.850651f, -0.525731f, -0.000000f, 0.850651f, -0.525731f, -0.000000f, 0.850651f, -0.525731f, -0.000000f, 0.850651f, -0.525731f, -0.000000f, 0.850651f, -0.525731f, -0.000000f, 0.850651f, -0.525731f, -0.000000f, 0.850651f, -0.525731f, -0.000000f, 0.850651f, -0.525731f, -0.000000f, 0.850651f, 0.000000f, 0.850651f, 0.525731f, 0.000000f, 0.850651f, 0.525731f, 0.000000f, 0.850651f, 0.525731f, 0.000000f, 0.850651f, 0.525731f, 0.000000f, 0.850651f, 0.525731f, 0.000000f, 0.850651f, 0.525731f, -0.000000f, 0.850651f, 0.525731f, -0.000000f, 0.850651f, 0.525731f, -0.000000f, 0.850651f, 0.525731f, 0.850651f, 0.525731f, 0.000000f, 0.850651f, 0.525731f, 0.000000f, 0.850651f, 0.525731f, 0.000000f, 0.850651f, 0.525731f, -0.000000f, 0.850651f, 0.525731f, -0.000000f, 0.850651f, 0.525731f, -0.000000f, 0.850651f, 0.525731f, -0.000000f, 0.850651f, 0.525731f, -0.000000f, 0.850651f, 0.525731f, -0.000000f, -0.000000f, -0.850651f, 0.525731f, -0.000000f, -0.850651f, 0.525731f, -0.000000f, -0.850651f, 0.525731f, -0.000000f, -0.850651f, 0.525731f, -0.000000f, -0.850651f, 0.525731f, -0.000000f, -0.850651f, 0.525731f, -0.000000f, -0.850651f, 0.525731f, -0.000000f, -0.850651f, 0.525731f, -0.000000f, -0.850651f, 0.525731f, -0.850651f, 0.525731f, -0.000000f, -0.850651f, 0.525731f, -0.000000f, -0.850651f, 0.525731f, -0.000000f, -0.850651f, 0.525731f, -0.000000f, -0.850651f, 0.525731f, -0.000000f, -0.850651f, 0.525731f, -0.000000f, -0.850651f, 0.525731f, -0.000000f, -0.850651f, 0.525731f, -0.000000f, -0.850651f, 0.525731f, -0.000000f, -0.850651f, -0.525731f, -0.000000f, -0.850651f, -0.525731f, -0.000000f, -0.850651f, -0.525731f, -0.000000f, -0.850651f, -0.525731f, -0.000000f, -0.850651f, -0.525731f, -0.000000f, -0.850651f, -0.525731f, -0.000000f, -0.850651f, -0.525731f, -0.000000f, -0.850651f, -0.525731f, 0.000000f, -0.850651f, -0.525731f, 0.000000f, 0.850651f, -0.525731f, -0.000000f, 0.850651f, -0.525731f, 0.000000f, 0.850651f, -0.525731f, 0.000000f, 0.850651f, -0.525731f, -0.000000f, 0.850651f, -0.525731f, -0.000000f, 0.850651f, -0.525731f, -0.000000f, 0.850651f, -0.525731f, -0.000000f, 0.850651f, -0.525731f, -0.000000f, 0.850651f, -0.525731f, -0.000000f, -0.000000f, 0.850651f, -0.525731f, -0.000000f, 0.850651f, -0.525731f, -0.000000f, 0.850651f, -0.525731f, 0.000000f, 0.850651f, -0.525731f, 0.000000f, 0.850651f, -0.525731f, 0.000000f, 0.850651f, -0.525731f, -0.000000f, 0.850651f, -0.525731f, -0.000000f, 0.850651f, -0.525731f, -0.000000f, 0.850651f, -0.525731f, 0.525731f, 0.000000f, -0.850651f, 0.525731f, -0.000000f, -0.850651f, 0.525731f, 0.000000f, -0.850651f, 0.525731f, -0.000000f, -0.850651f, 0.525731f, -0.000000f, -0.850651f, 0.525731f, -0.000000f, -0.850651f, 0.525731f, -0.000000f, -0.850651f, 0.525731f, -0.000000f, -0.850651f, 0.525731f, -0.000000f, -0.850651f, -0.525731f, 0.000000f, -0.850651f, -0.525731f, -0.000000f, -0.850651f, -0.525731f, 0.000000f, -0.850651f, -0.525731f, -0.000000f, -0.850651f, -0.525731f, -0.000000f, -0.850651f, -0.525731f, -0.000000f, -0.850651f, -0.525731f, -0.000000f, -0.850651f, -0.525731f, -0.000000f, -0.850651f, -0.525731f, -0.000000f, -0.850651f, 0.000000f, -0.850651f, -0.525731f, -0.000000f, -0.850651f, -0.525731f, 0.000000f, -0.850651f, -0.525731f, -0.000000f, -0.850651f, -0.525731f, -0.000000f, -0.850651f, -0.525731f, -0.000000f, -0.850651f, -0.525731f, -0.000000f, -0.850651f, -0.525731f, -0.000000f, -0.850651f, -0.525731f, -0.000000f, -0.850651f, -0.525731f}; //glPushMatrix(); glScalef(r,r,r); glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(3, GL_FLOAT, 0, dodev); glEnableClientState(GL_NORMAL_ARRAY); glNormalPointer(GL_FLOAT, 0, doden); glDrawArrays(GL_TRIANGLES, 0, 108); glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_NORMAL_ARRAY); //glPopMatrix(); } void Molecule::icosaeder(GLfloat r){ if (program_in_use&&(g_Program!=NULL)){ g_Program->setUniformValue(lichtH, 1); g_Program->setUniformValue(wallH, 0); g_Program->setUniformValue(ringH, 0); g_Program->setUniformValue(openH, 0); g_Program->setUniformValue(adpsH, 0); } static const GLfloat icov[180]={ 1.000000f, 0.000000f, fibo, 0.000000f, fibo, 1.000000f, -1.000000f, 0.000000f, fibo, 0.000000f, -fibo, 1.000000f, 1.000000f, 0.000000f, fibo, -1.000000f, 0.000000f, fibo, 1.000000f, 0.000000f, fibo, fibo, 1.000000f, 0.000000f, 0.000000f, fibo, 1.000000f, 1.000000f, 0.000000f, fibo, 0.000000f, -fibo, 1.000000f, fibo, -1.000000f, 0.000000f, 1.000000f, 0.000000f, fibo, fibo, -1.000000f, 0.000000f, fibo, 1.000000f, 0.000000f, -1.000000f, 0.000000f, fibo, 0.000000f, fibo, 1.000000f, -fibo, 1.000000f, 0.000000f, -1.000000f, 0.000000f, fibo, -fibo, -1.000000f, 0.000000f, 0.000000f, -fibo, 1.000000f, -1.000000f, 0.000000f, fibo, -fibo, 1.000000f, 0.000000f, -fibo, -1.000000f, 0.000000f, 0.000000f, fibo, 1.000000f, fibo, 1.000000f, 0.000000f, 0.000000f, fibo, -1.000000f, 0.000000f, fibo, 1.000000f, 0.000000f, fibo, -1.000000f, -fibo, 1.000000f, 0.000000f, 0.000000f, -fibo, 1.000000f, -fibo, -1.000000f, 0.000000f, 0.000000f, -fibo, -1.000000f, 0.000000f, -fibo, 1.000000f, 0.000000f, -fibo, -1.000000f, fibo, -1.000000f, 0.000000f, fibo, 1.000000f, 0.000000f, fibo, -1.000000f, 0.000000f, 1.000000f, 0.000000f, -fibo, fibo, 1.000000f, 0.000000f, 1.000000f, 0.000000f, -fibo, 0.000000f, fibo, -1.000000f, -fibo, 1.000000f, 0.000000f, -1.000000f, 0.000000f, -fibo, -fibo, -1.000000f, 0.000000f, -fibo, 1.000000f, 0.000000f, 0.000000f, fibo, -1.000000f, -1.000000f, 0.000000f, -fibo, -fibo, -1.000000f, 0.000000f, -1.000000f, 0.000000f, -fibo, 0.000000f, -fibo, -1.000000f, fibo, -1.000000f, 0.000000f, 0.000000f, -fibo, -1.000000f, 1.000000f, 0.000000f, -fibo, 0.000000f, fibo, -1.000000f, 1.000000f, 0.000000f, -fibo, -1.000000f, 0.000000f, -fibo, 0.000000f, -fibo, -1.000000f, -1.000000f, 0.000000f, -fibo, 1.000000f, 0.000000f, -fibo}; static const GLfloat icon[180]={ -0.000000f, 0.356822f, 0.934172f, -0.000000f, 0.356822f, 0.934172f, -0.000000f, 0.356822f, 0.934172f, 0.000000f, -0.356822f, 0.934172f, -0.000000f, -0.356822f, 0.934172f, -0.000000f, -0.356822f, 0.934172f, 0.577350f, 0.577350f, 0.577350f, 0.577350f, 0.577350f, 0.577350f, 0.577350f, 0.577350f, 0.577350f, 0.577350f, -0.577350f, 0.577350f, 0.577350f, -0.577350f, 0.577350f, 0.577350f, -0.577350f, 0.577350f, 0.934172f, -0.000000f, 0.356822f, 0.934172f, -0.000000f, 0.356822f, 0.934172f, -0.000000f, 0.356822f, -0.577350f, 0.577350f, 0.577350f, -0.577350f, 0.577350f, 0.577350f, -0.577350f, 0.577350f, 0.577350f, -0.577350f, -0.577350f, 0.577350f, -0.577350f, -0.577350f, 0.577350f, -0.577350f, -0.577350f, 0.577350f, -0.934172f, -0.000000f, 0.356822f, -0.934172f, -0.000000f, 0.356822f, -0.934172f, -0.000000f, 0.356822f, 0.356822f, 0.934172f, -0.000000f, 0.356822f, 0.934172f, -0.000000f, 0.356822f, 0.934172f, -0.000000f, -0.356822f, 0.934172f, -0.000000f, -0.356822f, 0.934172f, -0.000000f, -0.356822f, 0.934172f, -0.000000f, -0.356822f, -0.934172f, -0.000000f, -0.356822f, -0.934172f, -0.000000f, -0.356822f, -0.934172f, -0.000000f, 0.356822f, -0.934172f, -0.000000f, 0.356822f, -0.934172f, -0.000000f, 0.356822f, -0.934172f, -0.000000f, 0.934172f, -0.000000f, -0.356822f, 0.934172f, -0.000000f, -0.356822f, 0.934172f, -0.000000f, -0.356822f, 0.577350f, 0.577350f, -0.577350f, 0.577350f, 0.577350f, -0.577350f, 0.577350f, 0.577350f, -0.577350f, -0.934172f, -0.000000f, -0.356822f, -0.934172f, -0.000000f, -0.356822f, -0.934172f, -0.000000f, -0.356822f, -0.577350f, 0.577350f, -0.577350f, -0.577350f, 0.577350f, -0.577350f, -0.577350f, 0.577350f, -0.577350f, -0.577350f, -0.577350f, -0.577350f, -0.577350f, -0.577350f, -0.577350f, -0.577350f, -0.577350f, -0.577350f, 0.577350f, -0.577350f, -0.577350f, 0.577350f, -0.577350f, -0.577350f, 0.577350f, -0.577350f, -0.577350f, -0.000000f, 0.356822f, -0.934172f, -0.000000f, 0.356822f, -0.934172f, -0.000000f, 0.356822f, -0.934172f, 0.000000f, -0.356822f, -0.934172f, 0.000000f, -0.356822f, -0.934172f, 0.000000f, -0.356822f, -0.934172f}; //glPushMatrix(); glScalef(r,r,r); glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(3, GL_FLOAT, 0, icov); glEnableClientState(GL_NORMAL_ARRAY); glNormalPointer(GL_FLOAT, 0, icon); glDrawArrays(GL_TRIANGLES, 0, 60); glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_NORMAL_ARRAY); //glPopMatrix(); icocnt++; } void Molecule::triacontaeder(GLfloat r){ if (program_in_use&&(g_Program!=nullptr)){ g_Program->setUniformValue(lichtH, 1); g_Program->setUniformValue(wallH, 0); g_Program->setUniformValue(ringH, 0); g_Program->setUniformValue(openH, 0); g_Program->setUniformValue(adpsH, 0); } static const GLfloat triv[540]={ 1.000000f, 0.000000f, fibo, 0.000000f, fibom1, fibo, 0.000000f, -fibom1, fibo, //9 1.000000f, 0.000000f, fibo, 1.000000f, 1.000000f, 1.000000f, 0.000000f, fibom1, fibo, //18 1.000000f, 0.000000f, fibo, 0.000000f, -fibom1, fibo, 1.000000f, -1.000000f, 1.000000f, //27 1.000000f, 0.000000f, fibo, fibo, 0.000000f, fibom1, 1.000000f, 1.000000f, 1.000000f, //36 1.000000f, 0.000000f, fibo, 1.000000f, -1.000000f, 1.000000f, fibo, 0.000000f, fibom1, //45 fibo, 0.000000f, fibom1, fibo, 0.000000f, -fibom1, fibo, 1.000000f, 0.000000f, //54 fibo, 0.000000f, fibom1, fibo, -1.000000f, 0.000000f, fibo, 0.000000f, -fibom1, //63 -fibo, 0.000000f, fibom1, -fibo, 1.000000f, 0.000000f, -fibo, 0.000000f, -fibom1, //72 -fibo, 0.000000f, fibom1, -fibo, 0.000000f, -fibom1, -fibo, -1.000000f, 0.000000f, //81 fibo, 1.000000f, 0.000000f, 1.000000f, 1.000000f, -1.000000f, fibom1, fibo, 0.000000f, //90 fibo, 1.000000f, 0.000000f, fibo, 0.000000f, -fibom1, 1.000000f, 1.000000f, -1.000000f, //99 0.000000f, fibom1, fibo, -1.000000f, 0.000000f, fibo, 0.000000f, -fibom1, fibo, //108 0.000000f, fibom1, fibo, -1.000000f, 1.000000f, 1.000000f, -1.000000f, 0.000000f, fibo, //117 -fibom1, fibo, 0.000000f, -1.000000f, 1.000000f, -1.000000f, -fibo, 1.000000f, 0.000000f, //126 -fibom1, fibo, 0.000000f, 0.000000f, fibo, -1.000000f, -1.000000f, 1.000000f, -1.000000f, //135 -fibo, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.000000f, -fibo, 0.000000f, -fibom1, //144 0.000000f, fibom1, fibo, 0.000000f, fibo, 1.000000f, -1.000000f, 1.000000f, 1.000000f, //153 -fibo, -1.000000f, 0.000000f, -1.000000f, -1.000000f, -1.000000f, -fibom1, -fibo, 0.000000f, //162 -fibo, -1.000000f, 0.000000f, -fibo, 0.000000f, -fibom1, -1.000000f, -1.000000f, -1.000000f, //171 fibom1, -fibo, 0.000000f, 1.000000f, -1.000000f, -1.000000f, fibo, -1.000000f, 0.000000f, //180 fibom1, -fibo, 0.000000f, 0.000000f, -fibo, -1.000000f, 1.000000f, -1.000000f, -1.000000f, //189 fibo, -1.000000f, 0.000000f, 1.000000f, -1.000000f, -1.000000f, fibo, 0.000000f, -fibom1, //198 1.000000f, 1.000000f, -1.000000f, 0.000000f, fibom1, -fibo, 0.000000f, fibo, -1.000000f, //207 1.000000f, 1.000000f, -1.000000f, 1.000000f, 0.000000f, -fibo, 0.000000f, fibom1, -fibo, //216 0.000000f, fibo, -1.000000f, 0.000000f, fibom1, -fibo, -1.000000f, 1.000000f, -1.000000f, //225 -1.000000f, 0.000000f, fibo, -1.000000f, -1.000000f, 1.000000f, 0.000000f, -fibom1, fibo, //234 -1.000000f, -1.000000f, -1.000000f, 0.000000f, -fibom1, -fibo, 0.000000f, -fibo, -1.000000f, //243 -1.000000f, -1.000000f, -1.000000f, -1.000000f, 0.000000f, -fibo, 0.000000f, -fibom1, -fibo, //252 -1.000000f, 0.000000f, fibo, -1.000000f, 1.000000f, 1.000000f, -fibo, 0.000000f, fibom1, //261 0.000000f, -fibo, -1.000000f, 0.000000f, -fibom1, -fibo, 1.000000f, -1.000000f, -1.000000f, //270 -1.000000f, 0.000000f, fibo, -fibo, 0.000000f, fibom1, -1.000000f, -1.000000f, 1.000000f, //279 1.000000f, -1.000000f, -1.000000f, 0.000000f, -fibom1, -fibo, 1.000000f, 0.000000f, -fibo, //288 1.000000f, 0.000000f, -fibo, 0.000000f, -fibom1, -fibo, 0.000000f, fibom1, -fibo, //297 0.000000f, fibom1, -fibo, 0.000000f, -fibom1, -fibo, -1.000000f, 0.000000f, -fibo, //306 0.000000f, -fibom1, fibo, 0.000000f, -fibo, 1.000000f, 1.000000f, -1.000000f, 1.000000f, //315 1.000000f, 1.000000f, 1.000000f, fibo, 1.000000f, 0.000000f, fibom1, fibo, 0.000000f, //324 1.000000f, 1.000000f, 1.000000f, fibom1, fibo, 0.000000f, 0.000000f, fibo, 1.000000f, //333 0.000000f, fibo, 1.000000f, fibom1, fibo, 0.000000f, -fibom1, fibo, 0.000000f, //342 0.000000f, fibo, 1.000000f, -fibom1, fibo, 0.000000f, -1.000000f, 1.000000f, 1.000000f, //351 -1.000000f, -1.000000f, 1.000000f, -fibo, -1.000000f, 0.000000f, -fibom1, -fibo, 0.000000f, //360 -1.000000f, -1.000000f, 1.000000f, -fibom1, -fibo, 0.000000f, 0.000000f, -fibo, 1.000000f, //369 0.000000f, -fibo, 1.000000f, -fibom1, -fibo, 0.000000f, fibom1, -fibo, 0.000000f, //378 0.000000f, -fibo, 1.000000f, fibom1, -fibo, 0.000000f, 1.000000f, -1.000000f, 1.000000f, //387 fibom1, fibo, 0.000000f, 0.000000f, fibo, -1.000000f, -fibom1, fibo, 0.000000f, //396 -fibom1, -fibo, 0.000000f, 0.000000f, -fibo, -1.000000f, fibom1, -fibo, 0.000000f, //405 fibom1, fibo, 0.000000f, 1.000000f, 1.000000f, -1.000000f, 0.000000f, fibo, -1.000000f, //414 0.000000f, fibom1, fibo, 1.000000f, 1.000000f, 1.000000f, 0.000000f, fibo, 1.000000f, //423 -fibom1, -fibo, 0.000000f, -1.000000f, -1.000000f, -1.000000f, 0.000000f, -fibo, -1.000000f, //432 fibo, 0.000000f, -fibom1, 1.000000f, 0.000000f, -fibo, 1.000000f, 1.000000f, -1.000000f, //441 fibo, 0.000000f, -fibom1, 1.000000f, -1.000000f, -1.000000f, 1.000000f, 0.000000f, -fibo, //450 -fibo, 0.000000f, -fibom1, -1.000000f, 1.000000f, -1.000000f, -1.000000f, 0.000000f, -fibo, //459 -fibo, 0.000000f, -fibom1, -1.000000f, 0.000000f, -fibo, -1.000000f, -1.000000f, -1.000000f, //468 -1.000000f, 1.000000f, -1.000000f, 0.000000f, fibom1, -fibo, -1.000000f, 0.000000f, -fibo, //477 0.000000f, -fibom1, fibo, -1.000000f, -1.000000f, 1.000000f, 0.000000f, -fibo, 1.000000f, //486 1.000000f, 1.000000f, 1.000000f, fibo, 0.000000f, fibom1, fibo, 1.000000f, 0.000000f, //495 -1.000000f, 1.000000f, 1.000000f, -fibo, 1.000000f, 0.000000f, -fibo, 0.000000f, fibom1, //504 -1.000000f, 1.000000f, 1.000000f, -fibom1, fibo, 0.000000f, -fibo, 1.000000f, 0.000000f, //513 -1.000000f, -1.000000f, 1.000000f, -fibo, 0.000000f, fibom1, -fibo, -1.000000f, 0.000000f, //522 1.000000f, -1.000000f, 1.000000f, fibo, -1.000000f, 0.000000f, fibo, 0.000000f, fibom1, //531 1.000000f, -1.000000f, 1.000000f, fibom1, -fibo, 0.000000f, fibo, -1.000000f, 0.000000f}; //540 static const GLfloat trin[540]={ -0.000000f, -0.000000f, 1.000000f, -0.000000f, -0.000000f, 1.000000f, -0.000000f, -0.000000f, 1.000000f, 0.309017f, 0.500000f, 0.809017f, 0.309017f, 0.500000f, 0.809017f, 0.309017f, 0.500000f, 0.809017f, 0.309017f, -0.500000f, 0.809017f, 0.309017f, -0.500000f, 0.809017f, 0.309017f, -0.500000f, 0.809017f, 0.809017f, 0.309017f, 0.500000f, 0.809017f, 0.309017f, 0.500000f, 0.809017f, 0.309017f, 0.500000f, 0.809017f, -0.309017f, 0.500000f, 0.809017f, -0.309017f, 0.500000f, 0.809017f, -0.309017f, 0.500000f, 1.000000f, -0.000000f, -0.000000f, 1.000000f, -0.000000f, -0.000000f, 1.000000f, -0.000000f, -0.000000f, 1.000000f, -0.000000f, -0.000000f, 1.000000f, -0.000000f, -0.000000f, 1.000000f, -0.000000f, -0.000000f, -1.000000f, -0.000000f, -0.000000f, -1.000000f, -0.000000f, -0.000000f, -1.000000f, -0.000000f, -0.000000f, -1.000000f, -0.000000f, 0.000000f, -1.000000f, -0.000000f, 0.000000f, -1.000000f, -0.000000f, 0.000000f, 0.500000f, 0.809017f, -0.309017f, 0.500000f, 0.809017f, -0.309017f, 0.500000f, 0.809017f, -0.309017f, 0.809017f, 0.309017f, -0.500000f, 0.809017f, 0.309017f, -0.500000f, 0.809017f, 0.309017f, -0.500000f, -0.000000f, -0.000000f, 1.000000f, -0.000000f, -0.000000f, 1.000000f, -0.000000f, -0.000000f, 1.000000f, -0.309017f, 0.500000f, 0.809017f, -0.309017f, 0.500000f, 0.809017f, -0.309017f, 0.500000f, 0.809017f, -0.500000f, 0.809017f, -0.309017f, -0.500000f, 0.809017f, -0.309017f, -0.500000f, 0.809017f, -0.309017f, -0.500000f, 0.809017f, -0.309017f, -0.500000f, 0.809017f, -0.309017f, -0.500000f, 0.809017f, -0.309017f, -0.809017f, 0.309017f, -0.500000f, -0.809017f, 0.309017f, -0.500000f, -0.809017f, 0.309017f, -0.500000f, -0.309017f, 0.500000f, 0.809017f, -0.309017f, 0.500000f, 0.809017f, -0.309017f, 0.500000f, 0.809017f, -0.500000f, -0.809017f, -0.309017f, -0.500000f, -0.809017f, -0.309017f, -0.500000f, -0.809017f, -0.309017f, -0.809017f, -0.309017f, -0.500000f, -0.809017f, -0.309017f, -0.500000f, -0.809017f, -0.309017f, -0.500000f, 0.500000f, -0.809017f, -0.309017f, 0.500000f, -0.809017f, -0.309017f, 0.500000f, -0.809017f, -0.309017f, 0.500000f, -0.809017f, -0.309017f, 0.500000f, -0.809017f, -0.309017f, 0.500000f, -0.809017f, -0.309017f, 0.809017f, -0.309017f, -0.500000f, 0.809017f, -0.309017f, -0.500000f, 0.809017f, -0.309017f, -0.500000f, 0.309017f, 0.500000f, -0.809017f, 0.309017f, 0.500000f, -0.809017f, 0.309017f, 0.500000f, -0.809017f, 0.309017f, 0.500000f, -0.809017f, 0.309017f, 0.500000f, -0.809017f, 0.309017f, 0.500000f, -0.809017f, -0.309017f, 0.500000f, -0.809017f, -0.309017f, 0.500000f, -0.809017f, -0.309017f, 0.500000f, -0.809017f, -0.309017f, -0.500000f, 0.809017f, -0.309017f, -0.500000f, 0.809017f, -0.309017f, -0.500000f, 0.809017f, -0.309017f, -0.500000f, -0.809017f, -0.309017f, -0.500000f, -0.809017f, -0.309017f, -0.500000f, -0.809017f, -0.309017f, -0.500000f, -0.809017f, -0.309017f, -0.500000f, -0.809017f, -0.309017f, -0.500000f, -0.809017f, -0.809017f, 0.309017f, 0.500000f, -0.809017f, 0.309017f, 0.500000f, -0.809017f, 0.309017f, 0.500000f, 0.309017f, -0.500000f, -0.809017f, 0.309017f, -0.500000f, -0.809017f, 0.309017f, -0.500000f, -0.809017f, -0.809017f, -0.309017f, 0.500000f, -0.809017f, -0.309017f, 0.500000f, -0.809017f, -0.309017f, 0.500000f, 0.309017f, -0.500000f, -0.809017f, 0.309017f, -0.500000f, -0.809017f, 0.309017f, -0.500000f, -0.809017f, -0.000000f, -0.000000f, -1.000000f, -0.000000f, -0.000000f, -1.000000f, -0.000000f, -0.000000f, -1.000000f, -0.000000f, 0.000000f, -1.000000f, -0.000000f, 0.000000f, -1.000000f, -0.000000f, 0.000000f, -1.000000f, 0.309017f, -0.500000f, 0.809017f, 0.309017f, -0.500000f, 0.809017f, 0.309017f, -0.500000f, 0.809017f, 0.500000f, 0.809017f, 0.309017f, 0.500000f, 0.809017f, 0.309017f, 0.500000f, 0.809017f, 0.309017f, 0.500000f, 0.809017f, 0.309017f, 0.500000f, 0.809017f, 0.309017f, 0.500000f, 0.809017f, 0.309017f, -0.000000f, 1.000000f, -0.000000f, -0.000000f, 1.000000f, -0.000000f, -0.000000f, 1.000000f, -0.000000f, -0.500000f, 0.809017f, 0.309017f, -0.500000f, 0.809017f, 0.309017f, -0.500000f, 0.809017f, 0.309017f, -0.500000f, -0.809017f, 0.309017f, -0.500000f, -0.809017f, 0.309017f, -0.500000f, -0.809017f, 0.309017f, -0.500000f, -0.809017f, 0.309017f, -0.500000f, -0.809017f, 0.309017f, -0.500000f, -0.809017f, 0.309017f, -0.000000f, -1.000000f, -0.000000f, -0.000000f, -1.000000f, -0.000000f, -0.000000f, -1.000000f, -0.000000f, 0.500000f, -0.809017f, 0.309017f, 0.500000f, -0.809017f, 0.309017f, 0.500000f, -0.809017f, 0.309017f, -0.000000f, 1.000000f, -0.000000f, -0.000000f, 1.000000f, -0.000000f, -0.000000f, 1.000000f, -0.000000f, -0.000000f, -1.000000f, 0.000000f, -0.000000f, -1.000000f, 0.000000f, -0.000000f, -1.000000f, 0.000000f, 0.500000f, 0.809017f, -0.309017f, 0.500000f, 0.809017f, -0.309017f, 0.500000f, 0.809017f, -0.309017f, 0.309017f, 0.500000f, 0.809017f, 0.309017f, 0.500000f, 0.809017f, 0.309017f, 0.500000f, 0.809017f, -0.500000f, -0.809017f, -0.309017f, -0.500000f, -0.809017f, -0.309017f, -0.500000f, -0.809017f, -0.309017f, 0.809017f, 0.309017f, -0.500000f, 0.809017f, 0.309017f, -0.500000f, 0.809017f, 0.309017f, -0.500000f, 0.809017f, -0.309017f, -0.500000f, 0.809017f, -0.309017f, -0.500000f, 0.809017f, -0.309017f, -0.500000f, -0.809017f, 0.309017f, -0.500000f, -0.809017f, 0.309017f, -0.500000f, -0.809017f, 0.309017f, -0.500000f, -0.809017f, -0.309017f, -0.500000f, -0.809017f, -0.309017f, -0.500000f, -0.809017f, -0.309017f, -0.500000f, -0.309017f, 0.500000f, -0.809017f, -0.309017f, 0.500000f, -0.809017f, -0.309017f, 0.500000f, -0.809017f, -0.309017f, -0.500000f, 0.809017f, -0.309017f, -0.500000f, 0.809017f, -0.309017f, -0.500000f, 0.809017f, 0.809017f, 0.309017f, 0.500000f, 0.809017f, 0.309017f, 0.500000f, 0.809017f, 0.309017f, 0.500000f, -0.809017f, 0.309017f, 0.500000f, -0.809017f, 0.309017f, 0.500000f, -0.809017f, 0.309017f, 0.500000f, -0.500000f, 0.809017f, 0.309017f, -0.500000f, 0.809017f, 0.309017f, -0.500000f, 0.809017f, 0.309017f, -0.809017f, -0.309017f, 0.500000f, -0.809017f, -0.309017f, 0.500000f, -0.809017f, -0.309017f, 0.500000f, 0.809017f, -0.309017f, 0.500000f, 0.809017f, -0.309017f, 0.500000f, 0.809017f, -0.309017f, 0.500000f, 0.500000f, -0.809017f, 0.309017f, 0.500000f, -0.809017f, 0.309017f, 0.500000f, -0.809017f, 0.309017f}; //glPushMatrix(); glEnable(GL_CULL_FACE); glScalef(r,r,r); glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(3, GL_FLOAT, 0, triv); glEnableClientState(GL_NORMAL_ARRAY); glNormalPointer(GL_FLOAT, 0, trin); glDrawArrays(GL_TRIANGLES, 0, 180); glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_NORMAL_ARRAY); glDisable(GL_CULL_FACE); } void Molecule::cube(GLfloat r){ if (program_in_use&&(g_Program!=nullptr)){ g_Program->setUniformValue(lichtH, 1); g_Program->setUniformValue(wallH, 0); g_Program->setUniformValue(ringH, 0); g_Program->setUniformValue(openH, 0); g_Program->setUniformValue(adpsH, 0); } static const GLfloat cubv[108]={ -fibom1, -fibo, 0.000000f, -fibo, 0.000000f, -fibom1, 0.000000f, fibom1, -fibo, -fibom1, -fibo, 0.000000f, 0.000000f, fibom1, -fibo, 1.000000f, -1.000000f, -1.000000f, -1.000000f, 1.000000f, 1.000000f, fibom1, fibo, 0.000000f, 0.000000f, fibom1, -fibo, -1.000000f, 1.000000f, 1.000000f, 0.000000f, fibom1, -fibo, -fibo, 0.000000f, -fibom1, -1.000000f, 1.000000f, 1.000000f, -fibom1, -fibo, 0.000000f, 0.000000f, -fibom1, fibo, -1.000000f, 1.000000f, 1.000000f, -fibo, 0.000000f, -fibom1, -fibom1, -fibo, 0.000000f, -1.000000f, 1.000000f, 1.000000f, fibo, 0.000000f, fibom1, fibom1, fibo, 0.000000f, -1.000000f, 1.000000f, 1.000000f, 0.000000f, -fibom1, fibo, fibo, 0.000000f, fibom1, 0.000000f, -fibom1, fibo, 1.000000f, -1.000000f, -1.000000f, fibo, 0.000000f, fibom1, 0.000000f, -fibom1, fibo, -fibom1, -fibo, 0.000000f, 1.000000f, -1.000000f, -1.000000f, fibo, 0.000000f, fibom1, 0.000000f, fibom1, -fibo, fibom1, fibo, 0.000000f, fibo, 0.000000f, fibom1, 1.000000f, -1.000000f, -1.000000f, 0.000000f, fibom1, -fibo}; static const GLfloat cubn[108]={ -0.309017f, -0.500000f, -0.809017f, -0.309017f, -0.500000f, -0.809017f, -0.309017f, -0.500000f, -0.809017f, -0.309017f, -0.500000f, -0.809017f, -0.309017f, -0.500000f, -0.809017f, -0.309017f, -0.500000f, -0.809017f, -0.500000f, 0.809017f, -0.309017f, -0.500000f, 0.809017f, -0.309017f, -0.500000f, 0.809017f, -0.309017f, -0.500000f, 0.809017f, -0.309017f, -0.500000f, 0.809017f, -0.309017f, -0.500000f, 0.809017f, -0.309017f, -0.809017f, -0.309017f, 0.500000f, -0.809017f, -0.309017f, 0.500000f, -0.809017f, -0.309017f, 0.500000f, -0.809017f, -0.309017f, 0.500000f, -0.809017f, -0.309017f, 0.500000f, -0.809017f, -0.309017f, 0.500000f, 0.309017f, 0.500000f, 0.809017f, 0.309017f, 0.500000f, 0.809017f, 0.309017f, 0.500000f, 0.809017f, 0.309017f, 0.500000f, 0.809017f, 0.309017f, 0.500000f, 0.809017f, 0.309017f, 0.500000f, 0.809017f, 0.500000f, -0.809017f, 0.309017f, 0.500000f, -0.809017f, 0.309017f, 0.500000f, -0.809017f, 0.309017f, 0.500000f, -0.809017f, 0.309017f, 0.500000f, -0.809017f, 0.309017f, 0.500000f, -0.809017f, 0.309017f, 0.809017f, 0.309017f, -0.500000f, 0.809017f, 0.309017f, -0.500000f, 0.809017f, 0.309017f, -0.500000f, 0.809017f, 0.309017f, -0.500000f, 0.809017f, 0.309017f, -0.500000f, 0.809017f, 0.309017f, -0.500000f}; //glPushMatrix(); glScalef(r,r,r); glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(3, GL_FLOAT, 0, cubv); glEnableClientState(GL_NORMAL_ARRAY); glNormalPointer(GL_FLOAT, 0, cubn); glDrawArrays(GL_TRIANGLES, 0, 36); glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_NORMAL_ARRAY); //glPopMatrix(); } double Molecule::dieder(V3 a,V3 b, V3 c){ static double erg; double A[3],B[3],sig; sig=a.x*b.y*c.z - a.z*b.y*c.x + a.z*b.x*c.y - a.x*b.z*c.y + a.y*b.z*c.x - a.y*b.x*c.z; A[0]= a.y*b.z - a.z*b.y; A[1]=-a.x*b.z + a.z*b.x; A[2]= a.x*b.y - a.y*b.x; B[0]=-b.y*c.z + b.z*c.y; B[1]= b.x*c.z - b.z*c.x; B[2]=-b.x*c.y + b.y*c.x; // printf("A%f B%f\n",sqrt(A[0]*A[0]+A[1]*A[1]+A[2]*A[2]),sqrt(B[0]*B[0]+B[1]*B[1]+B[2]*B[2])); erg=(A[0]*B[0]+A[1]*B[1]+A[2]*B[2])/(sqrt(A[0]*A[0]+A[1]*A[1]+A[2]*A[2])*sqrt(B[0]*B[0]+B[1]*B[1]+B[2]*B[2])); erg=acos(erg)/M_PI*180.0f; return (sig>0)?(erg):(-erg); } double Molecule::winkel(V3 a,V3 b){ static double erg; if ((Norm(a)<0.001)||(Norm(b)<0.001)) return 0; erg= a*b /(sqrt(Norm(a))*sqrt(Norm(b))); // erg=(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)); erg=acos(erg)/M_PI*180.0; return(erg); } V3 Molecule::kreuzX(double x1,double y1,double z1,double x2,double y2,double z2) { static V3 erg; erg.x=-y1*z2+z1*y2; erg.y=-z1*x2+x1*z2; erg.z=-x1*y2+y1*x2; return(erg); } bool Molecule::decodeSymmCard(QString symmCard){ /*! decodes a symmetry card like 'SYMM -X, 1/2+Y, -Z' and feeds cell.symmops and cell.trans lists. * @param symmCard like 'SYMM -X, 1/2+Y, -Z'. * \returns true on sucess. * */ QString sc=symmCard.toUpper().remove("SYMM").trimmed(); sc=sc.remove("'"); sc=sc.remove(" "); QStringList axe=sc.split(","); QStringList bruch; if (axe.size()!=3) return false; double sx[3],sy[3],sz[3],t[3]; for (int i=0; i<3; i++){ sx[i]=0;sy[i]=0;sz[i]=0;t[i]=0; if (axe.at(i).contains("-X")) {sx[i]=-1.0;axe[i].remove("-X");} else if (axe.at(i).contains("X")) {sx[i]=1.0;axe[i].remove("X");} if (axe.at(i).contains("-Y")) {sy[i]=-1.0;axe[i].remove("-Y");} else if (axe.at(i).contains("Y")) {sy[i]=1.0;axe[i].remove("Y");} if (axe.at(i).contains("-Z")) {sz[i]=-1.0;axe[i].remove("-Z");} else if (axe.at(i).contains("Z")) {sz[i]=1.0;axe[i].remove("Z");} if (axe.at(i).endsWith("+")) axe[i].remove("+"); if (axe.at(i).contains("/")) { bruch=axe.at(i).split("/"); if (bruch.size()==2) t[i]=bruch.at(0).toDouble() / bruch.at(1).toDouble(); } else if (!axe.at(i).isEmpty()) t[i]=axe.at(i).toDouble(); } Matrix sm = Matrix(sx[0],sy[0],sz[0], sx[1],sy[1],sz[1], sx[2],sy[2],sz[2]); cell.symmops.append(sm); cell.trans.append(V3(t[0],t[1],t[2])); return true; } bool Molecule::decodeSymmCardEQIV(QString symmCard){ /*! decodes a symmetry card like 'SYMM -X, 1/2+Y, -Z' and feeds Molecule.symmopsEQIV, Molecule.transEQIV and Molecule.labelEQIV. * \returns true on success. * @param symmCard like 'SYMM -X, 1/2+Y, -Z'. */ QString sc=symmCard.toUpper().remove("EQIV").trimmed(); labelEQIV.append(sc.section(' ',0,0)); sc.remove(labelEQIV.last()); sc=sc.remove("'"); sc=sc.remove(" "); QStringList axe=sc.split(","); QStringList bruch; if (axe.size()!=3) return false; double sx[3],sy[3],sz[3],t[3]; for (int i=0; i<3; i++){ sx[i]=0;sy[i]=0;sz[i]=0;t[i]=0; if (axe.at(i).contains("-X")) {sx[i]=-1.0;axe[i].remove("-X");} else if (axe.at(i).contains("X")) {sx[i]=1.0;axe[i].remove("X");} if (axe.at(i).contains("-Y")) {sy[i]=-1.0;axe[i].remove("-Y");} else if (axe.at(i).contains("Y")) {sy[i]=1.0;axe[i].remove("Y");} if (axe.at(i).contains("-Z")) {sz[i]=-1.0;axe[i].remove("-Z");} else if (axe.at(i).contains("Z")) {sz[i]=1.0;axe[i].remove("Z");} if (axe.at(i).endsWith("+")) axe[i].remove("+"); if (axe.at(i).contains("/")) { bruch=axe.at(i).split("/"); if (bruch.size()==2) t[i]=bruch.at(0).toDouble() / bruch.at(1).toDouble(); } else if (!axe.at(i).isEmpty()) t[i]=axe.at(i).toDouble(); } Matrix sm = Matrix(sx[0],sy[0],sz[0], sx[1],sy[1],sz[1], sx[2],sy[2],sz[2]); symmopsEQIV.append(sm); transEQIV.append(V3(t[0],t[1],t[2])); // qDebug()<-1)){ frac=cell.symmops.at(s)*asymm[i].frac+cell.trans.at(s)+V3(h,k,l); for (int j=0;jVoronoi:
"); //QTime speedTest; //speedTest.start(); vtriangles.clear(); VPoly triangle; vorobas=1; V3 prime,dp,D,floorD; QList sdm; SdmItem sdmItem; sdmItem.a1=0; sdmItem.a2=1; sdmItem.sn=0; //sdmItem.p1=sdmItem.p2=V3(0,0,0); for (int i=0; i0.01)&&((range)>=dk)){ sdmItem.d=dk; sdmItem.floorD=fD; sdmItem.a1=i; sdmItem.a2=j; sdmItem.sn=n; sdm.append(sdmItem); } } } } } } } #if (QT_VERSION >= 0x050000) std::sort(sdm.begin(),sdm.end()); #else qSort(sdm.begin(),sdm.end()); #endif //SDMprint(sdm,au); QList n,m,doneLine; QList intra, altcol; QList v; Vert vert; V3 pf,pc,mx,nx,of,oc; Matrix mat; double vol=0.0,avol,tvol; for (int i=(intat>-1)?intat:0; i-1)) { pf = cell.symmops.at(sdm.at(j).sn) * au[sdm.at(j).a1].frac + cell.trans.at(sdm.at(j).sn) - sdm.at(j).floorD; frac2kart(pf,pc); /* printf("%9.5f %9.5f %9.5f %9.5f %9.5f %9.5f\n" ,oc.x ,oc.y ,oc.z ,pc.x ,pc.y ,pc.z );// */ mx =0.5*(oc+pc); nx = Normalize(pc-oc); bool exists = false; double dpl; for (int tp=0; tp-1)altcol.append(au[sdm.at(j).a1].an); } }//is neighbour of i }// j sdm for (int h=0; h0.00001) { out=true; break; } } if (!out) { v.append(vert); // printf("[%d,%d,%d] %9.5f%9.5f%9.5f \n",h,k,l,vert.pos.x,vert.pos.y,vert.pos.z); } } for (int mi=0; mi-1)?altcol.at(fc[0]):au[i].an; triangle.intra=(intat>-1)?0:intra.at(fc[0]); triangle.verts0=v[v1].pos; triangle.verts1=v[v2].pos; vtriangles.append(triangle); /* GLfloat colo[4]={ Acol[au[i].an][0], Acol[au[i].an][1], Acol[au[i].an][2], 0.4}; //GLfloat colo[4]={ Acol[tris%100][0], Acol[tris%100][1], Acol[tris%100][2], 0.4}; colo[3]=intra.at(fc[0])?1.0:0.4; glColor4fv(colo); glNormal3d(n.at(fc[0]).x,n.at(fc[0]).y,n.at(fc[0]).z); glVertex3d(m.at(fc[0]).x,m.at(fc[0]).y,m.at(fc[0]).z); glVertex3d(v.at(v1).pos.x,v.at(v1).pos.y,v.at(v1).pos.z); glVertex3d(v.at(v2).pos.x,v.at(v2).pos.y,v.at(v2).pos.z); */ tris++; double tv=fabs(tvol)/6.0; avol+=tv; vol+=tv*au[i].sof; tvol=determinant(Matrix(m.at(fc[1])-oc, v.at(vi).pos-oc,v.at(vj).pos-oc)); v1=(tvol<0)?vj:vi; v2=(tvol<0)?vi:vj; triangle.mid=m.at(fc[1]); triangle.nor=n.at(fc[1]); triangle.acol=(intat>-1)?altcol.at(fc[1]):au[i].an; triangle.intra=(intat>-1)?0:intra.at(fc[1]); // triangle.col[3]=((intat>-1)&&(intra.at(fc[1])))?0.8:0.4; triangle.verts0=v[v1].pos; triangle.verts1=v[v2].pos; vtriangles.append(triangle); /* colo[3]=intra.at(fc[1])?1.0:0.4; glColor4fv(colo); glNormal3d(n.at(fc[1]).x,n.at(fc[1]).y,n.at(fc[1]).z); glVertex3d(m.at(fc[1]).x,m.at(fc[1]).y,m.at(fc[1]).z); glVertex3d(v.at(v1).pos.x,v.at(v1).pos.y,v.at(v1).pos.z); glVertex3d(v.at(v2).pos.x,v.at(v2).pos.y,v.at(v2).pos.z); */ tris++; tv=fabs(tvol)/6.0; avol+=tv; vol+=tv*au[i].sof; } } // glEnd(); // printf("%d neighbours found for %s. Voronoij polyeder has %d verices, %d edges and %d faces. Triangles %d Volume %f Total Volume= %f cell volume %f\n", // m.size(),au.at(i).Label,v.size(),v.size()+m.size()-2,m.size(), printf("%-12s: Triangles %6d Volume %18.5f\n", au.at(i).Label.toStdString().c_str(), tris, avol); voroMsg.append(QString("%1 : EulerTest: %2 Volume %3 Å3.
").arg(au.at(i).Label).arg(-tris/2+faci+v.size()).arg(avol)); if (intat>-1) break; }//i atoms au if (intat==-1) { printf("Total Volume= %18.5f Total Volume * z = %18.5f cell volume %18.5f delta =%f%%\n",vol,vol*cell.symmops.size(),cell.V,(vol*cell.symmops.size()-cell.V)/cell.V*100.0); voroMsg.append(QString("Total Volume= %1 Å3 cell volume %2 Å3 ΔV %3%
").arg(vol*cell.symmops.size()).arg(cell.V).arg((vol*cell.symmops.size()-cell.V)/cell.V*100.0)); } // printf("drawing %dms\n",speedTest.restart()); } V3 eye; bool vbyeye(VPoly a,VPoly b){ //return (Distance((a.mid+a.verts0+a.verts1)*0.33333,eye)>Distance((b.mid+b.verts0+b.verts1)*0.33333,eye)); return (Distance(a.mid,eye)>Distance(b.mid,eye)); } void Molecule::drawAxses(){ glLineWidth(2.5); glDisable(GL_CULL_FACE); glEnable(GL_BLEND); glDisable(GL_LIGHTING); glBegin(GL_LINES); QColor c; //glColor3d(0,0,0); for (int i=0; i= 0x050000) std::sort(vtriangles.begin(),vtriangles.end(),vbyeye); #else qSort(vtriangles.begin(),vtriangles.end(),vbyeye); #endif glLineWidth(2.5); glDisable(GL_CULL_FACE); glEnable(GL_BLEND); glDisable(GL_LIGHTING); glBegin(GL_LINES); for (int ti=0; ti0)?0.03:(vtriangles.at(ti).intra<0)?0.2:0.6); // Farbverlauf(ti,0,vtriangles.size(),0.2); glNormal3d(vtriangles.at(ti).nor.x,vtriangles.at(ti).nor.y,vtriangles.at(ti).nor.z); glVertex3d(vtriangles.at(ti).mid.x,vtriangles.at(ti).mid.y,vtriangles.at(ti).mid.z); glVertex3d(vtriangles.at(ti).verts0.x,vtriangles.at(ti).verts0.y,vtriangles.at(ti).verts0.z); glVertex3d(vtriangles.at(ti).verts1.x,vtriangles.at(ti).verts1.y,vtriangles.at(ti).verts1.z); } glEnd(); // glEndList(); } void Molecule::drawPlanes(){ glLineWidth(2.5); glDisable(GL_CULL_FACE); glEnable(GL_BLEND); glDisable(GL_LIGHTING); glBegin(GL_LINES); QColor c; for (int ti=0; ti0.01){ c=symmColors.at(ptriangles.at(ti).colr); glColor4d(c.redF(),c.greenF(),c.blueF(),1.0); glVertex3d(ptriangles.at(ti).mid.x,ptriangles.at(ti).mid.y,ptriangles.at(ti).mid.z); //glVertex3d(0,0,0); glVertex3d(ptriangles.at(ti).mid.x+ptriangles.at(ti).glide.x, ptriangles.at(ti).mid.y+ptriangles.at(ti).glide.y, ptriangles.at(ti).mid.z+ptriangles.at(ti).glide.z); } c=symmColors.at(ptriangles.at(ti).colr); glColor4d(c.redF(),c.greenF(),c.blueF(),0.5); //glColor4d(ptriangles.at(ti).colr.redF(), ptriangles.at(ti).colr.greenF(), ptriangles.at(ti).colr.blueF(), 0.5); glVertex3d(ptriangles.at(ti).verts0.x,ptriangles.at(ti).verts0.y,ptriangles.at(ti).verts0.z); glVertex3d(ptriangles.at(ti).verts1.x,ptriangles.at(ti).verts1.y,ptriangles.at(ti).verts1.z); } glEnd(); glBegin(GL_TRIANGLES); for (int ti=0; ti0.01){ c=symmColors.at(ptriangles.at(ti).colr); glColor4d(c.redF(),c.greenF(),c.blueF(),1.0); spitze(ptriangles.at(ti).glide,ptriangles.at(ti).mid+ptriangles.at(ti).glide); } } // glEndList(); glEnable(GL_LIGHTING); } void Molecule::loadSettings(){ /*! Loads molecular parameters stored in shelxle.ini */ QSettings einstellung( QSettings::IniFormat, QSettings::UserScope ,PROGRAM_NAME,mynewnameis ); printf("loadSettings '%s' <=> '%s'\n",PROGRAM_NAME,mynewnameis.toStdString().c_str()); einstellung.sync(); einstellung.beginGroup("PSE"); pseFontSize=einstellung.value("FontSize",10).toInt(); einstellung.endGroup(); einstellung.beginGroup("HFIX"); HFixSuitableAtomsOnly=einstellung.value("HFixSuitableAtomsOnly0",false).toBool(); einstellung.endGroup(); einstellung.beginGroup("Atoms"); int acsize; acsize = einstellung.beginReadArray("CovaleceRadii"); //printf("H hat %d actsize %d\n", Kovalenz_Radien[0], acsize); for (int i = 0; i < acsize; ++i) { einstellung.setArrayIndex(i); Kovalenz_Radien[i] = einstellung.value("Radius").toInt(); //printf ("%d = %d\n",i,Kovalenz_Radien[i]); } einstellung.endArray(); acsize = einstellung.beginReadArray("BallRadii"); for (int i = 0; i < acsize; ++i) { einstellung.setArrayIndex(i); arad[i]=einstellung.value("Radius").toDouble(); } einstellung.endArray(); acsize = einstellung.beginReadArray("AtomColors"); // printf("H hat %d Col actsize %d\n", Kovalenz_Radien[0], acsize); for (int i = 0; i < acsize; ++i) { einstellung.setArrayIndex(i); AtomColor[i] = einstellung.value("Color").value(); AtomColor[i].setAlphaF(0.25); } einstellung.endArray(); acsize = einstellung.beginReadArray("AtomStyles"); for (int i = 0; i < acsize; ++i) { einstellung.setArrayIndex(i); AtomStyle[i] = einstellung.value("Style").toInt(); //printf("%d style %X\n",i, AtomStyle[i]); } einstellung.endArray(); einstellung.endGroup(); einstellung.beginGroup("SymmetryElements"); einstellung.beginWriteArray("SymmetryElementColors",107); for (int i = 0, j = 0; i < 18; ++i) { if ((i>5)&&(j%5==0)) j++; int colori=27+j++; //printf("%d %s\n",i,QColor::colorNames().at(colori).toStdString().c_str()); einstellung.setArrayIndex(i); symmColors[i] = einstellung.value("Color",QColor::colorNames().at(colori)).value(); symmColors[i].setAlphaF(1.0); } einstellung.endArray(); einstellung.endGroup(); einstellung.beginGroup("Bonds"); bondColor=einstellung.value("BondColor",QColor(Qt::darkGray)).value(); bondColorStyle=einstellung.value("BondStyle",0).toInt(); bondStrength=einstellung.value("BondStrength",0.05).toDouble(); q_bondWidth=einstellung.value("Q-BondStrength",1.00f).toFloat(); HAMax=einstellung.value("HBondMaxDist",2.5).toDouble(); HAWink=einstellung.value("HBondMaxAng",135.0).toDouble(); acsize = einstellung.beginReadArray("HBondDonors"); if (acsize>0) theseAreDonors.clear(); for (int i = 0; i < acsize; ++i) { einstellung.setArrayIndex(i); theseAreDonors.append(getOZ(einstellung.value("Element").toString())); } einstellung.endArray(); acsize = einstellung.beginReadArray("HBondAcceptors"); if (acsize>0) theseAreAcceptors.clear(); for (int i = 0; i < acsize; ++i) { einstellung.setArrayIndex(i); theseAreAcceptors.append(getOZ(einstellung.value("Element").toString())); } einstellung.endArray(); //qDebug()<(); enviHBColor=einstellung.value("enviHBColor",QColor(Qt::darkYellow)).value(); enviDefaultColor=einstellung.value("enviDefaultColor",QColor(Qt::black)).value(); einstellung.endGroup(); einstellung.beginGroup("QPeaks"); qPeakRad = einstellung.value("QPeaksRadius",0.05).toDouble(); einstellung.endGroup(); einstellung.beginGroup("Window"); ffmpegexe=einstellung.value("FFMPEG.EXE",ffmpegexe).toString(); LOD=einstellung.value("LevelOfDetail",4).toInt(); //if (einstellung.contains("Use_GLSL_Shaders")) useShaders=einstellung.value("Use_GLSL_Shaders").toBool(); einstellung.endGroup(); einstellung.beginGroup("IDEAL"); beloRad = einstellung.value("beloRad",0.04).toDouble(); beloColor = einstellung.value("beloColor",QColor("teal")).value(); beloColorByDefden= einstellung.value("beloColorByDefden",true).toBool(); beloLabels = einstellung.value("beloLabels",true).toBool(); einstellung.endGroup(); } void Molecule::setHBondMaxDist(double d){if ((d>0.0)&&(d<4.0)) HAMax=d;} void Molecule::setHBondMaxAngl(double w){if ((w>0.0)&&(w<180.0)) HAWink=w;} bool Molecule::canbeDonor(int an){ return theseAreDonors.contains(an); } bool Molecule::canbeAcceptor(int an){ return theseAreAcceptors.contains(an); } //QList theseAreAcceptors;// //QList theseAreDonors; double Molecule::hbdist(){return HAMax;} double Molecule::hbangl(){return HAWink;} #include QString Molecule::symmcode2human(int s){ /*! @param s the Nth symmetry operation of the space group. * \returns human readable string. */ QString erg; Matrix m; V3 t; int h=0,k=0,l=0; m=cell.symmops.at(s); QString symstrX,symstrY,symstrZ; if (m.m11==1) symstrX.append("+x"); if (m.m11==-1) symstrX.append("-x"); if (m.m21==1) symstrX.append("+y"); if (m.m21==-1) symstrX.append("-y"); if (m.m31==1) symstrX.append("+z"); if (m.m31==-1) symstrX.append("-z"); if (m.m12==1) symstrY.append("+x"); if (m.m12==-1) symstrY.append("-x"); if (m.m22==1) symstrY.append("+y"); if (m.m22==-1) symstrY.append("-y"); if (m.m32==1) symstrY.append("+z"); if (m.m32==-1) symstrY.append("-z"); if (m.m13==1) symstrZ.append("+x"); if (m.m13==-1) symstrZ.append("-x"); if (m.m23==1) symstrZ.append("+y"); if (m.m23==-1) symstrZ.append("-y"); if (m.m33==1) symstrZ.append("+z"); if (m.m33==-1) symstrZ.append("-z"); t=cell.trans.at(s); V3 zaehler,nenner; double egal; for (int g=1;g<7; g++){ //nenner.x=(t.x<0)?-g:g; nenner.x=g; zaehler.x=(int)round((t.x+h)*g); if (fabs(modf(t.x*g,&egal))<0.05) break; } for (int g=1;g<7; g++){ //nenner.y=(t.y<0)?-g:g; nenner.y=g; zaehler.y=(int)round((t.y+k)*g); if (fabs(modf(t.y*g,&egal))<0.05) break; } for (int g=1;g<7; g++){ //nenner.z=(t.z<0)?-g:g; nenner.z=g; zaehler.z=(int)round((t.z+l)*g); if (fabs(modf(t.z*g,&egal))<0.05) break; } erg=(QString(" %1/%2%3, %4/%5%6, %7/%8%9") .arg(zaehler.x) .arg(nenner.x) .arg(symstrX) .arg(zaehler.y) .arg(nenner.y) .arg(symstrY) .arg(zaehler.z) .arg(nenner.z) .arg(symstrZ)); erg.remove(QRegularExpression("0/\\d")); erg.replace("1/1","1"); erg.replace("2/1","2"); erg.replace("3/1","3"); erg.replace("4/1","4"); erg.replace("5/1","5"); erg.replace("6/1","6"); return erg; } QString Molecule::symmcode2human(QString brauchSymm){ /*! @param brauchSymm internal symmetry code n_555 * \returns human readable string */ QString erg; Matrix m; V3 t; int h,k,l,s; sscanf(brauchSymm.toLatin1(),"%d_%1d%1d%1d",&s,&h,&k,&l); h-=5; k-=5; l-=5; s--; m=cell.symmops.at(s); QString symstrX,symstrY,symstrZ; if (m.m11==1) symstrX.append("+x"); if (m.m11==-1) symstrX.append("-x"); if (m.m21==1) symstrX.append("+y"); if (m.m21==-1) symstrX.append("-y"); if (m.m31==1) symstrX.append("+z"); if (m.m31==-1) symstrX.append("-z"); if (m.m12==1) symstrY.append("+x"); if (m.m12==-1) symstrY.append("-x"); if (m.m22==1) symstrY.append("+y"); if (m.m22==-1) symstrY.append("-y"); if (m.m32==1) symstrY.append("+z"); if (m.m32==-1) symstrY.append("-z"); if (m.m13==1) symstrZ.append("+x"); if (m.m13==-1) symstrZ.append("-x"); if (m.m23==1) symstrZ.append("+y"); if (m.m23==-1) symstrZ.append("-y"); if (m.m33==1) symstrZ.append("+z"); if (m.m33==-1) symstrZ.append("-z"); t=cell.trans.at(s); V3 zaehler,nenner; double egal; for (int g=1;g<7; g++){ nenner.x=(t.x<0)?-g:g;; zaehler.x=(int)round((t.x+h)*g); if (fabs(modf(t.x*g,&egal))<0.05) break; } for (int g=1;g<7; g++){ nenner.y=(t.y<0)?-g:g; zaehler.y=(int)round((t.y+k)*g); if (fabs(modf(t.y*g,&egal))<0.05) break; } for (int g=1;g<7; g++){ nenner.z=(t.z<0)?-g:g; zaehler.z=(int)round((t.z+l)*g); if (fabs(modf(t.z*g,&egal))<0.05) break; } erg=(QString("%1/%2%3, %4/%5%6, %7/%8%9") .arg(zaehler.x) .arg(nenner.x) .arg(symstrX) .arg(zaehler.y) .arg(nenner.y) .arg(symstrY) .arg(zaehler.z) .arg(nenner.z) .arg(symstrZ)); erg.remove(QRegularExpression("0/\\d")); erg.replace("1/1","1"); erg.replace("2/1","2"); erg.replace("3/1","3"); erg.replace("4/1","4"); erg.replace("5/1","5"); erg.replace("6/1","6"); return erg; } QString Molecule::symmcode2human(QString brauchSymm, int j){ /*! @param brauchSymm internal symmetry code n_555 * @param j symmetry number to prepend the human readable string returned. * \returns human readable string */ QString erg; Matrix m; V3 t; int h,k,l,s; sscanf(brauchSymm.toLatin1(),"%d_%1d%1d%1d",&s,&h,&k,&l); h-=5; k-=5; l-=5; s--; m=cell.symmops.at(s); QString symstrX,symstrY,symstrZ; if (m.m11==1) symstrX.append("+x"); if (m.m11==-1) symstrX.append("-x"); if (m.m21==1) symstrX.append("+y"); if (m.m21==-1) symstrX.append("-y"); if (m.m31==1) symstrX.append("+z"); if (m.m31==-1) symstrX.append("-z"); if (m.m12==1) symstrY.append("+x"); if (m.m12==-1) symstrY.append("-x"); if (m.m22==1) symstrY.append("+y"); if (m.m22==-1) symstrY.append("-y"); if (m.m32==1) symstrY.append("+z"); if (m.m32==-1) symstrY.append("-z"); if (m.m13==1) symstrZ.append("+x"); if (m.m13==-1) symstrZ.append("-x"); if (m.m23==1) symstrZ.append("+y"); if (m.m23==-1) symstrZ.append("-y"); if (m.m33==1) symstrZ.append("+z"); if (m.m33==-1) symstrZ.append("-z"); t=cell.trans.at(s); V3 zaehler,nenner; double egal; for (int g=1;g<7; g++){ nenner.x=(t.x<0)?-g:g;; zaehler.x=(int)round(((t.x+h)*g));//+0.0001 if (fabs(modf(t.x*g,&egal))<0.05) break; } for (int g=1;g<7; g++){ nenner.y=(t.y<0)?-g:g; zaehler.y=(int)round(((t.y+k)*g));//+0.001 if (fabs(modf(t.y*g,&egal))<0.05) break; } for (int g=1;g<7; g++){ nenner.z=(t.z<0)?-g:g; zaehler.z=(int)round(((t.z+l)*g));//+0.001 if (fabs(modf(t.z*g,&egal))<0.05) break; } erg=(QString("»%1 : %2/%3%4, %5/%6%7, %8/%9%10
") .arg(j) .arg(zaehler.x) .arg(nenner.x) .arg(symstrX) .arg(zaehler.y) .arg(nenner.y) .arg(symstrY) .arg(zaehler.z) .arg(nenner.z) .arg(symstrZ)); erg.remove(QRegularExpression("0/\\d")); erg.replace("1/1","1"); erg.replace("2/1","2"); erg.replace("3/1","3"); erg.replace("4/1","4"); erg.replace("5/1","5"); erg.replace("6/1","6"); return erg; } QString Molecule::symmcode2human(QStringList brauchSymm){ /*! @param brauchSymm list of internal symmetry codes * \returns human readable string sepearated by
*/ QString erg; Matrix m; V3 t; int h,k,l,s; for (int j=0; j %2/%3%4, %5/%6%7, %8/%9%10
") .arg(j+1) .arg(zaehler.x) .arg(nenner.x) .arg(symstrX) .arg(zaehler.y) .arg(nenner.y) .arg(symstrY) .arg(zaehler.z) .arg(nenner.z) .arg(symstrZ)); } erg.remove(QRegularExpression("0/\\d")); erg.replace("1/1","1"); erg.replace("2/1","2"); erg.replace("3/1","3"); erg.replace("4/1","4"); erg.replace("5/1","5"); erg.replace("6/1","6"); return erg; } void Molecule::frac2kart(V3 x, V3 &y){ /*! * converts a fractional coordinate into a cartesian using cell information. * @param[in] x fractional coordinate. * @param[out] y cartesian coordinate. */ Matrix u; u.m11 = cell.a; u.m21 = 0.0; u.m31 = 0.0; u.m12 = cell.b * cell.cosga; u.m22 = cell.b * cell.singa; u.m32 = 0.0; u.m13 = cell.c * cell.cosbe; u.m23 = cell.tau; u.m33 = cell.c * cell.phi / cell.singa; y.x = x.x * u.m11 + x.y * u.m12 + x.z * u.m13; y.y = x.x * u.m21 + x.y * u.m22 + x.z * u.m23; y.z = x.x * u.m31 + x.y * u.m32 + x.z * u.m33; } QMatrix3x3 Molecule::cholesky(){ QMatrix3x3 u ; u(0,0) = cell.a; u(1,0) = 0.0; u(2,0) = 0.0; u(0,1) = cell.b * cell.cosga; u(1,1) = cell.b * cell.singa; u(2,1) = 0.0; u(0,2) = cell.c * cell.cosbe; u(1,2) = cell.tau; u(2,2) = cell.c * cell.phi / cell.singa; /*QMatrix3x3 v; v.setToIdentity(); QMatrix3x3 w = u * v; qDebug()<-1)&&(oz flags; int toflipp=0; for (int i=0; i-1){ flags.append(-1); toflipp++; }else flags.append(0); flags[0]=1; // printf("MaxMol = %d\n",maxmol); double dk; V3 prime,dp,D,floorD; // V3 D,floorD; QList minMol; for (int i=0; i starter; QList mii; for (int j=0; j0.01)&&((range)>=dk)){ sdmItem.d=dk; sdmItem.floorD=fD; sdmItem.a1=i; sdmItem.a2=j; sdmItem.sn=n; if ((asymm[i].an>-1)&&(asymm[j].an>-1)&& ((asymm[i].part*asymm[j].part==0)|| (asymm[i].part==asymm[j].part))) dddd=(Kovalenz_Radien[asymm[i].an]+ Kovalenz_Radien[asymm[j].an])*0.012; else dddd=0; if (sdmItem.d= 0x050000) std::sort(envi_sdm.begin(),envi_sdm.end()); #else qSort(envi_sdm.begin(),envi_sdm.end()); #endif //histogram /* double hmi,hma; hmi=envi_sdm.first().d; hma=envi_sdm.last().d; double hstep=(hma-hmi)/20.0; printf("%g %g %g %d\n",hma,hmi,hstep,envi_sdm.size()); if (hstep<0.01) return; int hbox[20]={ 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0}; for (int i=0; i=asymm.size())||(kn.neighbors.at(j)>=asymm.size())) continue; if (asymm.at(kn.neighbors.at(i)).an < asymm.at(kn.neighbors.at(j)).an){ int swap=kn.neighbors.at(i); kn.neighbors[i]=kn.neighbors.at(j); kn.neighbors[j]=swap; } } } } QList Molecule::computeSDM(CEnvironment au){ double dk,dddd; V3 prime,dp,D,floorD; SdmItem sdmItem; sdmItem.a1=0; sdmItem.a2=0; sdmItem.sn=0; QList _sdm; for (int i=0; i0.01)&&((min+0.00)>=dk)){ min=fmin(dk,min); sdmItem.d=min; sdmItem.floorD=floorD; sdmItem.a1=i; sdmItem.a2=j; sdmItem.sn=n; hma=true; } } if ((au[sdmItem.a1].an>-1)&& (au[sdmItem.a2].an>-1)&& ((au[sdmItem.a1].part*au[sdmItem.a2].part==0)||(au[sdmItem.a1].part==au[sdmItem.a2].part))){ dddd=(Kovalenz_Radien[au[sdmItem.a1].an]+ Kovalenz_Radien[au[sdmItem.a2].an])*0.012; } else { dddd=0; } sdmItem.covalent=(sdmItem.d0.01)&&((min+0.00)>=dk)){ min=fmin(dk,min); sdmItem.d=min; sdmItem.floorD=floorD; sdmItem.a1=i; sdmItem.a2=j; sdmItem.sn=n; hma=true; } } if ((asymm[sdmItem.a1].an>-1)&&(asymm[sdmItem.a2].an>-1)&& ((asymm[sdmItem.a1].part*asymm[sdmItem.a2].part==0)|| (asymm[sdmItem.a1].part==asymm[sdmItem.a2].part))) dddd=(Kovalenz_Radien[asymm[sdmItem.a1].an]+ Kovalenz_Radien[asymm[sdmItem.a2].an])*0.0115; else dddd=0; if (sdmItem.d180))));// */ if ((qMax(ang1,ang2)!=361)&&((qMin(ang1,ang2)<85)||(qMax(ang1,ang2)>180))) sdmItem2.covalent=false; else { //printf("contact ok\n"); contact.append(sdmItem2); } } } } } // printf("sdm3 %d\n",zeit.elapsed());//\n"); zeit.restart(); QString bs; QStringList brauchSymm; int someleft=0,nextmol=0; maxmol=1; for (int i=0; i-1)&&(asymm[i].molindex<0)) {nextmol=i;break;} } if (nextmol) { asymm[nextmol].molindex=(++maxmol); } }while (nextmol); Fragments=QString("The asymmetric unit contains %1 fragments.
").arg(maxmol); for (int k =0; k6) continue; for (int n=0;n0.001)&&(dddd>=dk)) { bs=QString("%1_%2%3%4:%5,").arg(n+1).arg(5-(int)floorD.x).arg(5-(int)floorD.y).arg(5-(int)floorD.z).arg(asymm[sdm.at(k).a1].molindex); if ((!brauchSymm.contains(bs))) { brauchSymm.append(bs); // printf("%d %d %d %d [%d]\n",n+1,(int)floorD.x,(int)floorD.y,(int)floorD.z ,brauchSymm.size()); } } } } } // printf("sdm4 %d\n",zeit.elapsed()); zeit.restart(); #if (QT_VERSION >= 0x050000) std::sort(sdm.begin(),sdm.end()); #else qSort(sdm.begin(),sdm.end()); #endif // printf("sdm5 %d\n",zeit.elapsed());//\n"); zeit.restart(); enviSDM(2.5); // printf("sdm5 %d\n",zeit.elapsed());//\n"); zeit.restart(); QList flags; for (int i=0; i-1)))){ // if (((asymm[envi_sdm.at(i).a1].Label=="Q11")||(asymm[envi_sdm.at(i).a2].Label=="Q11"))&&(envi_sdm.at(i).d<2.6)) // qDebug()<-1) continue; if (asymm[envi_sdm.at(i).a1].an==-66) continue; if ((envi_sdm.at(i).sn==0)&&(envi_sdm.at(i).floorD==V3(0,0,0))) {flags[envi_sdm.at(i).a1]=1;continue;} if (envi_sdm.at(i).d>2.4) continue; asymm[envi_sdm.at(i).a1].frac = cell.symmops.at(envi_sdm.at(i).sn) * asymm[envi_sdm.at(i).a1].frac + cell.trans.at(envi_sdm.at(i).sn) - envi_sdm.at(i).floorD; flags[envi_sdm.at(i).a1]=1; frac2kart(asymm[envi_sdm.at(i).a1].frac,asymm[envi_sdm.at(i).a1].pos); //} } } // printf("sdm6 %d\n",zeit.elapsed()); zeit.restart(); return brauchSymm; } Connection Molecule::connecting(const CEnvironment &atom,bool eac){ /*! Creates bonds and lbonds depending on covalent radii. * If edit atom style flag (eac) is not set FREE and BIND instructions are considered. * Feeds also Molecule.knoepfe list. * \returns the Connection bond list. * */ Connection bonds; bonds.clear(); lbonds.clear(); MyBond bond; double soll=0; printf("connecting %d atoms atom styles dialog %d\n",atom.size(),eac); for (int i=0; i-1)&&(atom.at(j).an>-1)&&(atom.at(i).part!=0)&&(atom.at(j).part!=0)&&((bindPart.key(atom.at(i).part)==atom.at(j).part)||(bindPart.value(atom.at(i).part)==atom.at(j).part))){ soll=(Kovalenz_Radien[atom.at(i).an]+ Kovalenz_Radien[atom.at(j).an])*0.012; //printf("%f %f %s==%s %d %d %d %d\n",d,soll,atom.at(i).Label.toStdString().c_str(),atom.at(j).Label.toStdString().c_str(), atom.at(i).an,atom.at(j).an,atom.at(i).part,atom.at(j).part); } else { if ((atom.at(i).part<0)&&(atom.at(j).part!=0)&&(atom.at(i).symmGroup!=atom.at(j).symmGroup)) continue; if ((atom.at(j).part<0)&&(atom.at(i).part!=0)&&(atom.at(i).symmGroup!=atom.at(j).symmGroup)) continue; if ((atom.at(i).an==0)&&(atom.at(j).an==0)) continue; if ((atom.at(i).an>-1)&&(atom.at(j).an>-1)&& ((!atom.at(i).part)||(!atom.at(j).part)||(atom.at(i).part==atom.at(j).part))){ soll=(Kovalenz_Radien[atom.at(i).an]+ Kovalenz_Radien[atom.at(j).an])*0.012; //printf("%d + %d = %d %d %d\n",Kovalenz_Radien[atom.at(i).an], Kovalenz_Radien[atom.at(j).an], (Kovalenz_Radien[atom.at(i).an]+ Kovalenz_Radien[atom.at(j).an]) , atom.at(i).an, atom.at(j).an); //printf("%f %f %s==%s %d %d %d %d\n",d,soll,atom.at(i).Label.toStdString().c_str(),atom.at(j).Label.toStdString().c_str(), atom.at(i).an,atom.at(j).an,atom.at(i).part,atom.at(j).part); } else{ soll=-1; } } if ((d>0.1)&&(dqboMin)){ if ((atom.at(i).an==-42)||(atom.at(j).an==-42)) continue;//belo: wuff! if ((atom.at(i).an==0)||(atom.at(j).an==0)) continue; if ((!atom.at(i).part)||(!atom.at(j).part)||(atom.at(i).part==atom.at(j).part)){ bond.ato1=&atom[i]; bond.ato2=&atom[j]; bond.a1=i; bond.a2=j; bond.length=d; lbonds.append(bond); } } } } //printf("connected %d\n",bonds.size()); //centroid metal bonds ... just normal bonds but bonds between metal and nonmetal that are close to the centroid will be removed. if (!eac) { bool weHaveCentroids=false; bool weHaveMetals=false; for (int i=0; i0)&&((AtomStyle[atom.at(bonds.at(k).a2).an]&ATOM_STYLE_METAL)==0)){ d = sqrt(Distance(atom.at(i).pos,atom.at(bonds.at(k).a2).pos));//re-use d distance cnt -- non metal if ((dqboMin)){ bonds.removeAt(k); // printf("1Removed metal non metal bond %s == %s\n",bonds.at(k).ato1->Label.toStdString().c_str(),bonds.at(k).ato2->Label.toStdString().c_str()); k=(k>0)?k-1:0; } }//a1 is a metal if ((bonds.at(k).a2==j)&&(atom.at(bonds.at(k).a1).an>0)&&((AtomStyle[atom.at(bonds.at(k).a1).an]&ATOM_STYLE_METAL)==0)){ d = sqrt(Distance(atom.at(i).pos,atom.at(bonds.at(k).a1).pos));//re-use d distance cnt -- non metal if ((dqboMin)){ bonds.removeAt(k); //printf("2Removed metal non metal bond %s == %s\n",bonds.at(k).ato1->Label.toStdString().c_str(),bonds.at(k).ato2->Label.toStdString().c_str()); k=(k>0)?k-1:0; } }//a1 is a metal }//k bonds.append(bond); }//cnt metal contact }//j }//centroid }//i }//metals and centroids present }//!eac printf("bind size %d free size %d bonds %d lbonds %d\n",bindatoms.size(),freeatoms.size(),bonds.size(),lbonds.size()); if (!eac) for (int i=0; i-1)&& (bonds.at(j).ato1->resiNr!=a1.resiNr))|| ((a2.resiNr>-1)&& (bonds.at(j).ato2->resiNr!=a2.resiNr))) continue; if (((a1.resiNr>-1)&& (bonds.at(j).ato2->resiNr!=a1.resiNr))|| ((a2.resiNr>-1)&& (bonds.at(j).ato1->resiNr!=a2.resiNr))) continue; if (((bonds.at(j).ato1->Label.section('_',0,0).toUpper()== a1.Label)&& (bonds.at(j).ato2->Label.section('_',0,0).toUpper()== a2.Label))|| ((bonds.at(j).ato2->Label.section('_',0,0).toUpper()== a1.Label)&& (bonds.at(j).ato1->Label.section('_',0,0).toUpper()== a2.Label))){ bonds.removeAt(j); j=qMax(j-1,0); } } } if (!eac) for (int i=0; i%d %d %d %d [%d] %s === %s\n",a2.resiNr,a1.resiNr,sy1,sy2,i,a1.Label.toStdString().c_str(),a2.Label.toStdString().c_str()); double mindd=50.0; printf("-Q %d\n",eqivMap.size()); if ((!eqivMap.isEmpty())&&(qMax(sy1,sy2)>0)) { // printf("sg %d\n",eqivMap.value(QString("$%1").arg(sy2))); // printf("%s %s\n",a1.Label.toUpper().toStdString().c_str(),a2.Label.toUpper().toStdString().c_str()); for (int iii=0; iii-1)&& (atom.at(iii).resiNr!=a1.resiNr)) continue; if ((a2.resiNr>-1)&& (atom.at(jjj).resiNr!=a2.resiNr)) continue; if ((sy1>-0)&&(atom.at(iii).symmGroup==0)) continue; if ((sy2>-0)&&(atom.at(jjj).symmGroup==0)) continue; //printf("sg %d\n",eqivMap.value(QString("$%1").arg(sy1))); if ((sy1>-0)&&(eqivMap.value(QString("$%1").arg(sy1))!=atom.at(iii).symmGroup)) continue; if ((sy2>-0)&&(eqivMap.value(QString("$%1").arg(sy2))!=atom.at(jjj).symmGroup)) continue; if ((atom.at(iii).Label.section('_',0,0).section(QString::fromUtf8("ยป"),0,0).toUpper() == a1.Label.toUpper())&& (atom.at(jjj).Label.section('_',0,0).section(QString::fromUtf8("ยป"),0,0).toUpper() == a2.Label.toUpper())){ bond.ato1=&atom[iii]; bond.ato2=&atom[jjj]; bond.a1=iii; bond.a2=jjj; bond.length=sqrt(Distance(atom[iii].pos,atom[jjj].pos)); printf("%g %f\n",bond.length,mindd); if ((mindd+0.01)>=bond.length) bonds.append(bond); if (bond.length>0.7) mindd=qMin(bond.length, mindd); } } } }else{ // printf("sg %d\n",eqivMap.value(QString("$%1").arg(sy2))); // printf("%s %s\n",a1.Label.toUpper().toStdString().c_str(),a2.Label.toUpper().toStdString().c_str()); for (int iii=0; iii-1)&& (atom.at(iii).resiNr!=a1.resiNr)) continue; if ((a2.resiNr>-1)&& (atom.at(jjj).resiNr!=a2.resiNr)) continue; if ((atom.at(iii).Label.section('_',0,0).section(QString::fromUtf8("ยป"),0,0).toUpper() == a1.Label.toUpper())&& (atom.at(jjj).Label.section('_',0,0).section(QString::fromUtf8("ยป"),0,0).toUpper() == a2.Label.toUpper())){ bond.ato1=&atom[iii]; bond.ato2=&atom[jjj]; bond.a1=iii; bond.a2=jjj; bond.length=sqrt(Distance(atom[iii].pos,atom[jjj].pos)); printf("%g %f\n",bond.length,mindd); if ((mindd+0.01)>=bond.length) bonds.append(bond); if (bond.length>0.7) mindd=qMin(bond.length, mindd); } } } } for (int j=0; j < bonds.size(); j++){ if (((bonds.at(j).ato1->Label.section('_',0,0).section(QString::fromUtf8("ยป"),0,0).toUpper()==a1.Label.toUpper())&& (bonds.at(j).ato2->Label.section('_',0,0).section(QString::fromUtf8("ยป"),0,0).toUpper()==a2.Label.toUpper()))|| ((bonds.at(j).ato1->Label.section('_',0,0).section(QString::fromUtf8("ยป"),0,0).toUpper()==a2.Label.toUpper())&& (bonds.at(j).ato2->Label.section('_',0,0).section(QString::fromUtf8("ยป"),0,0).toUpper()==a1.Label.toUpper()))) if (bonds.at(j).length>(mindd+0.1)) { double d=bonds.at(j).length; printf("-- %f %f\n",d,mindd); bonds.removeAt(j); if (j) j--; } } } printf(">>>bind size %d free size %d bonds %d lbonds %d\n",bindatoms.size(),freeatoms.size(),bonds.size(),lbonds.size()); //-->Verknopfung !!! if (!eac){ for (int i=0; i see Shelxl manual. */ int z=cell.symmops.size(); cell.ns0=z; Matrix inv(-1.0,0.0,0.0, 0.0,-1.0,0.0, 0.0,0.0,-1.0); cell.centeric=false; if (gitter>0){ for (int i=0; i0)?gitter:-gitter; z=cell.symmops.size(); cell.centered=false; switch (gitter){ case 5 : for (int i=0; i1)?tt.x-1:tt.x; tt.y=(tt.y>1)?tt.y-1:tt.y; tt.z=(tt.z>1)?tt.z-1:tt.z; cell.symmops.append(cell.symmops.at(i)); cell.trans.append(tt); cell.centered=true; } break; case 6 : for (int i=0; i1)?tt.x-1:tt.x; tt.y=(tt.y>1)?tt.y-1:tt.y; tt.z=(tt.z>1)?tt.z-1:tt.z; cell.symmops.append(cell.symmops.at(i)); cell.trans.append(tt); cell.centered=true; } break; case 7 : for (int i=0; i1)?tt.x-1:tt.x; tt.y=(tt.y>1)?tt.y-1:tt.y; tt.z=(tt.z>1)?tt.z-1:tt.z; cell.symmops.append(cell.symmops.at(i)); cell.trans.append(tt); cell.centered=true; } break; case 4 : for (int i=0; i1)?tt.x-1:tt.x; tt.y=(tt.y>1)?tt.y-1:tt.y; tt.z=(tt.z>1)?tt.z-1:tt.z; cell.symmops.append(cell.symmops.at(i)); cell.trans.append(tt); tt = cell.trans.at(i)+V3(0.5, 0.0, 0.5); tt.x=(tt.x>1)?tt.x-1:tt.x; tt.y=(tt.y>1)?tt.y-1:tt.y; tt.z=(tt.z>1)?tt.z-1:tt.z; cell.symmops.append(cell.symmops.at(i)); cell.trans.append(tt); tt = cell.trans.at(i)+V3(0.5, 0.5, 0.0); tt.x=(tt.x>1)?tt.x-1:tt.x; tt.y=(tt.y>1)?tt.y-1:tt.y; tt.z=(tt.z>1)?tt.z-1:tt.z; cell.symmops.append(cell.symmops.at(i)); cell.trans.append(tt); cell.centered=true; } break; case 2 : for (int i=0; i1)?tt.x-1:tt.x; tt.y=(tt.y>1)?tt.y-1:tt.y; tt.z=(tt.z>1)?tt.z-1:tt.z; cell.symmops.append(cell.symmops.at(i)); cell.trans.append(tt); cell.centered=true; } break; case 3 : for (int i=0; i1)?tt.x-1:tt.x; tt.y=(tt.y>1)?tt.y-1:tt.y; tt.z=(tt.z>1)?tt.z-1:tt.z; cell.symmops.append(cell.symmops.at(i)); cell.trans.append(tt); tt = cell.trans.at(i)+V3(1.0/3.0, 2.0/3.0, 2.0/3.0); tt.x=(tt.x>1)?tt.x-1:tt.x; tt.y=(tt.y>1)?tt.y-1:tt.y; tt.z=(tt.z>1)?tt.z-1:tt.z; cell.symmops.append(cell.symmops.at(i)); cell.trans.append(tt); cell.centered=true; } break; case 0 :break; } } double Molecule::dimension(){ /*! calculates the maximal interatomic distance (Ang) of showatoms environment if this is 0 then 10.0 is returned instead. */ double max=0,gg=0; for (int i=0;i=0)&&(showatoms[j].an>=0)) gg=sqrt( Distance(showatoms[i].pos,showatoms[j].pos)); max=(max=0)&&(ce[j].an>=0)) gg=sqrt( Distance(ce[i].pos,ce[j].pos)); max=(maxbind()) qWarning() << "Could not bind program to the context"; g_Program->setUniformValue(lichtH,1); /*glGetUniformiv(g_program,lichtH,&Licht); if (!Licht) { int ect=0; GLenum err = GL_NO_ERROR; while((err = glGetError()) != GL_NO_ERROR) { printf("DAVOR %d %d [%d]\n",err==GL_INVALID_VALUE ,err == GL_INVALID_OPERATION,++ect); } }*/ shaderAtoms(atom, proba, radScal); g_Program->release(); return; }//else{printf("%d %d %d %p\n",shaders_work,g_program,useShaders,g_Program);} /* int myAdp=adp; int myStyle=7; int pminus=0; int wire=0; GLfloat white[4]={0.2f, 0.2f, 0.3f, 0.0f}; GLfloat black[4]={0.0f, 0.0f, 0.0f, 1.0f}; for (int i=0; i-1) { myStyle=AtomStyle[atom.at(i).an]; //printf("style: %X\n",myStyle); if (atom.at(i).Label.contains("(noADP)")) myStyle|=ATOM_STYLE_NOADP; glColor4d(atomColor(atom.at(i).an).redF(), atomColor(atom.at(i).an).greenF(), atomColor(atom.at(i).an).blueF(), atomColor(atom.at(i).an).alphaF()); rad=arad[atom.at(i).an]; if (parthigh) { QColor pcolor=PartColor::color(atom.at(i).part); if (atom.at(i).part==666) pcolor.setAlpha(200); else pcolor.setAlpha(140); glColor4d(pcolor.redF(), pcolor.greenF(), pcolor.blueF(), pcolor.alphaF()); } if ((highlightEquivalents)&&(!parthigh)&&(atom.at(i).symmGroup)) { glMaterialfv( GL_FRONT_AND_BACK, GL_EMISSION,white ); glColor4d(qMin(1.0,(atomColor(atom.at(i).an).redF()+0.1) * 1.2), qMin(1.0,(atomColor(atom.at(i).an).greenF()+0.1) * 1.2), qMin(1.0,(atomColor(atom.at(i).an).blueF()+0.1) * 1.2), 1.0); } else glMaterialfv( GL_FRONT_AND_BACK, GL_EMISSION,black ); if ((atom.at(i).symmGroup)&&(atom.at(i).part<0)){ glColor4d(atomColor(atom.at(i).an).redF(), atomColor(atom.at(i).an).greenF(), 1.0, 0.3); pminus=1; // myStyle|=ATOM_STYLE_NOADP; } myAdp=(myStyle&ATOM_STYLE_NOADP)?0:adp; } if (wire) {myStyle|=ATOM_STYLE_SPHERE;if (myStyle&ATOM_STYLE_SOLID)myStyle-=ATOM_STYLE_SOLID; } if (tubes){ rad=bondStrength; if (atom.at(i).part==666) rad*=4.5; myAdp=0; nonPositiveDefinite=0; } if ((atom.at(i).an<0)||(atom.at(i).Label.startsWith('Q',Qt::CaseInsensitive))){ glColor4d(1.0 ,0.7, 0.8 ,0.4); if (atom.at(i).an==-66) { rad*=2; glColor4d(0.6,0.3,0.1,0.3); dodecaeder(rad); }else{ if((atom.at(i).an==-1)&&(!monoQrom)) Farbverlauf(atom.at(i).peakHeight, pmin, pmax); if (monoQrom) glColor3d(mQolor.redF(),mQolor.greenF(),mQolor.blueF()); // if (!wire) icosaeder(rad); } } else { if (myAdp){ V3 ev=V3(0,0,0); double *arr=jacobi(atom.at(i).uc,ev); if ((ev.x>0)&&(ev.y>0)&&(ev.z>0)){ nonPositiveDefinite=0; glRotated(Ato4d(arr)); double psc=(parthigh)?1.32:1.0; if (atom.at(i).part==666) psc*=1.2; switch (proba ) { case 10 :{ glScaled(0.76*sqrt(ev.x)*psc,0.76*sqrt(ev.y)*psc,0.76*sqrt(ev.z)*psc);break;} //Hauptachsen der Eliipsoide 10% Wahrscheinlichkeit case 30 :{ glScaled(1.19*sqrt(ev.x)*psc,1.19*sqrt(ev.y)*psc,1.19*sqrt(ev.z)*psc);break;} //Hauptachsen der Eliipsoide 30% Wahrscheinlichkeit case 50 :{ glScaled(1.54*sqrt(ev.x)*psc,1.54*sqrt(ev.y)*psc,1.54*sqrt(ev.z)*psc);break;} //Hauptachsen der Eliipsoide 50% Wahrscheinlichkeit case 70 :{ glScaled(1.91*sqrt(ev.x)*psc,1.91*sqrt(ev.y)*psc,1.91*sqrt(ev.z)*psc);break;} //Hauptachsen der Eliipsoide 70% Wahrscheinlichkeit case 90 :{ glScaled(2.50*sqrt(ev.x)*psc,2.50*sqrt(ev.y)*psc,2.50*sqrt(ev.z)*psc);break;} //Hauptachsen der Eliipsoide 90% Wahrscheinlichkeit default: ; } }else {nonPositiveDefinite=1;} } if (parthigh) { rad*=1.32; if (atom.at(i).part==666) rad*=1.2; glEnable(GL_BLEND); myStyle&=(ATOM_STYLE_SPHERE|ATOM_STYLE_NOADP); myStyle|=ATOM_STYLE_SPHERE; } / * #define ATOM_STYLE_WALLS 1 #define ATOM_STYLE_RINGS 2 #define ATOM_STYLE_SPHERE 4 #define ATOM_STYLE_SOLID 8 #define ATOM_STYLE_WHITERING 16 #define ATOM_STYLE_NOLABEL 32 * / if (atom.at(i).an>-1) { if (myAdp&&intern) { if (!nonPositiveDefinite) ellipse(myStyle); else { cube(rad); } } else if ((!myAdp)||((myStyle&ATOM_STYLE_SPHERE)&&(!(myStyle&ATOM_STYLE_SOLID)))){ rad*=radScal; if (!myAdp) glScaled(rad,rad,rad); if (!nonPositiveDefinite) { if (wire)dratom =5; sphere(myAdp|pminus); } else { cube(rad); } } } else icosaeder(rad); } } else{ atom[i].hidden=0; sphere(0); } // glEnable(GL_COLOR_MATERIAL); glMaterialfv( GL_FRONT_AND_BACK, GL_EMISSION,black ); glPopMatrix(); if (parthigh) dratom=2; }*/ } void Molecule::billBoard(){ const GLfloat v[]={ 0.f,0.f,0.f, 1.f,0.f,0.f, 1.f,1.f,0.f, 0.f,1.f,0.f, 0.f,0.f,0.f, 1.f,1.f,0.f }; glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY); glVertexPointer(3, GL_FLOAT, 0, v); glTexCoordPointer(3, GL_FLOAT, 0, v); glDrawArrays(GL_TRIANGLES, 0, 6); glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_NORMAL_ARRAY); glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_TEXTURE_COORD_ARRAY); } void Molecule::pappe(){ glEnable(GL_ALPHA_TEST); g_Program->setUniformValue(wallH, 1); const GLfloat v[]={ -1.f,-1.f, 0.f, 1.f,-1.f, 0.f, -1.f, 1.f, 0.f, -1.f, 1.f, 0.f, 1.f,-1.f, 0.f, 1.f, 1.f, 0.f, -1.f, 0.f,-1.f, 1.f, 0.f,-1.f, -1.f, 0.f, 1.f, -1.f, 0.f, 1.f, 1.f, 0.f,-1.f, 1.f, 0.f, 1.f, 0.f,-1.f,-1.f, 0.f, 1.f,-1.f, 0.f,-1.f, 1.f, 0.f,-1.f, 1.f, 0.f, 1.f,-1.f, 0.f, 1.f, 1.f, 1.f,-1.f, 0.f, -1.f,-1.f, 0.f, -1.f, 1.f, 0.f, 1.f,-1.f, 0.f, -1.f, 1.f, 0.f, 1.f, 1.f, 0.f, 1.f, 0.f,-1.f, -1.f, 0.f,-1.f, -1.f, 0.f, 1.f, 1.f, 0.f,-1.f, -1.f, 0.f, 1.f, 1.f, 0.f, 1.f, 0.f, 1.f,-1.f, 0.f,-1.f,-1.f, 0.f,-1.f, 1.f, 0.f, 1.f,-1.f, 0.f,-1.f, 1.f, 0.f, 1.f, 1.f }; const GLfloat n[]={ 0.f, 0.f, 1.f, 0.f, 0.f, 1.f, 0.f, 0.f, 1.f, 0.f, 0.f, 1.f, 0.f, 0.f, 1.f, 0.f, 0.f, 1.f, 0.f,-1.f, 0.f, 0.f,-1.f, 0.f, 0.f,-1.f, 0.f, 0.f,-1.f, 0.f, 0.f,-1.f, 0.f, 0.f,-1.f, 0.f, 1.f, 0.f, 0.f, 1.f, 0.f, 0.f, 1.f, 0.f, 0.f, 1.f, 0.f, 0.f, 1.f, 0.f, 0.f, 1.f, 0.f, 0.f, 0.f, 0.f,-1.f, 0.f, 0.f,-1.f, 0.f, 0.f,-1.f, 0.f, 0.f,-1.f, 0.f, 0.f,-1.f, 0.f, 0.f,-1.f, 0.f, 1.f, 0.f, 0.f, 1.f, 0.f, 0.f, 1.f, 0.f, 0.f, 1.f, 0.f, 0.f, 1.f, 0.f, 0.f, 1.f, 0.f, -1.f, 0.f, 0.f, -1.f, 0.f, 0.f, -1.f, 0.f, 0.f, -1.f, 0.f, 0.f, -1.f, 0.f, 0.f, -1.f, 0.f, 0.f }; glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(3, GL_FLOAT, 0, v); glEnableClientState(GL_NORMAL_ARRAY); glNormalPointer(GL_FLOAT, 0, n); glDrawArrays(GL_TRIANGLES, 0, 36); glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_NORMAL_ARRAY); } void Molecule::shaderAtoms(CEnvironment atom,int proba,double radScal){ /*! Draws atoms as spheres or as ellipses cubes or icosahedrons. * @params atoms list of atoms to be drawn . * @params proba ellipsoid probability (currently 10 30 50 70 90 %). * * Molecule.dratom controls the wireframe style of the resulting atom . * * Molecule.tubes atom balls is drawn in bondstrength. * * Molecule.adp atom is drawn as a ellipsoid. * * Molecule.monoQrom Q-Peaks are drawn in Color Molecule.mQolor . * */ if (atom.isEmpty())return; int myAdp=adp; int myStyle=7; int pminus=0; int wire=0; // if (!intern) return; Licht=1; g_Program->bind(); g_Program->setUniformValue(lichtH, 1); g_Program->setUniformValue(bgH,fgc[0],fgc[1],fgc[2],fgc[3]); //glGetUniformiv(g_program,lichtH,&Licht); //if (!Licht) { // glUseProgram(0); // return;//licht geht nicht an //} program_in_use=true; for (int i=0; i-1) { myStyle=AtomStyle[atom.at(i).an]; if (atom.at(i).Label.contains("(noADP)")) myStyle|=ATOM_STYLE_NOADP; bool isd=((atom.at(i).an==0)&&(atom.at(i).Label[0]=='D')); glColor4d(atomColor(atom.at(i).an,isd).redF(), atomColor(atom.at(i).an,isd).greenF(), atomColor(atom.at(i).an,isd).blueF(), (wire)?0.25:1.0);//atomColor(atom.at(i).an].alphaF()); rad=arad[atom.at(i).an]; if (parthigh) { glEnable(GL_BLEND); QColor pcolor=PartColor::color(atom.at(i).part); if (atom.at(i).part==666) pcolor.setAlpha(70); else pcolor.setAlpha(90); glColor4d(pcolor.redF(), pcolor.greenF(), pcolor.blueF(), pcolor.alphaF()); } if ((highlightEquivalents)&&(!parthigh)&&(atom.at(i).symmGroup)) { glColor4d(qMin(1.0,(atomColor(atom.at(i).an,isd).redF()+0.1) * 1.2), qMin(1.0,(atomColor(atom.at(i).an,isd).greenF()+0.1) * 1.2), qMin(1.0,(atomColor(atom.at(i).an,isd).blueF()+0.1) * 1.2), (wire)?0.25:1.0); } if ((atom.at(i).symmGroup)&&(atom.at(i).part<0)){ glColor4d(atomColor(atom.at(i).an,isd).redF(), atomColor(atom.at(i).an,isd).greenF(), 1.0, 0.3); pminus=1; //myStyle|=ATOM_STYLE_NOADP; } myAdp=(myStyle&ATOM_STYLE_NOADP)?0:adp; } if (wire) {myStyle|=ATOM_STYLE_SPHERE;if (myStyle&ATOM_STYLE_SOLID)myStyle-=ATOM_STYLE_SOLID; } if (tubes){ rad=bondStrength; if (atom.at(i).part==666) rad*=4.5; myAdp=0; nonPositiveDefinite=false; } if ((atom.at(i).an<0)||(atom.at(i).Label.startsWith('Q',Qt::CaseInsensitive))){ glColor4d(1.0 ,0.7, 0.8 ,0.4); if (atom.at(i).an==-42) {//belos sit! if (beloColorByDefden) Farbverlauf(atom.at(i).sof,lmin,lmax); else glColor3d(beloColor.redF(),beloColor.greenF(),beloColor.blueF()); //dodecaeder(rad); triacontaeder(beloRad); } else if (atom.at(i).an==-66) {//centroids rad*=2; glColor4d(0.6,0.3,0.1,0.3); dodecaeder(rad); }else{ if((atom.at(i).an==-1)&&(!monoQrom)) Farbverlauf(atom.at(i).peakHeight, pmin, pmax); if (monoQrom) glColor3d(mQolor.redF(),mQolor.greenF(),mQolor.blueF()); // if (!wire) icosaeder(rad); } } else { if (myAdp){ V3 ev=V3(0,0,0); double *arr=jacobi(atom.at(i).uc,ev); if ((ev.x>0)&&(ev.y>0)&&(ev.z>0)){ nonPositiveDefinite=false; glRotated(Ato4d(arr)); double psc=(parthigh)?1.1:1.0; if (atom.at(i).part==666) psc*=1.1; switch (proba ) { case 10 :{ glScaled(0.76*sqrt(ev.x)*psc,0.76*sqrt(ev.y)*psc,0.76*sqrt(ev.z)*psc);break;} //Hauptachsen der Eliipsoide 10% Wahrscheinlichkeit case 30 :{ glScaled(1.19*sqrt(ev.x)*psc,1.19*sqrt(ev.y)*psc,1.19*sqrt(ev.z)*psc);break;} //Hauptachsen der Eliipsoide 30% Wahrscheinlichkeit case 50 :{ glScaled(1.54*sqrt(ev.x)*psc,1.54*sqrt(ev.y)*psc,1.54*sqrt(ev.z)*psc);break;} //Hauptachsen der Eliipsoide 50% Wahrscheinlichkeit case 70 :{ glScaled(1.91*sqrt(ev.x)*psc,1.91*sqrt(ev.y)*psc,1.91*sqrt(ev.z)*psc);break;} //Hauptachsen der Eliipsoide 70% Wahrscheinlichkeit case 90 :{ glScaled(2.50*sqrt(ev.x)*psc,2.50*sqrt(ev.y)*psc,2.50*sqrt(ev.z)*psc);break;} //Hauptachsen der Eliipsoide 90% Wahrscheinlichkeit default: ; } }else {nonPositiveDefinite=true;} }else{ myStyle&=(ATOM_STYLE_SPHERE|ATOM_STYLE_NOADP); myStyle|=ATOM_STYLE_NOADP; } if (parthigh) { rad*=1.32; if (atom.at(i).part==666) rad*=1.2; glEnable(GL_BLEND); myStyle&=(ATOM_STYLE_SPHERE|ATOM_STYLE_NOADP); myStyle|=ATOM_STYLE_SPHERE; myStyle|=ATOM_STYLE_SOLID; } /* #define ATOM_STYLE_WALLS 1 #define ATOM_STYLE_RINGS 2 #define ATOM_STYLE_SPHERE 4 #define ATOM_STYLE_SOLID 8 #define ATOM_STYLE_WHITERING 16 #define ATOM_STYLE_NOLABEL 32 #define ATOM_STYLE_NOADP 64 */ int walls=((ATOM_STYLE_WALLS&myStyle))?1:0; //printf("style: %X walls %d %d\n",myStyle,walls,wire); if ((!wire)&&(myAdp)&&(walls)&&(!nonPositiveDefinite)) pappe(); if (atom.at(i).an>-1) { if (myAdp&&intern) { if (!nonPositiveDefinite) sphere(myAdp,myStyle); else { cube(rad); } } else if ((!myAdp)||wire||parthigh){ rad*=radScal; rad=fmax(rad,0.10); if (!myAdp) glScaled(rad,rad,rad); if (!nonPositiveDefinite) { if (wire)dratom =5; sphere(myAdp||pminus,myStyle); } else { cube(rad); } } } else icosaeder(rad); } } else{ atom[i].hidden=0; if (dratom==76){ glEnable(GL_BLEND); if (atom.at(i).an>=0) rad=arad[atom.at(i).an]; glScaled(rad,rad,rad); if (atom.at(i).sg) glColor4d(0.7,0.5,0.2,0.7); else glColor4d(0.2,0.5,0.7,0.7); sphere(0,myStyle); dratom=0; glColor4d(qMin(1.0,(atomColor(atom.at(i).an).redF()) + ((atom.at(i).sg)?0.3:-0.3)), qMin(1.0,(atomColor(atom.at(i).an).greenF()) ), qMin(1.0,(atomColor(atom.at(i).an).blueF()) + ((atom.at(i).sg)?-0.3:0.3)), 0.7); myStyle&=ATOM_STYLE_NOADP; myStyle|=ATOM_STYLE_SPHERE; myStyle|=ATOM_STYLE_SOLID; if (atom.at(i).an==-42) { glColor4d(0.8,0.6,0.1,0.8); triacontaeder(2.0); }else sphere(0,myStyle); dratom=76; } else sphere(0,myStyle); } glPopMatrix(); if (parthigh) dratom=2; } g_Program->release(); program_in_use=false; } void Molecule::Farbverlauf (GLfloat wrt,GLfloat min,GLfloat max){ if (min+0.001f>=max)max+=0.002f; GLclampd ff[4]; int lauf=0; const GLclampd farbe[6][4]={{1.0,0.0,0.0,1.0}, {1.0,1.0,0.0,1.0}, {0.0,1.0,0.0,1.0}, {0.0,1.0,1.0,1.0}, {0.0,0.0,1.0,1.0}, {1.0,0.0,1.0,1.0}}; GLfloat nwrt = (wrt - min) / (max - min); nwrt=(nwrt >= 1.0f)?0.99999f:nwrt; nwrt=(nwrt <= 0.0f)?0.00001f:nwrt; lauf=(int (nwrt/0.2f)); nwrt-=(0.2f*lauf); nwrt/=(0.2f); ff[0]=(1.0-nwrt)*farbe[lauf][0]+farbe[lauf+1][0]*nwrt; ff[1]=(1.0-nwrt)*farbe[lauf][1]+farbe[lauf+1][1]*nwrt; ff[2]=(1.0-nwrt)*farbe[lauf][2]+farbe[lauf+1][2]*nwrt; ff[3]=1.0; glColor4dv(ff); return; } void Molecule::spitze(V3 dir, V3 pos){ V3 vec=V3(0,0,1)%dir; if (Norm(vec)>0.0001) vec=Normalize(vec); else vec=V3(0,1,0); glPushMatrix(); // glTranslated (mitsav.x,mitsav.y,mitsav.z); glTranslated (pos.x,pos.y,pos.z);//Anfangspunkt double wink=acos(dir.z/sqrt(Norm(dir)))/M_PI*180.0; //printf("Winkel=%g %g (%g %g %g)(%g %g %g)\n",wink,Norm(vec),vec.x,vec.y,vec.z,dir.x,dir.y,dir.z); glRotated(wink,vec.x,vec.y,vec.z); // drehen glPushMatrix(); glScaled(0.07,0.07,0.4); myCone(); glPopMatrix(); glPopMatrix(); } void Molecule::bonds(Connection bond, double radScal){ /*! @params bond list of bonds to be drawn * draws bonds as cylinders with radius Molecule.bondStrength . * Bonds start and stop at the atom surface. */ if (bond.isEmpty())return; GLfloat white[4]={0.2f, 0.2f, 0.3f, 0.0f}; GLfloat black[4]={0.0f, 0.0f, 0.0f, 1.0f}; glDisable(GL_BLEND); glEnable(GL_ALPHA_TEST); if (nullptr==hbtex) hbtex = new QOpenGLTexture(QImage(QString(theIconPath+"hbb.png")).mirrored()); hbtex->bind(); //glBindTexture(GL_TEXTURE_2D, hbtex); //printf("Doing Bonds adp=%d proba=%d tubes%d\n",adp,proba,tubes); V3 vec,bondir; double kurz=0,ara1,ara2; double wink; bool parthigh=false; double psc=1.0; if (dratom==2) { dratom=0; parthigh=true; psc=1.32; glEnable(GL_BLEND); glDisable(GL_ALPHA_TEST); // glPolygonMode(GL_FRONT_AND_BACK,GL_LINE); }else{glDisable(GL_BLEND);} for (int i=0; ihidden) continue; if (bond.at(i).ato2->hidden) continue; if ((parthigh)&&((bond.at(i).ato1->part==0)||(bond.at(i).ato2->part==0))) continue; if ((parthigh)&&(((bond.at(i).ato1->part<0)&&(bond.at(i).ato1->symmGroup))||((bond.at(i).ato2->part<0)&&(bond.at(i).ato2->symmGroup)))) continue; if ((nopm1)&&(bond.at(i).ato1->symmGroup)&&(bond.at(i).ato1->part<0))continue; if ((nopm1)&&(bond.at(i).ato2->symmGroup)&&(bond.at(i).ato2->part<0))continue; if ((ATOM_STYLE_METAL&AtomStyle[bond.at(i).ato1->an])!=(ATOM_STYLE_METAL&AtomStyle[bond.at(i).ato2->an])){ //printf("ATOM_STYLE_METAL an1:%d an2:%d %X %X %x\n",bond.at(i).ato1->an,bond.at(i).ato2->an, // AtomStyle[bond.at(i).ato1->an],AtomStyle[bond.at(i).ato2->an],ATOM_STYLE_METAL); glEnable(GL_TEXTURE_2D); } else glDisable(GL_TEXTURE_2D); glColor4d(0.5,0.3,0.3,1.0); if (adp) { V3 hin=Normalize(bond.at(i).ato2->pos-bond.at(i).ato1->pos); double r=1; switch (proba){ case 10:r=0.76;break; case 30:r=1.19;break; case 50:r=1.54;break; case 70:r=1.91;break; case 90:r=2.50;break; } ara1=sqrt((hin*bond.at(i).ato1->uc)*hin); ara1*=r; ara2=sqrt((hin*bond.at(i).ato2->uc)*hin); ara2*=r; // printf("%s-%s %f %f %d %f\n",bond.at(i).ato1->Label.toStdString().c_str(),bond.at(i).ato2->Label.toStdString().c_str(),ara1, ara2, proba,r); } else{ ara1=arad[bond.at(i).ato1->an] * radScal; ara2=arad[bond.at(i).ato2->an] * radScal; } if (((bond.at(i).ato1->symmGroup)&&(bond.at(i).ato1->part<0))|| (ATOM_STYLE_NOADP&AtomStyle[bond.at(i).ato1->an])) ara1=arad[bond.at(i).ato1->an]; if (((bond.at(i).ato2->symmGroup)&&(bond.at(i).ato2->part<0))|| (ATOM_STYLE_NOADP&AtomStyle[bond.at(i).ato2->an])) ara2=arad[bond.at(i).ato2->an]; if (tubes) ara1=ara2=bondStrength; if (bond.at(i).ato2->an>-1) { bool isd=((bond.at(i).ato2->an==0)&&(bond.at(i).ato2->Label[0]=='D')); glColor4d(atomColor(bond.at(i).ato2->an,isd).redF(), atomColor(bond.at(i).ato2->an,isd).greenF(), atomColor(bond.at(i).ato2->an,isd).blueF(), atomColor(bond.at(i).ato2->an,isd).alphaF()); }else{ if (bond.at(i).ato1->an>-1) { bool isd=((bond.at(i).ato1->an==0)&&(bond.at(i).ato1->Label[0]=='D')); glColor4d(atomColor(bond.at(i).ato1->an,isd).redF(), atomColor(bond.at(i).ato1->an,isd).greenF(), atomColor(bond.at(i).ato1->an,isd).blueF(), atomColor(bond.at(i).ato1->an,isd).alphaF()); } } ara1=qMax(ara1,bondStrength); ara2=qMax(ara2,bondStrength); if ((highlightEquivalents)&&(bond.at(i).ato2->symmGroup|bond.at(i).ato1->symmGroup)) glMaterialfv( GL_FRONT_AND_BACK, GL_EMISSION,white ); else glMaterialfv( GL_FRONT_AND_BACK, GL_EMISSION,black ); if ((bond.at(i).ato2->symmGroup|bond.at(i).ato1->symmGroup)&&((bond.at(i).ato2->part<0)||(bond.at(i).ato1->part<0))){ // glMaterialfv( GL_FRONT_AND_BACK, GL_EMISSION,blue ); bool isd=((bond.at(i).ato2->an==0)&&(bond.at(i).ato2->Label[0]=='D')); glColor4d(atomColor(bond.at(i).ato2->an,isd).redF(), atomColor(bond.at(i).ato2->an,isd).greenF(), 1.0, 0.3); glEnable(GL_BLEND); } vec.x=(bond.at(i).ato2->pos.y-bond.at(i).ato1->pos.y); vec.y=(bond.at(i).ato1->pos.x-bond.at(i).ato2->pos.x); vec.z=0; if (Norm(vec)) vec=Normalize(vec); else vec=V3(0,1,0); bondir =V3(0,0,0); if (bondStrengthpos-bond.at(i).ato2->pos)*(0.9*sqrt((ara2*ara2)-bondStrength*bondStrength)); kurz=sqrt(Norm(bondir));// */ //printf("%s--%s kurz %f len %f ara2 %f\n",bond.at(i).ato1->Label.toStdString().c_str(),bond.at(i).ato2->Label.toStdString().c_str(),kurz,bond.at(i).length,ara2); glPushMatrix(); // glTranslated (mitsav.x,mitsav.y,mitsav.z); glTranslated ( bond.at(i).ato2->pos.x+bondir.x, bond.at(i).ato2->pos.y+bondir.y, bond.at(i).ato2->pos.z+bondir.z);//Anfangspunkt wink=acos(((bond.at(i).ato1->pos.z-bond.at(i).ato2->pos.z)/ (sqrt((bond.at(i).ato1->pos.x-bond.at(i).ato2->pos.x)*(bond.at(i).ato1->pos.x-bond.at(i).ato2->pos.x)+ (bond.at(i).ato1->pos.y-bond.at(i).ato2->pos.y)*(bond.at(i).ato1->pos.y-bond.at(i).ato2->pos.y)+ (bond.at(i).ato1->pos.z-bond.at(i).ato2->pos.z)*(bond.at(i).ato1->pos.z-bond.at(i).ato2->pos.z)))))/M_PI*180.0; glRotated(wink,vec.x,vec.y,vec.z); // drehen if (parthigh) { glEnable(GL_BLEND); QColor pcolor=PartColor::color(bond.at(i).ato1->part); pcolor.setAlpha(140); glColor4d(pcolor.redF(), pcolor.greenF(), pcolor.blueF(), pcolor.alphaF()); } //if (trans) {glEnable(GL_BLEND);glEnable(GL_CULL_FACE);} cylinder(bondStrength*psc, (float)(bond.at(i).length /2.0f -kurz)); //if (trans) {glDisable(GL_BLEND);glDisable(GL_CULL_FACE);} glPopMatrix(); if (bond.at(i).ato1->an>-1){ bool isd=(bond.at(i).ato1->an==0)&&(bond.at(i).ato1->Label[0]=='D'); glColor4d( atomColor(bond.at(i).ato1->an,isd).redF(), atomColor(bond.at(i).ato1->an,isd).greenF(), atomColor(bond.at(i).ato1->an,isd).blueF(), atomColor(bond.at(i).ato1->an,isd).alphaF()); }else { if (bond.at(i).ato2->an>-1){ bool isd=(bond.at(i).ato2->an==0)&&(bond.at(i).ato2->Label[0]=='D'); glColor4d( atomColor(bond.at(i).ato2->an,isd).redF(), atomColor(bond.at(i).ato2->an,isd).greenF(), atomColor(bond.at(i).ato2->an,isd).blueF(), atomColor(bond.at(i).ato2->an,isd).alphaF()); } } if ((bond.at(i).ato2->symmGroup|bond.at(i).ato1->symmGroup)&&((bond.at(i).ato2->part<0)||(bond.at(i).ato1->part<0))){ // glMaterialfv( GL_FRONT_AND_BACK, GL_EMISSION,blue ); if (bond.at(i).ato1->an>-1){ glColor4d(atomColor(bond.at(i).ato1->an).redF(), atomColor(bond.at(i).ato1->an).greenF(), 1.0, 0.3); } glEnable(GL_BLEND); } vec.x=(bond.at(i).ato1->pos.y-bond.at(i).ato2->pos.y); vec.y=(bond.at(i).ato2->pos.x-bond.at(i).ato1->pos.x); vec.z=0; if (Norm(vec)) vec=Normalize(vec); else vec=V3(0,1,0); bondir =V3(0,0,0); if (bondStrengthpos-bond.at(i).ato1->pos)*(0.9*sqrt((ara1*ara1)-bondStrength*bondStrength)); kurz=sqrt(Norm(bondir));// */ glPushMatrix(); // glTranslated (mitsav.x,mitsav.y,mitsav.z); glTranslated ( bond.at(i).ato1->pos.x+bondir.x, bond.at(i).ato1->pos.y+bondir.y, bond.at(i).ato1->pos.z+bondir.z);//Anfangspunkt wink=acos(((bond.at(i).ato2->pos.z-bond.at(i).ato1->pos.z)/ (sqrt((bond.at(i).ato2->pos.x-bond.at(i).ato1->pos.x)*(bond.at(i).ato2->pos.x-bond.at(i).ato1->pos.x)+ (bond.at(i).ato2->pos.y-bond.at(i).ato1->pos.y)*(bond.at(i).ato2->pos.y-bond.at(i).ato1->pos.y)+ (bond.at(i).ato2->pos.z-bond.at(i).ato1->pos.z)*(bond.at(i).ato2->pos.z-bond.at(i).ato1->pos.z)))))/M_PI*180.0; glRotated(wink,vec.x,vec.y,vec.z); // drehen //if (trans) {glEnable(GL_BLEND);glEnable(GL_CULL_FACE);} if (parthigh) { glEnable(GL_BLEND); QColor pcolor=PartColor::color(bond.at(i).ato2->part); pcolor.setAlpha(140); glColor4d(pcolor.redF(), pcolor.greenF(), pcolor.blueF(), pcolor.alphaF()); } cylinder(bondStrength*psc, (float)bond.at(i).length/2.0f-kurz); glDisable(GL_BLEND); glDisable(GL_TEXTURE_2D); glPopMatrix(); } } QString Molecule::h_bonds(Connection bond,CEnvironment atoms) { /*! calculates Hydrogen bonds and draws them as stippled cylinders * \returns a html table of the found H-bonds */ if (atoms.isEmpty())return ""; if (bond.isEmpty())return ""; glDisable(GL_CULL_FACE); if (HAMax<0.01)return ""; glEnable(GL_ALPHA_TEST); if (nullptr==hbtex) hbtex = new QOpenGLTexture(QImage(QString(theIconPath+"hbb.png")).mirrored()); hbtex->bind(); //glBindTexture(GL_TEXTURE_2D, hbtex); glEnable(GL_TEXTURE_2D); QString hbonds; double gg=0,kk=0,ll=0; double kurz=0,ara1,ara2; float wink,hb_wink; V3 vec,bondir; const MyAtom *Hyd,*Acc,*Don;//Wasserstoff Akzeptor und Donor hbonds.append("

Hydrogen Bonds

"); for (int i=0;ian == 0)&& (bond.at(i).ato2->an > 5)&& (bond.at(i).ato2->an < 9))|| ((bond.at(i).ato2->an == 0)&& (bond.at(i).ato1->an > 5)&& (bond.at(i).ato1->an < 9))) { Hyd=(bond.at(i).ato1->an==0)?bond.at(i).ato1:bond.at(i).ato2; Don=(bond.at(i).ato1->an==0)?bond.at(i).ato2:bond.at(i).ato1; for (int j=0; j8)) continue; if ((Don->part!=0)&&(atoms.at(j).part!=0)&&(atoms.at(j).part!=Don->part)) continue;//acceptor may be in main part if ((Hyd->part!=0)&&(atoms.at(j).part!=0)&&(atoms.at(j).part!=Hyd->part)) continue; //printf("%d %d %d\n",bond.at(i).ato1->an,bond.at(i).ato2->an,atoms.at(j).an); Acc=&atoms.at(j); if (Acc==Don) continue; gg=sqrt( Distance(Hyd->pos,atoms.at(j).pos)); if (gg<=HAMax){ hb_wink=winkel(Acc->pos-Hyd->pos, Don->pos-Hyd->pos); /* printf("%s %s %s %f %f\n",bond.at(i).ato1->Label.toStdString().c_str(), bond.at(i).ato2->Label.toStdString().c_str(), atoms.at(j).Label.toStdString().c_str(),gg,hb_wink);*/ if ((gg>=1.3)&&(fabs(hb_wink)>HAWink)) {//wenn AbstandRichtig ll=sqrt(Distance(Acc->pos,Don->pos)); kk=sqrt(Distance(Don->pos,Hyd->pos)); hbonds.append(QString("") .arg(Don->Label) .arg(Hyd->Label) .arg(Acc->Label) .arg(kk,6,'f',2) .arg(gg,6,'f',2) .arg(ll,6,'f',3) .arg(hb_wink,5,'f',1)); glPushMatrix(); ara1=arad[0]; ara2=arad[Acc->an]; if (adp) { V3 hin=Normalize(bond.at(i).ato2->pos-bond.at(i).ato1->pos); double r=1; switch (proba){ case 10:r=0.76;break; case 30:r=1.19;break; case 50:r=1.54;break; case 70:r=1.91;break; case 90:r=2.50;break; } ara1=sqrt((hin*bond.at(i).ato1->uc)*hin); ara1*=r; ara2=sqrt((hin*bond.at(i).ato2->uc)*hin); ara2*=r; // printf("%s-%s %f %f %d %f\n",bond.at(i).ato1->Label.toStdString().c_str(),bond.at(i).ato2->Label.toStdString().c_str(),ara1, ara2, proba,r); } if (ATOM_STYLE_NOADP&AtomStyle[bond.at(i).ato1->an])ara1=arad[0]; if (ATOM_STYLE_NOADP&AtomStyle[bond.at(i).ato2->an])ara2=arad[Acc->an]; if (tubes) ara1=ara2=bondStrength; bondir =V3(0,0,0); if (bondStrengthpos-Acc->pos)*(1.2*sqrt((ara2*ara2)-bondStrength*bondStrength)); if (bondStrengthpos.x+bondir.x,Acc->pos.y+bondir.y,Acc->pos.z+bondir.z);//z vec=kreuzX(Hyd->pos.x-Acc->pos.x, Hyd->pos.y-Acc->pos.y, Hyd->pos.z-Acc->pos.z, 0.0f,0.0f,1.0f); wink=acos(((Hyd->pos.z-Acc->pos.z)/ (sqrt((Acc->pos.x-Hyd->pos.x)*(Acc->pos.x-Hyd->pos.x)+ (Acc->pos.y-Hyd->pos.y)*(Acc->pos.y-Hyd->pos.y)+ (Acc->pos.z-Hyd->pos.z)*(Acc->pos.z-Hyd->pos.z)))))/M_PI*180.0; //printf("%f %f %f %f\n",wink, vec.x, vec.y, vec.z); glRotatef(wink, vec.x, vec.y, vec.z); // drehen //if (!adp) if (gg>2.0) glColor4f(1.f,0.6f,0.f,1.f); else glColor4f(1.f,1.f,0.f,1.f); cylinder(bondStrength*0.85, (float)gg-kurz); glPopMatrix(); } } } } } //glDisable( GL_BLEND); glDisable(GL_ALPHA_TEST); glDisable(GL_TEXTURE_2D); glEnable( GL_CULL_FACE); if (hbonds.contains("deg;")) hbonds.append("
Donor---Hydrogen...AcceptorDon--Hyd [Å] Hyd--Acc [Å]Don--Acc [Å]D--H-----A
%1---%2...%3%4%5%6%7°

"); else hbonds.clear(); return hbonds; } void Molecule::h_bonds2(Connection bond,CEnvironment atoms) { /*! calculates Hydrogen bonds and draws them as stippled cylinders */ if (bond.isEmpty())return; glDisable(GL_CULL_FACE); if (HAMax<0.01)return ; glEnable(GL_ALPHA_TEST); //glBindTexture(GL_TEXTURE_2D, hbtex); hbtex->bind(); glEnable(GL_TEXTURE_2D); double gg=0;//,kk=0,ll=0; double kurz=0,ara1,ara2; float wink,hb_wink; V3 vec,bondir; MyBond hbond; theH_Bonds.clear(); //printf("h_bonds2\n"); const MyAtom *Hyd,*Acc,*Don;//Wasserstoff Akzeptor und Donor for (int i=0;ian == 0)&&(canbeDonor(bond.at(i).ato2->an)))|| ((bond.at(i).ato2->an == 0)&&(canbeDonor(bond.at(i).ato1->an)))) { Hyd=(bond.at(i).ato1->an==0)?bond.at(i).ato1:bond.at(i).ato2; int iHyd=(bond.at(i).ato1->an==0)?bond.at(i).a1:bond.at(i).a2; Don=(bond.at(i).ato1->an==0)?bond.at(i).ato2:bond.at(i).ato1; for (int j=0; jpart!=0)&&(atoms.at(j).part!=0)&&((bindPart.key(Don->part)==atoms.at(j).part)|| (bindPart.value(Don->part)==atoms.at(j).part))); else if ((Don->part!=0)&&(atoms.at(j).part!=0)&&(atoms.at(j).part!=Don->part)) continue;//acceptor may be in main part if ((Hyd->part!=0)&&(atoms.at(j).part!=0)&&((bindPart.key(Hyd->part)==atoms.at(j).part)|| (bindPart.value(Hyd->part)==atoms.at(j).part))); else if ((Hyd->part!=0)&&(atoms.at(j).part!=0)&&(atoms.at(j).part!=Hyd->part)) continue; //printf("%d %d %d\n",bond.at(i).ato1->an,bond.at(i).ato2->an,atoms.at(j).an); Acc=&atoms.at(j); if (Acc==Don) continue; gg=sqrt( Distance(Hyd->pos,atoms.at(j).pos)); if (gg<=HAMax){ hb_wink=winkel(Acc->pos-Hyd->pos, Don->pos-Hyd->pos); /* printf("%s %s %s %f %f\n",bond.at(i).ato1->Label.toStdString().c_str(), bond.at(i).ato2->Label.toStdString().c_str(), atoms.at(j).Label.toStdString().c_str(),gg,hb_wink);*/ if ((gg>=1.3)&&(fabs(hb_wink)>HAWink)) {//wenn AbstandRichtig //ll=sqrt(Distance(Acc->pos,Don->pos)); //kk=sqrt(Distance(Don->pos,Hyd->pos)); glPushMatrix(); ara1=arad[0]; ara2=arad[Acc->an]; if (adp) { V3 hin=Normalize(bond.at(i).ato2->pos-bond.at(i).ato1->pos); double r=1; switch (proba){ case 10:r=0.76;break; case 30:r=1.19;break; case 50:r=1.54;break; case 70:r=1.91;break; case 90:r=2.50;break; } ara1=sqrt((hin*bond.at(i).ato1->uc)*hin); ara1*=r; ara2=sqrt((hin*bond.at(i).ato2->uc)*hin); ara2*=r; // printf("%s-%s %f %f %d %f\n",bond.at(i).ato1->Label.toStdString().c_str(),bond.at(i).ato2->Label.toStdString().c_str(),ara1, ara2, proba,r); } if (ATOM_STYLE_NOADP&AtomStyle[bond.at(i).ato1->an])ara1=arad[0]; if (ATOM_STYLE_NOADP&AtomStyle[bond.at(i).ato2->an])ara2=arad[Acc->an]; if (tubes) ara1=ara2=bondStrength; bondir =V3(0,0,0); if (bondStrengthpos-Acc->pos)*(1.2*sqrt((ara2*ara2)-bondStrength*bondStrength)); if (bondStrengthpos.x+bondir.x,Acc->pos.y+bondir.y,Acc->pos.z+bondir.z);//z vec=kreuzX(Hyd->pos.x-Acc->pos.x, Hyd->pos.y-Acc->pos.y, Hyd->pos.z-Acc->pos.z, 0.0f,0.0f,1.0f); wink=acos(((Hyd->pos.z-Acc->pos.z)/ (sqrt((Acc->pos.x-Hyd->pos.x)*(Acc->pos.x-Hyd->pos.x)+ (Acc->pos.y-Hyd->pos.y)*(Acc->pos.y-Hyd->pos.y)+ (Acc->pos.z-Hyd->pos.z)*(Acc->pos.z-Hyd->pos.z)))))/M_PI*180.0; //printf("%f %f %f %f\n",wink, vec.x, vec.y, vec.z); glRotatef(wink, vec.x, vec.y, vec.z); // drehen //if (!adp) if (gg>2.0) glColor4f(1.f,0.6f,0.f,1.f); else glColor4f(1.f,1.f,0.f,1.f); cylinder(bondStrength*0.85, (float)gg-kurz); glPopMatrix(); hbond.a1=iHyd; hbond.a2=j; hbond.ato1=Hyd; hbond.ato2=Acc; hbond.length=gg; if (!theH_Bonds.contains(hbond)) theH_Bonds.append(hbond); } } } } } //glDisable( GL_BLEND); glDisable(GL_ALPHA_TEST); glDisable(GL_TEXTURE_2D); glEnable( GL_CULL_FACE); } void Molecule::h_bonds3(Connection bond,CEnvironment atoms) { /*! calculates Hydrogen bonds */ if (bond.isEmpty())return; if (HAMax<0.01)return ; double gg=0;//,kk=0,ll=0; float wink,hb_wink; MyBond hbond; theH_Bonds.clear(); const MyAtom *Hyd,*Acc,*Don;//Wasserstoff Akzeptor und Donor for (int i=0;ian == 0)&&(canbeDonor(bond.at(i).ato2->an)))|| ((bond.at(i).ato2->an == 0)&&(canbeDonor(bond.at(i).ato1->an)))) { Hyd=(bond.at(i).ato1->an==0)?bond.at(i).ato1:bond.at(i).ato2; int iHyd=(bond.at(i).ato1->an==0)?bond.at(i).a1:bond.at(i).a2; Don=(bond.at(i).ato1->an==0)?bond.at(i).ato2:bond.at(i).ato1; for (int j=0; jpart!=0)&&(atoms.at(j).part!=0)&&((bindPart.key(Don->part)==atoms.at(j).part)|| (bindPart.value(Don->part)==atoms.at(j).part))); else if ((Don->part!=0)&&(atoms.at(j).part!=0)&&(atoms.at(j).part!=Don->part)) continue;//acceptor may be in main part if ((Hyd->part!=0)&&(atoms.at(j).part!=0)&&((bindPart.key(Hyd->part)==atoms.at(j).part)|| (bindPart.value(Hyd->part)==atoms.at(j).part))); else if ((Hyd->part!=0)&&(atoms.at(j).part!=0)&&(atoms.at(j).part!=Hyd->part)) continue; Acc=&atoms.at(j); if (Acc==Don) continue; gg=sqrt( Distance(Hyd->pos,atoms.at(j).pos)); if (gg<=HAMax){ hb_wink=winkel(Acc->pos-Hyd->pos, Don->pos-Hyd->pos); if ((gg>=1.3)&&(fabs(hb_wink)>HAWink)) {//wenn AbstandRichtig hbond.a1=iHyd; hbond.a2=j; hbond.ato1=Hyd; hbond.ato2=Acc; hbond.length=gg; if (!theH_Bonds.contains(hbond)) theH_Bonds.append(hbond); } } } } } } void Molecule::hirsh(Connection bond){ return; V3 hin; // double zab,zba; for (int i=0; ipos-bond.at(i).ato1->pos); // zab=(hin*bond.at(i).ato1->uc)*hin; // zba=(hin*bond.at(i).ato2->uc)*hin; /* printf("%-9s = %-9s zab %g zba %g %g\n", bond.at(i).ato1->Label.toStdString().c_str(), bond.at(i).ato2->Label.toStdString().c_str(), zab,zba,fabs(zab-zba)*1000);*/ } } void Molecule::lbond(){ /*! draws line bonds from lbonds list. */ if (lbonds.isEmpty())return; //glPushMatrix(); glLineWidth(q_bondWidth); glEnable(GL_BLEND); glDisable(GL_LIGHTING); glBegin(GL_LINES); glColor3f(0.5f,0.3f,0.3f); for (int i=0; ihidden+lbonds.at(i).ato2->hidden==0){ glVertex3d(lbonds.at(i).ato1->pos.x,lbonds.at(i).ato1->pos.y,lbonds.at(i).ato1->pos.z); glVertex3d(lbonds.at(i).ato2->pos.x,lbonds.at(i).ato2->pos.y,lbonds.at(i).ato2->pos.z); } glEnd(); glEnable(GL_LIGHTING); glDisable(GL_BLEND); glLineWidth(1.0f); //glPopMatrix(); } void Molecule::dbond(Connection bond,int ccod){ /*! draws line bonds from bond list . */ if (bond.isEmpty())return; glEnable(GL_BLEND); glDisable(GL_LIGHTING); glLineWidth((ccod==76)?6.f:3.f); glBegin(GL_LINES); glColor3f(0.0,0.0,0.0); for (int i=0; isg) glColor4d(0.7,0.5,0.2,0.7); else glColor4d(0.2,0.5,0.7,0.7); } if (bond.at(i).ato1->hidden+bond.at(i).ato2->hidden==0){ glVertex3d(bond.at(i).ato1->pos.x,bond.at(i).ato1->pos.y,bond.at(i).ato1->pos.z); glVertex3d(bond.at(i).ato2->pos.x,bond.at(i).ato2->pos.y,bond.at(i).ato2->pos.z); } } glEnd(); glEnable(GL_LIGHTING); glDisable(GL_BLEND); glLineWidth(1.0f); } void Molecule::unitCell(){ /*!draws a unit cell box * * */ V3 uz0f,uz1f,uz2f,uz3f,uz4f,uz5f,uz6f,uz7f; V3 uz0k,uz1k,uz2k,uz3k,uz4k,uz5k,uz6k,uz7k; uz0f.x=0.0; uz0f.y=0.0; uz0f.z=0.0; uz1f.x=1.0; uz1f.y=0.0; uz1f.z=0.0; uz2f.x=0.0; uz2f.y=1.0; uz2f.z=0.0; uz3f.x=0.0; uz3f.y=0.0; uz3f.z=1.0; uz4f.x=1.0; uz4f.y=1.0; uz4f.z=0.0; uz5f.x=1.0; uz5f.y=0.0; uz5f.z=1.0; uz6f.x=0.0; uz6f.y=1.0; uz6f.z=1.0; uz7f.x=1.0; uz7f.y=1.0; uz7f.z=1.0; frac2kart(uz0f,uz0k); frac2kart(uz1f,uz1k); frac2kart(uz2f,uz2k); frac2kart(uz3f,uz3k); frac2kart(uz4f,uz4k); frac2kart(uz5f,uz5k); frac2kart(uz6f,uz6k); frac2kart(uz7f,uz7k); glEnable(GL_BLEND); glDisable(GL_LIGHTING); glLineWidth(2); //glPushMatrix(); glBegin(GL_LINES); glColor4f(1.0f,0.0f,0.0f,1.0); glVertex3d(uz0k.x,uz0k.y,uz0k.z); glVertex3d(uz1k.x,uz1k.y,uz1k.z); glColor4f(0.0f,1.0f,0.0f,1.0); glVertex3d(uz0k.x,uz0k.y,uz0k.z); glVertex3d(uz2k.x,uz2k.y,uz2k.z); glColor4f(0.0f,0.0f,1.0f,1.0); glVertex3d(uz0k.x,uz0k.y,uz0k.z); glVertex3d(uz3k.x,uz3k.y,uz3k.z); glColor4f(0.6f,0.6f,0.8f,1.0); glVertex3d(uz1k.x,uz1k.y,uz1k.z); glVertex3d(uz4k.x,uz4k.y,uz4k.z); glVertex3d(uz1k.x,uz1k.y,uz1k.z); glVertex3d(uz5k.x,uz5k.y,uz5k.z); glVertex3d(uz2k.x,uz2k.y,uz2k.z); glVertex3d(uz4k.x,uz4k.y,uz4k.z); glVertex3d(uz2k.x,uz2k.y,uz2k.z); glVertex3d(uz6k.x,uz6k.y,uz6k.z); glVertex3d(uz3k.x,uz3k.y,uz3k.z); glVertex3d(uz5k.x,uz5k.y,uz5k.z); glVertex3d(uz3k.x,uz3k.y,uz3k.z); glVertex3d(uz6k.x,uz6k.y,uz6k.z); glVertex3d(uz7k.x,uz7k.y,uz7k.z); glVertex3d(uz5k.x,uz5k.y,uz5k.z); glVertex3d(uz7k.x,uz7k.y,uz7k.z); glVertex3d(uz4k.x,uz4k.y,uz4k.z); glVertex3d(uz7k.x,uz7k.y,uz7k.z); glVertex3d(uz6k.x,uz6k.y,uz6k.z); glEnd(); //glPopMatrix(); glLineWidth(1); glEnable(GL_LIGHTING); glDisable(GL_BLEND); } void Molecule::Uf2Uo(const Matrix x, Matrix & y) { /*! Turns fractional Uij's into cartesinan based Uij's. * @param[in] x fractional Uij matrix. * @param[out] y cartesinan Uij matrix. */ Matrix o,a,w; /*Cholesky decomposition of the real space Metric tensor Wird fuer die Umrechnung von fraktionellen in kartesischen Korrdinaten benoetigt.*/ a.m11 =cell.as; a.m12 = 0; a.m13 = 0; a.m21 = 0; a.m22 = cell.bs; a.m23 = 0; a.m31 = 0; a.m32 = 0; a.m33 = cell.cs; w=(a*x)*a; o.m11 =cell.a; o.m12 = 0.0; o.m13 = 0.0; o.m21 = cell.b*cell.cosga; o.m22 = cell.b*cell.singa; o.m23 = 0.0; o.m31 = cell.c* cell.cosbe; o.m32 = cell.tau; o.m33 = cell.c* cell.phi / cell.singa ; // Matrix to=; y=(o*w)*transponse(o); /* printf("%f %f %f %f %f %f %f %f %f\n%f %f %f %f %f %f %f %f %f\n%f %f %f %f %f %f %f %f %f\n%f %f %f %f %f %f %f %f %f\n", o.m11,o.m12,o.m13,o.m21,o.m22,o.m23,o.m31,o.m32,o.m33, to.m11,to.m21,to.m31,to.m12,to.m22,to.m32,to.m13,to.m23,to.m33, x.m11,x.m12,x.m13,x.m21,x.m22,x.m23,x.m31,x.m32,x.m33, w.m11,w.m12,w.m13,w.m21,w.m22,w.m23,w.m31,w.m32,w.m33 );*/ // printf("%f %f %f %f %f %f\n",y.m11*10000,y.m22*10000,y.m33*10000,y.m12*10000,y.m13*10000,y.m23*10000);// */ } void Molecule::Usym (Matrix x,Matrix sym, Matrix & y){ /*! Applies the symmetry matrix sym to Uij's * @param[in] x Uij matrix. * @param[in] sym symmtry matrix. * @param[out] y resulting Uij matrix. */ //y=(transponse(sym)*x)*sym; y=(sym*x)*transponse(sym); } void Molecule::USymCode(Matrix x,int scod, Matrix & y){ int s = scod / 1000; y=(cell.symmops.at(s)*x)*transponse(cell.symmops.at(s)); } //void Molecule:: #define ROTATE(a,i,j,k,l) g=a[i][j];h=a[k][l];a[i][j]=g-s*(h+g*tau); a[k][l]=h+s*(g-h*tau); //NumericalRecepies.... double * Molecule::jacobi(const Matrix &uij, V3 &ev) { int j,iq,ip,i,n=3,nrot; double tresh=0,theta,tau,t,sm,s,h,g,c; double a[3][3],b[3],z[3],v[3][3],d[3]; a[0][0]=uij.m11; a[0][1]=uij.m12; a[0][2]=uij.m13; a[1][0]=uij.m21; a[1][1]=uij.m22; a[1][2]=uij.m23; a[2][0]=uij.m31; a[2][1]=uij.m32; a[2][2]=uij.m33; /* printf("%12.6f %12.6f %12.6f\n%12.6f %12.6f %12.6f\n%12.6f %12.6f %12.6f\n" ,a[0][0],a[1][0],a[2][0] ,a[0][1],a[1][1],a[2][1] ,a[0][2],a[1][2],a[2][2]);*/ static double erg[4]={0.0,1.0,0.0,0.0}; for (ip=1;ip<=n;ip++) { for (iq=1;iq<=n;iq++) v[ip-1][iq-1]=0.0; v[ip-1][ip-1]=1.0; } for (ip=1;ip<=n;ip++) { b[ip-1]=d[ip-1]=a[ip-1][ip-1]; z[ip-1]=0.0; } nrot=0; for (i=1;i<=150;i++) { sm=0.0; for (ip=1;ip<=n-1;ip++) { for (iq=ip+1;iq<=n;iq++) sm += fabs(a[ip-1][iq-1]); } //printf("sm =%20.19f\n",sm); if (float(sm) < tresh) { if ((v[0][0]+v[1][1]+v[2][2])!=3.0) { erg[0]=acos((v[0][0]+v[1][1]+v[2][2]-1.0)/2.0); erg[1]=(v[2][1]-v[1][2])/(2.0*sin(erg[0])); erg[2]=(v[0][2]-v[2][0])/(2.0*sin(erg[0])); erg[3]=(v[1][0]-v[0][1])/(2.0*sin(erg[0])); erg[0]*=180.0/M_PI;} else {erg[0]=0.0;erg[1]=1.0;erg[2]=0.0;erg[3]=0.0; } //printf("%d??ERG:%f %f %f %f\n",i,Ato4d(erg)); /* printf("=%d======================================\n%8.5f %8.5f %8.5f \n%8.5f %8.5f %8.5f \n%8.5f %8.5f %8.5f \n%8.5f %8.5f %8.5f\n========================================\n",i, d[0],d[1],d[2],v[0][0],v[0][1],v[0][2] ,v[1][0],v[1][1],v[1][2] ,v[2][0],v[2][1],v[2][2] );*/ ev=V3(d[0],d[1],d[2]); /* printf("\n%12.6f %12.6f %12.6f\n%12.6f %12.6f %12.6f\n%12.6f %12.6f %12.6f\n" ,v[0][0],v[1][0],v[2][0] ,v[0][1],v[1][1],v[2][1] ,v[0][2],v[1][2],v[2][2]); if ((ev.x>0)&&(ev.y>0)&&(ev.z>0)){;}else{ printf("NPD: %g %g %g \n",d[0],d[1],d[2]); }*/ return (double*) erg; } if (i < 4) tresh=0.00001; else tresh=0.0001; for (ip=1;ip<=n-1;ip++) { for (iq=ip+1;iq<=n;iq++) { //printf("\np:%i q:%i i:%i nrot:%i\n",ip,iq,i,nrot); g=100.0*fabs(a[ip-1][iq-1]); if ((i > 4) && ((fabs(d[ip-1])+g) == fabs(d[ip-1])) && ((fabs(d[iq-1])+g) == fabs(d[iq-1]))) {a[ip-1][iq-1]=0.0;} else if (fabs(a[ip-1][iq-1]) >= tresh) { h=d[iq-1]-d[ip-1]; if ((fabs(h)+g) == fabs(h)) {t=(a[ip-1][iq-1])/h; } else { theta=0.5*h/(a[ip-1][iq-1]); t=1.0/(fabs(theta)+sqrt(1.0+theta*theta)); if (theta < 0.0) {t = -1.0*t;} } c=1.0/sqrt(1+t*t); s=t*c; tau=s/(1.0+c); h=t*a[ip-1][iq-1]; z[ip-1] -= h; z[iq-1] += h; d[ip-1] -= h; d[iq-1] += h; a[ip-1][iq-1]=0.0; for (j=1;j<=ip-1;j++) { ROTATE(a,j-1,ip-1,j-1,iq-1) //printf("%i %i %i %i",j,ip,j,iq); } for (j=ip+1;j<=iq-1;j++) { ROTATE(a,ip-1,j-1,j-1,iq-1) //printf("%i %i %i %i ",ip,j,j,iq); } for (j=iq+1;j<=n;j++) { ROTATE(a,ip-1,j-1,iq-1,j-1) //printf("%i %i %i %i",ip,j,iq,j); } for (j=1;j<=n;j++) { ROTATE(v,j-1,ip-1,j-1,iq-1) } ++(nrot); // printf("U|\n%f %f %f \n%f %f %f\n%f %f %f\nV|\n%f %f %f \n%f %f %f\n%f %f %f\n\n",a[0][0],a[1][0],a[2][0],a[0][1],a[1][1],a[2][1],a[0][2],a[1][2],a[2][2],v[0][0],v[1][0],v[2][0],v[0][1],v[1][1],v[2][1],v[0][2],v[1][2],v[2][2]); } //else ;//printf("nix:%f p%i q%i",fabs(a[ip-1][iq-1]),ip,iq); } } for (ip=1;ip<=n;ip++) { b[ip-1] += z[ip-1]; d[ip-1] =b[ip-1]; z[ip-1] =0.0; } } erg[0]=acos((v[0][0]+v[1][1]+v[2][2]-1.0)/2.0); if (erg[0]==0) { erg[1]=1.0; erg[2]=0.0; erg[3]=0.0; }else{ erg[1]=(v[2][1]-v[1][2])/(2.0*sin(erg[0])); erg[2]=(v[0][2]-v[2][0])/(2.0*sin(erg[0])); erg[3]=(v[1][0]-v[0][1])/(2.0*sin(erg[0])); erg[0]*=180.0/M_PI; } /*printf("=%d=======================================\n%8.5f %8.5f %8.5f \n%8.5f %8.5f %8.5f \n%8.5f %8.5f %8.5f \n%8.5f %8.5f %8.5f\n========================================\n",i, d[0],d[1],d[2],v[0][0],v[0][1],v[0][2] ,v[1][0],v[1][1],v[1][2] ,v[2][0],v[2][1],v[2][2] );*/ ev=V3(d[0],d[1],d[2]); /* if ((ev.x>0)&&(ev.y>0)&&(ev.z>0)){;}else{ printf("NPD: %g %g %g \n",d[0],d[1],d[2]); }*/ return (double*)erg; } void Molecule::fuse(){ /*! reduces the showatoms list to the asymmetric unit. * */ HumanSymmetry=QString("Used Symmetry:
%1").arg(symmcode2human(QStringList())); usedSymmetry.clear(); //printf("FUSE\n"); showatoms.clear(); for (int i=0; i grow\n"); showatoms.clear(); for (int i=0; i0.001)&&(dddd>=dk)) { bs=QString("%1_%2%3%4:%5,").arg(n+1).arg(5-(int)floorD.x).arg(5-(int)floorD.y).arg(5-(int)floorD.z).arg(asymm[sdm.at(k).a1].molindex); // printf("%s %s %g %g\n",asymm[sdm.at(k).a1].Label.toStdString().c_str(),asymm[sdm.at(k).a2].Label.toStdString().c_str(),sdm.at(k).d,dddd); // printf("(grow)%s\n",bs.toStdString().c_str()); if ((!brauchSymm.contains(bs))) { brauchSymm.append(bs); } } } } } for (int i=0; i-1)&& (asymm[ii].resiNr!=a1.resiNr)) continue; if ((a2.resiNr>-1)&& (asymm[ii].resiNr!=a2.resiNr)) continue; if (asymm[ii].Label.section('_',0,0).toUpper() == a1.Label.toUpper()){ frag1=asymm[ii].molindex; } if (asymm[ii].Label.section('_',0,0).toUpper() == a2.Label.toUpper()){ frag2=asymm[ii].molindex; } } QString ss; QList smm; QList tmm; int syy1=-1; if (sy1>-1) syy1=labelEQIV.indexOf(QString("$%1").arg(sy1)); if (syy1>-1) { smm.append(symmopsEQIV.at(syy1)); tmm.append(transEQIV.at(syy1)); } int syy2=-1; if (sy2>-1) syy2=labelEQIV.indexOf(QString("$%1").arg(sy2)); if (syy2>-1) { smm.append(symmopsEQIV.at(syy2)); tmm.append(transEQIV.at(syy2)); } for (int ui=0; ui-1)&&(!ui))?frag1:frag2); if (!brauchSymm.contains(ss)) { brauchSymm.append(ss); eqivMap[labelEQIV.at(((sy1>-1)&&(!ui))?sy1-1:sy2-1)]=brauchSymm.size(); // printf("%d ==> %d %s\n",sy2-1, brauchSymm.size(),labelEQIV.at(((sy1>-1)&&(!ui))?sy1-1:sy2-1).toStdString().c_str()); } } } } } } /* for (int i=0; isdm.at(i).d){ bs=QString("%1_%2%3%4:%5,").arg(sdm.at(i).sn+1).arg(5-(int)sdm.at(i).floorD.x).arg(5-(int)sdm.at(i).floorD.y).arg(5-(int)sdm.at(i).floorD.z).arg(asymm[sdm.at(i).a1].molindex); / * printf("%s %f %s %s\n",bs.toStdString().c_str(),sdm.at(i).d, asymm[sdm.at(i).a1].Label.toStdString().c_str(), asymm[sdm.at(i).a2].Label.toStdString().c_str()); * / if (!brauchSymm.contains(bs)) { brauchSymm.append(bs); } } } */ //packer(brauchSymm); usedSymmetry+=brauchSymm; //complete(); // printf("GROW\n"); packer(brauchSymm); showbonds.clear(); showbonds=connecting(showatoms); } void Molecule::grow_plus(){ /*! completes covalent bound molecule fragments. * * */ showatoms.clear(); for (int i=0; i0.001)&&(dddd>=dk)) { bs=QString("%1_%2%3%4:%5,").arg(n+1).arg(5-(int)floorD.x).arg(5-(int)floorD.y).arg(5-(int)floorD.z).arg(asymm[sdm.at(k).a1].molindex); // printf("%s %s %g %g\n",asymm[sdm.at(k).a1].Label.toStdString().c_str(),asymm[sdm.at(k).a2].Label.toStdString().c_str(),sdm.at(k).d,dddd); // printf("(grow)%s\n",bs.toStdString().c_str()); if ((!brauchSymm.contains(bs))) { brauchSymm.append(bs); } } } } } for (int i=0; i-1)&& (asymm[ii].resiNr!=a1.resiNr)) continue; if ((a2.resiNr>-1)&& (asymm[ii].resiNr!=a2.resiNr)) continue; if (asymm[ii].Label.section('_',0,0).toUpper() == a1.Label.toUpper()){ frag1=asymm[ii].molindex; } if (asymm[ii].Label.section('_',0,0).toUpper() == a2.Label.toUpper()){ frag2=asymm[ii].molindex; } } QString ss; QList smm; QList tmm; int syy1=-1; if (sy1>-1) syy1=labelEQIV.indexOf(QString("$%1").arg(sy1)); if (syy1>-1) { smm.append(symmopsEQIV.at(syy1)); tmm.append(transEQIV.at(syy1)); } int syy2=-1; if (sy2>-1) syy2=labelEQIV.indexOf(QString("$%1").arg(sy2)); if (syy2>-1) { smm.append(symmopsEQIV.at(syy2)); tmm.append(transEQIV.at(syy2)); } for (int ui=0; ui-1)&&(!ui))?frag1:frag2); if (!brauchSymm.contains(ss)) { brauchSymm.append(ss); // printf("### %d = %d\n",((sy1>-1)&&(!ui))?sy1:sy2,brauchSymm.size()); eqivMap[labelEQIV.at(((sy1>-1)&&(!ui))?sy1-1:sy2-1)]=brauchSymm.size(); // qDebug()<sdm.at(i).d){ bs=QString("%1_%2%3%4:%5,").arg(sdm.at(i).sn+1).arg(5-(int)sdm.at(i).floorD.x).arg(5-(int)sdm.at(i).floorD.y).arg(5-(int)sdm.at(i).floorD.z).arg(asymm[sdm.at(i).a1].molindex); / * printf("%s %f %s %s\n",bs.toStdString().c_str(),sdm.at(i).d, asymm[sdm.at(i).a1].Label.toStdString().c_str(), asymm[sdm.at(i).a2].Label.toStdString().c_str()); * / if (!brauchSymm.contains(bs)) { brauchSymm.append(bs); } } } */ //packer(brauchSymm); usedSymmetry+=brauchSymm; complete(); showbonds.clear(); showbonds=connecting(showatoms); } void Molecule::packPoint(const V3 &prime, QList &wearein){//!< Pack inside cell //wearein.clear(); V3 p; double dawars=1000.0,dl; const double ami = 0.0, ama = 1.0, bmi = 0.0, bma = 1.0, cmi = 0.0, cma = 1.0; dawars=1000.0; for (int g=0; g0.01){ for (int hh=-11; hh<12; hh++){ for (int kk=-11; kk<12; kk++){ for (int ll=-11; ll<12; ll++){ if ((prime.x+hh)ama) continue; if ((prime.y+kk)>bma) continue; if ((prime.z+ll)>cma) continue; p=prime+V3(static_cast(hh),static_cast(kk),static_cast(ll)); //printf("=>%g %g %g \n",p.x,p.y,p.z); wearein.append(p); }//ll }//kk }//hh } } void Molecule::packLine(const V3 &p1,const V3 &p2, QList &wearein, int c, QList &dc){//!< Pack inside cell V3 prime,dprime,pA,pB; //wearein.clear(); //double dawars=1000.0,dawars2=1000.0,dl; const double ami = -0.001, ama = 1.001, bmi = -0.001, bma = 1.001, cmi = -0.001, cma = 1.001; //for (int n=0; nama) continue; if ((prime.y+kk)>bma) continue; if ((prime.z+ll)>cma) continue; if ((dprime.x+hh)ama) continue; if ((dprime.y+kk)>bma) continue; if ((dprime.z+ll)>cma) continue; pA=prime+V3(static_cast(hh),static_cast(kk),static_cast(ll)); pB=dprime+V3(static_cast(hh),static_cast(kk),static_cast(ll)); int bi=-1, ai = wearein.indexOf(pA); if (ai>-1) bi = wearein.indexOf(pB); if (fabs(0.0+ai-bi)!=1.0){ //printf("we are in %d %d %g\n",wearein.indexOf(pA),wearein.indexOf(pB),fabs(0.0+ai-bi)); //printf("a=>%g %g %g %d:%d%d%d\n",pA.x, pA.y, pA.z, n+1,5+hh,5+kk,5+ll); //printf("b=>%g %g %g %d:%d%d%d\n",pB.x, pB.y, pB.z, n+1,5+hh,5+kk,5+ll); wearein.append(pA); dc.append(c); wearein.append(pB); dc.append(c); } }//ll }//kk }//hh }//n++ } void Molecule::packInLimits(double ami, double ama, double bmi, double bma, double cmi, double cma){//!< Pack inside given limits (eg multiple unit cells) MyAtom newAtom; newAtom.hidden=0; V3 prime,floorD; double dawars=1000.0,dl; for (int n=0; n-1)&&(asymm.at(i).molindex>0)) { prime=cell.symmops.at(n) * asymm.at(i).frac + cell.trans.at(n); floorD=V3(floor(prime.x),floor(prime.y),floor(prime.z)); //prime=prime -floorD; dawars=1000.0; for (int g=0; gama) continue; if ((prime.y+kk)>bma) continue; if ((prime.z+ll)>cma) continue; newAtom.part=asymm[i].part; newAtom.frac=prime+V3((double)hh,(double)kk,(double)ll); frac2kart(newAtom.frac,newAtom.pos); newAtom.an=asymm[i].an; newAtom.molindex=asymm[i].molindex; newAtom.peakHeight=asymm[i].peakHeight; newAtom.resiNr=asymm[i].resiNr; newAtom.sof=asymm[i].sof; newAtom.Label=asymm[i].Label; newAtom.isIso=asymm[i].isIso; newAtom.ufiso_org=asymm[i].ufiso_org; newAtom.sof_org=asymm[i].sof_org; newAtom.symmGroup=1; newAtom.sg=n; // printf("A%d %d %d %d %g %g %g\n", n, hh, kk, ll, floorD.x, floorD.y, floorD.z); newAtom.scod = genSymCode(n,hh,kk,ll);//genSymCode(n,(int)(hh+floorD.x),(int)(kk+floorD.x),(int)(ll+floorD.x));//genSymCode(n,hh,kk,ll); newAtom.auidx = i; if ((asymm[i].uc.m12==0.0)&&(asymm[i].uc.m23==0.0)&&(asymm[i].uc.m13==0.0)){ newAtom.uf.m11=newAtom.uc.m11=newAtom.uc.m22=newAtom.uc.m33=asymm[i].uf.m11; newAtom.uc.m12=newAtom.uc.m13=newAtom.uc.m23=newAtom.uc.m21=newAtom.uc.m31=newAtom.uc.m32=0.0; } else { Usym(asymm[i].uf,cell.symmops[n],newAtom.uf); Uf2Uo(newAtom.uf,newAtom.uc); } showatoms.append(newAtom); }//ll }//packable // else if ((asymm.at(i).an<0)&&(n==0)) showatoms.append(asymm[i]);//non atoms BCPs, Dummys, etc. }//i++ }//n++ showbonds.clear(); showbonds=connecting(showatoms); } CEnvironment Molecule::packInLimits(CEnvironment &au, double ami, double ama, double bmi, double bma, double cmi, double cma){//!< Pack inside given limits (eg multiple unit cells) MyAtom newAtom; CEnvironment sa; newAtom.hidden=0; V3 prime,floorD; //double dawars=1000.0,dl; for (int n=0; nama) continue; if ((prime.y+kk)>bma) continue; if ((prime.z+ll)>cma) continue; newAtom.frac=prime+V3((double)hh, (double)kk, (double)ll); frac2kart(newAtom.frac,newAtom.pos); newAtom.an=au[i].an; newAtom.peakHeight=au[i].peakHeight; newAtom.sof=au[i].sof; newAtom.Label=au[i].Label; newAtom.isIso=au[i].isIso; newAtom.ufiso_org=au[i].ufiso_org; newAtom.sof_org=au[i].sof_org; newAtom.symmGroup=1; newAtom.sg=n; newAtom.scod = genSymCode(n,hh,kk,ll); // printf("B%d %d %d %d %g %g %g\n", n, hh, kk, ll, floorD.x, floorD.y, floorD.z); //newAtom.scod = genSymCode(n,(int)(hh-floorD.x),(int)(kk-floorD.x),(int)(ll-floorD.x)); newAtom.auidx = i; Usym(au[i].uf,cell.symmops[n],newAtom.uf); sa.append(newAtom); }//ll }//i++ }//n++ return sa; } void Molecule::fillCell(){ /*! Fills the unit cell with molecules. * * */ // packInLimits(0.0, 1.0, 0.0, 1.0, 0.0, 1.0); // return; showatoms.clear(); for (int i=0; i=showatoms.size()) return; // V3 expander= showatoms.at(index).frac; V3 prime,floorD,D; double SUCHRAD=3.2; for (int i=0; i0)) { brauchSymm.append(bs); } } } } } showatoms.clear(); for (int i=0; i=showatoms.size()) return; // V3 expander= showatoms.at(index).frac; V3 prime,floorD,D; QStringList brauchSymm; QString bs; // brauchSymm.clear(); if (usedSymmetry.isEmpty()){ QList scods; for (int i=0; i0)) { brauchSymm.append(bs); } } } } } } showatoms.clear(); for (int i=0; i=showatoms.size()) return; V3 expander= showatoms.at(index).frac; V3 prime,floorD,D; double SUCHRAD=3.2; for (int i=0; i0)) { brauchSymm.append(bs); } } } } showatoms.clear(); for (int i=0; isetMinimum(0); // balken->setMaximum(brauchSymm.size()); // balken->show(); HumanSymmetry=QString("Used Symmetry:
%1").arg(symmcode2human(brauchSymm)); QString pre,suff; for (int j=0;jsetValue(j); sscanf(brauchSymm.at(j).toLatin1(),"%d_%1d%1d%1d:%d",&s,&h,&k,&l,&symmgroup); //printf("BS:!%s! %d h%d k%d l%d sg%d\n",brauchSymm.at(j).toStdString().c_str(),s,h,k,l,symmgroup); h-=5; k-=5; l-=5; s--; for (int i=0;i-1)){ newAtom.frac=cell.symmops.at(s)*asymm[i].frac+cell.trans.at(s)+V3(h,k,l); newAtom.part=asymm[i].part; frac2kart(newAtom.frac,newAtom.pos); newAtom.Label=QString("%1%2%3") .arg(asymm.at(i).Label) .arg(QString::fromUtf8("ยป")) .arg(j+1);// */ newAtom.an=asymm[i].an; newAtom.symmGroup=j+1; newAtom.sg=s; newAtom.scod = genSymCode(s,h,k,l); newAtom.auidx = i; //printf("scod=%d %d %d %d %d\n",newAtom.scod, s,h+5,k+5,l+5); newAtom.sof_org=asymm[i].sof_org; newAtom.isIso=asymm[i].isIso; newAtom.ufiso_org=asymm[i].ufiso_org; newAtom.molindex=asymm[i].molindex; newAtom.ResiClass=asymm[i].ResiClass; newAtom.resiNr=asymm[i].resiNr; if ((asymm[i].uc.m12==0.0 )&&(asymm[i].uc.m23==0.0)&&(asymm[i].uc.m13==0.0)){ newAtom.uc.m11=newAtom.uc.m22=newAtom.uc.m33=asymm[i].uf.m11; newAtom.uc.m12=newAtom.uc.m13=newAtom.uc.m23=newAtom.uc.m21=newAtom.uc.m31=newAtom.uc.m32=0.0; newAtom.uf=asymm[i].uf; } else { Usym(asymm[i].uf,cell.symmops[s],newAtom.uf); Uf2Uo(newAtom.uf,newAtom.uc); } gibscho=0; if (newAtom.part>=0){ for(int gbt=0;gbt=0){ for(int gbt=0;gbtshowMessage(tr("Neighbor search is finished")); } bool Molecule::checkExtensions(){ bool gut=true; int glmajor=0,glminor=0; float vv=0.0; const char *extensionString =(const char *) glGetString(GL_EXTENSIONS); //printf("%s \n",extensionString); const char *verstring=(char*)glGetString(GL_VERSION); if ((verstring==NULL)||(sscanf(verstring,"%d.%d",&glmajor,&glminor)!=2)) glminor=glmajor=0; //printf("!!%s \n",verstring); if (glmajor<2) return false; verstring=(char*)glGetString(GL_SHADING_LANGUAGE_VERSION); if ((verstring==NULL)||(sscanf(verstring,"%f",&vv)!=1)) vv=0.0; //qDebug()<addShaderFromSourceFile(QOpenGLShader::Vertex,":/shaders/old.vert.glsl"); if (canwrite) logshad.write(g_Program->log().toLatin1()); if (canwrite) logshad.write(g_Program->shaders().last()->log().toLatin1()); g_Program->addShaderFromSourceFile(QOpenGLShader::Fragment,":/shaders/old.frag.glsl"); if (canwrite) logshad.write(g_Program->log().toLatin1()); if (canwrite) logshad.write(g_Program->shaders().last()->log().toLatin1()); g_Program->link(); if (canwrite) logshad.write(g_Program->log().toLatin1()); if (canwrite) logshad.write(g_Program->log().toLatin1()); logshad.close(); g_Program->bind(); wallH = g_Program->uniformLocation( "wall"); ringH = g_Program->uniformLocation( "ring"); ballH = g_Program->uniformLocation( "ball"); openH = g_Program->uniformLocation( "open"); adpsH = g_Program->uniformLocation( "eli"); fogH = g_Program->uniformLocation( "fog"); fograngeH = g_Program->uniformLocation( "fogrange"); bgH = g_Program->uniformLocation("fogColor"); whiteringH = g_Program->uniformLocation( "whitering"); lichtH = g_Program->uniformLocation( "lighting"); lodH = g_Program->uniformLocation( "LOD"); shaders_work=true; g_Program->release(); return g_Program->programId(); } Matrix Molecule::b2u(const Matrix u){ const double twopi2=2.0*M_PI*M_PI; Matrix erg; /* * 99 Atoms(ii)%Bij(1)=2*Pisqr*Atoms(ii)%Uij(1)*(rcell(1)*rcell(1)) * 100 Atoms(ii)%Bij(2)=2*Pisqr*Atoms(ii)%Uij(2)*(rcell(2)*rcell(2)) * 101 Atoms(ii)%Bij(3)=2*Pisqr*Atoms(ii)%Uij(3)*(rcell(3)*rcell(3)) * 102 Atoms(ii)%Bij(4)=2*Pisqr*Atoms(ii)%Uij(4)*(rcell(1)*rcell(2)) * 103 Atoms(ii)%Bij(5)=2*Pisqr*Atoms(ii)%Uij(5)*(rcell(1)*rcell(3)) * 104 Atoms(ii)%Bij(6)=2*Pisqr*Atoms(ii)%Uij(6)*(rcell(2)*rcell(3)) * */ erg.m11 = u.m11 /( twopi2 * cell.as*cell.as); erg.m22 = u.m22 /( twopi2 * cell.bs*cell.bs); erg.m33 = u.m33 /( twopi2 * cell.cs*cell.cs); erg.m12 = erg.m21 =u.m12 /( twopi2 * cell.as*cell.bs); erg.m13 = erg.m31 =u.m13 /( twopi2 * cell.as*cell.cs); erg.m23 = erg.m32 =u.m23 /( twopi2 * cell.bs*cell.cs); // printf("Uij: %9.6f%9.6f%9.6f%9.6f%9.6f%9.6f\n",u.m11,u.m22,u.m33,u.m12,u.m13,u.m23); // printf("Bij: %9.6f%9.6f%9.6f%9.6f%9.6f%9.6f\n",erg.m11,erg.m22,erg.m33,erg.m12,erg.m13,erg.m23); //printf("erg:\n%9.5f %9.5f %9.5f\n%9.5f %9.5f %9.5f\n%9.5f %9.5f %9.5f\n",erg.m11,erg.m12,erg.m13,erg.m12,erg.m22,erg.m23,erg.m13,erg.m23,erg.m33); //printf("erg2:\n%9.5f %9.5f %9.5f\n%9.5f %9.5f %9.5f\n%9.5f %9.5f %9.5f\n",erg2.m11,erg2.m12,erg2.m13,erg2.m12,erg2.m22,erg2.m23,erg2.m13,erg2.m23,erg2.m33); return erg; } Matrix Molecule::u2b(const Matrix u){ const double twopi2=2.0*M_PI*M_PI; Matrix erg; /* * 99 Atoms(ii)%Bij(1)=2*Pisqr*Atoms(ii)%Uij(1)*(rcell(1)*rcell(1)) * 100 Atoms(ii)%Bij(2)=2*Pisqr*Atoms(ii)%Uij(2)*(rcell(2)*rcell(2)) * 101 Atoms(ii)%Bij(3)=2*Pisqr*Atoms(ii)%Uij(3)*(rcell(3)*rcell(3)) * 102 Atoms(ii)%Bij(4)=2*Pisqr*Atoms(ii)%Uij(4)*(rcell(1)*rcell(2)) * 103 Atoms(ii)%Bij(5)=2*Pisqr*Atoms(ii)%Uij(5)*(rcell(1)*rcell(3)) * 104 Atoms(ii)%Bij(6)=2*Pisqr*Atoms(ii)%Uij(6)*(rcell(2)*rcell(3)) * */ erg.m11 = u.m11 * twopi2 * cell.as*cell.as; erg.m22 = u.m22 * twopi2 * cell.bs*cell.bs; erg.m33 = u.m33 * twopi2 * cell.cs*cell.cs; erg.m12 = erg.m21 =u.m12 * twopi2 * cell.as*cell.bs; erg.m13 = erg.m31 =u.m13 * twopi2 * cell.as*cell.cs; erg.m23 = erg.m32 =u.m23 * twopi2 * cell.bs*cell.cs; // printf("Uij: %9.6f%9.6f%9.6f%9.6f%9.6f%9.6f\n",u.m11,u.m22,u.m33,u.m12,u.m13,u.m23); // printf("Bij: %9.6f%9.6f%9.6f%9.6f%9.6f%9.6f\n",erg.m11,erg.m22,erg.m33,erg.m12,erg.m13,erg.m23); //printf("erg:\n%9.5f %9.5f %9.5f\n%9.5f %9.5f %9.5f\n%9.5f %9.5f %9.5f\n",erg.m11,erg.m12,erg.m13,erg.m12,erg.m22,erg.m23,erg.m13,erg.m23,erg.m33); //printf("erg2:\n%9.5f %9.5f %9.5f\n%9.5f %9.5f %9.5f\n%9.5f %9.5f %9.5f\n",erg2.m11,erg2.m12,erg2.m13,erg2.m12,erg2.m22,erg2.m23,erg2.m13,erg2.m23,erg2.m33); return erg; } int Molecule::genSymCode(int s, int h, int k, int l){//!< creates a platon style symmetry code as an integer (s555) return s*1000+(h+5)*100+(k+5)*10+(l+5); } V3 Molecule::applySymCode(const V3 &frac, int scode){;//!< applies a platon style symmetry code as an integer (s555) int s, h, k, l; s = scode / 1000; if (s >= cell.symmops.size())return frac;// silent error handling l = (scode % 10) - 5 ; k = ((scode % 100) / 10) - 5; h = ((scode % 1000) / 100) - 5; return cell.symmops.at(s) * frac + cell.trans.at(s) + V3(h, k, l); } int Molecule::rankMySymmOp(Matrix m, V3 t){ V3 tv(0.27353,0.03537,0.15373); V3 a=V3(0,0,0),b=tv; int rank=0; while (!(a==tv)){ a=m*b+t; //b=a; //V3 flo=V3(floor(fabs(a.x)),floor(fabs(a.y)),floor(fabs(a.z)));//V3(floor(a.x+0.5), floor(a.y+0.5), floor(a.z+0.5)); //b=b-flo;//+V3(0.5,0.5,0.5); a.x=(a.x>1.0)?a.x-1:(a.x<0.000001)?a.x+1:a.x; a.y=(a.y>1.0)?a.y-1:(a.y<0.000001)?a.y+1:a.y; a.z=(a.z>1.0)?a.z-1:(a.z<0.000001)?a.z+1:a.z; /*printf("%g %g %g | %g %g %g | %g %g %g {} %g %g\n", b.x,b.y,b.z, a.x,a.y,a.z, flo.x,flo.y,flo.z,Distance(a,tv),Distance(b,tv));// */ b=a; rank++; if (rank>=16) break; } return rank; } V3 Molecule::intersectPoint(V3 rayVector, V3 rayPoint, V3 planeNormal, V3 planePoint,bool &ok) { V3 diff = rayPoint - planePoint; ok=true; double prod1 = diff * planeNormal; double prod2 = (rayVector * planeNormal)/(sqrt(Norm(rayVector))*sqrt(Norm(planeNormal)));//cosine //printf("diff %g %g %g A%g B%g\n",diff.x,diff.y,diff.z,prod1,prod2); if (fabs(prod2)<0.000001) {ok=false;return V3(0,0,0);} double p3 = prod1 / prod2; V3 erg =rayPoint - (Normalize(rayVector) * p3); ok= (erg.x>=-0.001)&&(erg.x<=1.001)&&(erg.y>=-0.001)&&(erg.y<=1.001)&&(erg.z>=-0.001)&&(erg.z<=1.001); erg.x=(erg.x<0.0)?0.0:erg.x; erg.y=(erg.y<0.0)?0.0:erg.y; erg.z=(erg.z<0.0)?0.0:erg.z; //if (!ok) printf("ich bin nicht ok (%g %g %g)\n",erg.x,erg.y,erg.z); //else printf("ich bin ok (%g %g %g)\n",erg.x,erg.y,erg.z); //printf("ich bin null = %g p1 %g p2 %g p3 %g (%g %g %g)\n",(erg-planePoint)* planeNormal,prod1,prod2,p3,erg.x,erg.y,erg.z); return erg; } void Molecule:: specialPts(const Matrix &mat, const V3 &trans, QList &points){ int nmax=9; double stp=1.0/(nmax-1.0); //double vstp=1.0/(3*nmax); int fold=3; V3 axis; QString sname=nameSymmOp(mat,fold,axis); axis=Normalize(axis); //Matrix mat_=mat; //if (fold<-2) mat_=mat*Matrix(-1,0,0,0,-1,0,0,0,-1); int end=0; V3 pts[1331]; V3 pp[12],p; for (int h=0; h%g\n %g %g %g\n %g %g %g\n %g %g %g\n %g %g %g\n" //REM %g %g %g %g %g %g %g %g %g %g %g %g %g\n" , i+1, p.x, p.y, p.z, (screwy>0.1)?1.0:0.0,d2,d ); // */ } } } V3 Molecule::findGlide(V3 normal, V3 test, int n){ Matrix mat=cell.symmops.at(n); V3 trans=cell.trans.at(n); V3 axis; return findGlide(normal,test,mat,trans); } V3 Molecule::findGlide(V3 normal, V3 test, Matrix mat, V3 trans){ V3 glide=V3(-6,-6,-6); V3 p=V3(0,0,0); QList tg; tg <1.1)||(t.y>1.1)||(t.z>1.1)||(t.x<-1.1)||(t.y<-1.1)||(t.z<-1.1)) continue; V3 v=p-t; v.x = v.x - floor(v.x+0.000001); v.y = v.y - floor(v.y+0.000001); v.z = v.z - floor(v.z+0.000001); V3 v2=test; v2.x = v2.x - floor(v2.x+0.000001); v2.y = v2.y - floor(v2.y+0.000001); v2.z = v2.z - floor(v2.z+0.000001); double d=Norm(t); double ang=winkel(normal,t); ang+=720; int ia=static_cast(round(ang)); ia%=360; if (((ia==90)||(ia==270))&&(Distance(v,v2)<0.001)&&(d<=td)) { glide=(t); td=d; } } } } } bool hasfract=false; hasfract=hasfract||((glide.x-floor(glide.x))>0.01); hasfract=hasfract||((glide.y-floor(glide.y))>0.01); hasfract=hasfract||((glide.z-floor(glide.z))>0.01); if (hasfract) return glide; else return V3(0,0,0); } void Molecule::findSymmElements(){ axvecs.clear(); ptriangles.clear(); axcols.clear(); axoprs.clear(); dontshowSel.clear(); dontshowSop.clear(); invoprs.clear(); invvecs.clear(); QList points; for (int n=1; n drin; for (int i=0; i< points.size(); i++){ packPoint(points.at(i),drin); //printf("%d -- %d\n",i,drin.size()); } for (int i=0; i< drin.size(); i++){ V3 pos; frac2kart(drin.at(i),pos); invoprs.append(n); invvecs.append(pos); } //printf("INVERSION CENTERS %d %d\n",invoprs.size(),invvecs.size()); }else if (fold==-2){ for (int g=0; g0.01); //if (n==6)printf("#@#@ isglide? %d (%g %g %g)\n",isglide,glide.x,glide.y,glide.z); int colori=abs(fold)-1; colori+=(fold<0)?5:0; colori+=fold==6?-1:0; colori+=(fold==-6)?-1:0; colori+=(isglide)?9:0; colori+=((isglide)&&(fold<0))?-1:0; //frac2kart(V3(glide.x*T.x,glide.y*T.y,glide.z*T.z),glide); make1Plane(axis,points.at(g),glide,colori,n); } }else{ // may be a axis QList drin; QList dc; for (int g=0; g sects; inp=intersectPoint(-1.0*axis,tt2,V3(0,0,1),V3(0,0,0),ok); if (ok){ if (!sects.contains(inp)) sects.append(inp); } inp=intersectPoint(-1.0*axis,tt2,V3(0,0,1),V3(0,0,1),ok); if (ok){ if (!sects.contains(inp)) sects.append(inp); } inp=intersectPoint(-1.0*axis,tt2,V3(0,1,0),V3(0,0,0),ok); if ((ok)){ if (!sects.contains(inp)) sects.append(inp); } inp=intersectPoint(-1.0*axis,tt2,V3(0,1,0),V3(0,1,0),ok); if ((ok)){ if (!sects.contains(inp)) sects.append(inp); } inp=intersectPoint(-1.0*axis,tt2,V3(1,0,0),V3(0,0,0),ok); if ((ok)){ if (!sects.contains(inp)) sects.append(inp); } inp=intersectPoint(-1.0*axis,tt2,V3(1,0,0),V3(1,0,0),ok); if ((ok)){ if (!sects.contains(inp)) sects.append(inp); } if (sects.size()>1){ V3 pp0 = 0.5*(sects.at(0)+sects.at(1)); V3 pp = cell.symmops.at(n) * pp0 + cell.trans.at(n); pp.x = pp.x - floor(pp.x+0.000001); pp.y = pp.y - floor(pp.y+0.000001); pp.z = pp.z - floor(pp.z+0.000001); double screwy = (fold==-2)?0.0:sqrt(Norm(pp-pp0)); //printf("%g %g %g ||%g %g %g \n",pp.x,pp.y,pp.z,pp0.x,pp0.y,pp0.z); //V3 ta=(pp-pp0); V3 screw = screwy * axis; screw.x = screw.x - floor(screw.x+0.000001); screw.y = screw.y - floor(screw.y+0.000001); screw.z = screw.z - floor(screw.z+0.000001); /*printf("Screw: %g >> (%g %g %g) (%g %g %g) (%g %g %g) (%g %g %g)\n", Norm(screw), screw.x, screw.y, screw.z,tt2.x,tt2.y,tt2.z, axis.x,axis.y,axis.z, dif.x,dif.y,dif.z );*/ bool isscrew=Norm(screw)>0.01; //frac2kart(screw,scc); int colori=abs(fold)-1; colori+=(fold<0)?5:0; colori+=(fold==6)?-1:0; colori+=(fold==-6)?-1:0; colori+=(isscrew)?9:0; colori+=((isscrew)&&(fold<0))?-1:0; //int ds=drin.size(); packLine(sects.at(0),sects.at(1),drin,colori,dc); /*if (ds!=drin.size())printf("drinsize %d colori %d screw(%g):( %g %g %g) (%g %g %g) (%g %g %g)\n",drin.size(),colori,screwy,screw.x,screw.y,screw.z ,ta.x,ta.y,ta.z,axis.x,axis.y,axis.z);// */ } //printf("drinn %d %d \n",drin.size(),sects.size()); for (int g=0; g %f %f %f\n",i,atm.frac.x,atm.frac.y,atm.frac.z,atm.pos.x,atm.pos.y,atm.pos.z); showatoms.append(atm); } } } } void Molecule::make1Plane(V3 planeNormal, V3 pointOnPlane,V3 glide, int ac, int n){ //if (n==11) printf("normal %g %g %g\n",planeNormal.x,planeNormal.y,planeNormal.z); QList pop;//point on plane int np=0; bool already=false; for (int h=0; h<2; h++){ for (int k=0; k<2; k++){ for (int l=0; l<2; l++){ bool ok; V3 inp=intersectPoint(V3(0,0,1),V3(h,k,l),planeNormal,pointOnPlane,ok); if (ok) { if (!pop.contains(inp)){ np++; pop.append(inp); } } inp=intersectPoint(V3(0,1,0),V3(h,k,l),planeNormal,pointOnPlane,ok); if (ok) { if (!pop.contains(inp)){ np++; pop.append(inp); } } inp=intersectPoint(V3(1,0,0),V3(h,k,l),planeNormal,pointOnPlane,ok); if (ok) { if (!pop.contains(inp)){ np++; pop.append(inp); } } } } } if (pop.size()>2){ PPoly tri; tri.nor=planeNormal; tri.mid=V3(0,0,0); for(int i=0; i order; order.append(0); int j=0,jj=0,aj=0; for (int k=1; k ev.y)?(ev.y > ev.z)?ev.z:ev.y:(ev.x > ev.z)?ev.z:ev.x; ma=(ev.x < ev.y)?(ev.y < ev.z)?ev.z:ev.y:(ev.x < ev.z)?ev.z:ev.x; if (mi<0.01) return true; if (ue8) return true; if ((ue/avu) >3.0) return true; return false; } double Molecule::averageUeq(){ double uav=0.0; int iok=0; Matrix ucc; for (int i=0; i0.0) { iok++; uav+=u; } } uav/=iok; return uav; } double Molecule::ueq(const Matrix m){ double erg=0; Matrix ucc; Uf2Uo(m,ucc); erg=1/3.0*(ucc.m11+ucc.m22+ucc.m33); return erg; } MyAtom Molecule::fromAtomString(const QString &s){ MyAtom a; a.an=-81; QStringList sl = s.split('!'); if (sl.size()<45) return a; a.Label = sl.at(0); a.ResiClass = sl.at(1); a.orginalLine = sl.at(2); a.molindex = sl.at(3).toInt(); a.fixFlag = sl.at(4).toInt(); a.symmGroup = sl.at(5).toInt(); a.sg = sl.at(6).toInt(); a.scod = sl.at(7).toInt(); a.auidx = sl.at(8).toInt(); a.hidden = sl.at(9).toInt(); a.sof_org = sl.at(10).toDouble(); a.sof = sl.at(11).toDouble(); a.isIso = sl.at(12).toInt(); a.ufiso_org = sl.at(13); a.uf.m11 = sl.at(14).toDouble(); a.uf.m12 = sl.at(15).toDouble(); a.uf.m13 = sl.at(16).toDouble(); a.uf.m21 = sl.at(17).toDouble(); a.uf.m22 = sl.at(18).toDouble(); a.uf.m23 = sl.at(19).toDouble(); a.uf.m31 = sl.at(20).toDouble(); a.uf.m32 = sl.at(21).toDouble(); a.uf.m33 = sl.at(22).toDouble(); a.uc.m11 = sl.at(23).toDouble(); a.uc.m12 = sl.at(24).toDouble(); a.uc.m13 = sl.at(25).toDouble(); a.uc.m21 = sl.at(26).toDouble(); a.uc.m22 = sl.at(27).toDouble(); a.uc.m23 = sl.at(28).toDouble(); a.uc.m31 = sl.at(29).toDouble(); a.uc.m32 = sl.at(30).toDouble(); a.uc.m33 = sl.at(31).toDouble(); a.pos.x = sl.at(32).toDouble(); a.pos.y = sl.at(33).toDouble(); a.pos.z = sl.at(34).toDouble(); a.frac.x = sl.at(35).toDouble(); a.frac.y = sl.at(36).toDouble(); a.frac.z = sl.at(37).toDouble(); a.peakHeight = sl.at(38).toDouble(); a.resiNr = sl.at(39).toInt(); a.an = sl.at(40).toInt(); a.part = sl.at(41).toInt(); a.style = sl.at(42).toInt(); a.afixParent = sl.at(43).toInt(); a.afix = sl.at(44).toInt(); return a; }