| 1 |
|
| 2 |
class MyString{ |
| 3 |
public: |
| 4 |
int last; |
| 5 |
char lastc; |
| 6 |
char *st; |
| 7 |
MyString(char *_st){ |
| 8 |
last=-1; |
| 9 |
st=_st; |
| 10 |
} |
| 11 |
char* sub(int a, int b){ |
| 12 |
a--; |
| 13 |
st[last]=lastc; |
| 14 |
lastc=st[b]; |
| 15 |
st[b]=0; |
| 16 |
last=b; |
| 17 |
return st+a; |
| 18 |
} |
| 19 |
}; |
| 20 |
|
| 21 |
|
| 22 |
class QAtom{ |
| 23 |
public: |
| 24 |
float px,py,pz,r; |
| 25 |
float cr,cg,cb; |
| 26 |
int serial; |
| 27 |
|
| 28 |
int chainIndex; |
| 29 |
unsigned int atomColor; |
| 30 |
|
| 31 |
float spacefillr, covalentr; |
| 32 |
|
| 33 |
int tx,ty; // starting places for texture |
| 34 |
|
| 35 |
bool hetatomFlag; |
| 36 |
//CubeMapSamp s; |
| 37 |
OctaMapSamp s; |
| 38 |
|
| 39 |
inline Point3f P() const { |
| 40 |
return Point3f(px, py, pz); |
| 41 |
} |
| 42 |
|
| 43 |
bool AssignNextTextPos(int texsize); |
| 44 |
|
| 45 |
void SmoothTexture(vector<Byte> &t, int siz){ |
| 46 |
/*s.Smooth( t, siz, tx, ty);*/ |
| 47 |
} |
| 48 |
void SmoothTexture(vector<int> &t, int siz){ |
| 49 |
/*s.Smooth( t, siz, tx, ty);*/ |
| 50 |
} |
| 51 |
|
| 52 |
void FillTexture(vector<Byte> &texture, int textsize) { |
| 53 |
s.FillTexture(texture, textsize, tx,ty, cr,cg,cb); |
| 54 |
} |
| 55 |
|
| 56 |
Point3f trp; float trr; // transormed pos and radius |
| 57 |
|
| 58 |
void Transform(const Point3f &ax,const Point3f &ay,const Point3f &az){ |
| 59 |
Point3f p(px,py,pz); |
| 60 |
trp[0]=p*ax; |
| 61 |
trp[1]=p*ay; |
| 62 |
trp[2]=p*az; |
| 63 |
//printf("[r=%f] (%f %f %f) -> (%f %f %f)\n", r, px,py,pz, trp[0],trp[1],trp[2] ); |
| 64 |
} |
| 65 |
|
| 66 |
void ScaleTransl(float dx, float dy, float scale){ |
| 67 |
trp[0]=(trp[0]+dx)*scale; |
| 68 |
trp[1]=(trp[1]+dy)*scale; |
| 69 |
trr=r*scale; |
| 70 |
//printf("[%f*%f] -> (%f %f %f %f)\n", r, scale, trp[0],trp[1],trp[2],trr ); |
| 71 |
} |
| 72 |
|
| 73 |
// color from atom name |
| 74 |
void getCol(const char* st); |
| 75 |
|
| 76 |
QAtom(string st); |
| 77 |
static bool readError; |
| 78 |
static char lastReadError[1024]; |
| 79 |
|
| 80 |
void UpdateColors(float mode); |
| 81 |
|
| 82 |
// sends impostors on screnbuffer |
| 83 |
void Draw(); |
| 84 |
// sends halos on screnbuffer |
| 85 |
void DrawHalo(); |
| 86 |
void DrawShadowmap(); |
| 87 |
|
| 88 |
// for GPU ao. |
| 89 |
void DrawOnTexture(); |
| 90 |
|
| 91 |
/* |
| 92 |
bool operator < (const QAtom& a) const { |
| 93 |
return trp[2]>a.trp[2]; |
| 94 |
} |
| 95 |
*/ |
| 96 |
|
| 97 |
static unsigned int VBOsize(); |
| 98 |
void VBOfill(float * f); |
| 99 |
static void VBOsetup(float *f); |
| 100 |
|
| 101 |
//inline bool operator <= (QAtom const &a) const { return px<=a.px; }; |
| 102 |
inline bool operator < (QAtom const &a) const { return px< a.px; }; |
| 103 |
|
| 104 |
}; |
| 105 |
|
| 106 |
|
| 107 |
class Bond{ |
| 108 |
public: |
| 109 |
Point3f a, b; |
| 110 |
Point3f dir; |
| 111 |
Point3f col1, col2; |
| 112 |
float lenght; |
| 113 |
Point3f startp; // start of parameterization |
| 114 |
|
| 115 |
const QAtom *atmA, *atmB; |
| 116 |
|
| 117 |
bool hetatomFlag; |
| 118 |
//Point3f cola, colb; |
| 119 |
void Draw(); |
| 120 |
void DrawHalo(); |
| 121 |
void DrawShadowmap(); |
| 122 |
//Bond(Point3f a,Point3f b, float rada, float radb, Point3f col1, Point3f col2); |
| 123 |
Bond(const QAtom &a,const QAtom &b); |
| 124 |
|
| 125 |
void UpdateColors(); // copies color from atoms |
| 126 |
|
| 127 |
void DrawOnTexture(); // for GPU ao. |
| 128 |
bool AssignNextTextPos(int texsize); |
| 129 |
int tx, ty; |
| 130 |
|
| 131 |
}; |
| 132 |
|
| 133 |
|
| 134 |
class Mol{ |
| 135 |
public: |
| 136 |
|
| 137 |
bool sticks; // true if ball_and_stick mode |
| 138 |
float colMode; // mode = 0 -> per atom |
| 139 |
// mode = 1 -> per chain |
| 140 |
|
| 141 |
void SetColMode(float newColMode); |
| 142 |
|
| 143 |
void SetBallAndSticks(float rad=0.3); |
| 144 |
void SetLicorice(float rad=0.5); |
| 145 |
void SetSpaceFill(); |
| 146 |
|
| 147 |
vector<QAtom> atom; |
| 148 |
vector<Bond> bond; |
| 149 |
|
| 150 |
float px,py,pz,r; |
| 151 |
bool textureAssigned; |
| 152 |
|
| 153 |
void Draw(); |
| 154 |
void DrawShadowmap(bool invert); |
| 155 |
|
| 156 |
void DrawHalos(); |
| 157 |
void DrawOnTexture(); |
| 158 |
|
| 159 |
void FindBonds(); |
| 160 |
|
| 161 |
void ComputeSize(); |
| 162 |
bool ReadPdb(const char *filename); |
| 163 |
|
| 164 |
float tx0,ty0,tx1,ty1; // bounding box transformed |
| 165 |
void Transform(const Point3f &ax,const Point3f &ay,const Point3f &az); |
| 166 |
|
| 167 |
void ScaleTransl(float scale){ |
| 168 |
for (int i=0; i<atom.size(); i++) |
| 169 |
atom[i].ScaleTransl( -tx0, -ty0, scale); |
| 170 |
} |
| 171 |
|
| 172 |
void SmoothTexture(vector<Byte> &t, int siz){ |
| 173 |
for (int i=0; i<atom.size(); i++) |
| 174 |
atom[i].SmoothTexture(t,siz); |
| 175 |
} |
| 176 |
|
| 177 |
void SmoothTexture(vector<int> &t, int siz){ |
| 178 |
for (int i=0; i<atom.size(); i++) |
| 179 |
atom[i].SmoothTexture(t,siz); |
| 180 |
} |
| 181 |
|
| 182 |
void Zero() { |
| 183 |
for (int i=0; i<atom.size(); i++) |
| 184 |
atom[i].s.Zero(); |
| 185 |
} |
| 186 |
|
| 187 |
void DuplicateTexels(vector<Byte> &t, int size); |
| 188 |
|
| 189 |
void FillTexture(vector<Byte> &texture, const vector<int> &sumtable, |
| 190 |
int texsize, float div ); |
| 191 |
|
| 192 |
bool ReassignTexture(int textsize); // for a given texture size |
| 193 |
|
| 194 |
void ReassignTextureAutosize(); // autoselect texture size |
| 195 |
|
| 196 |
int NTotTexels(){ |
| 197 |
return atom.size()*atom[0].s.TotTexSizeX()*atom[0].s.TotTexSizeY(); |
| 198 |
} |
| 199 |
|
| 200 |
// vertexbuffer objects |
| 201 |
unsigned int vboNorm, vboShadow, vboAO; |
| 202 |
unsigned int vboNormSt, vboShadowSt, vboAOSt; // for the sticks |
| 203 |
|
| 204 |
Mol(); |
| 205 |
|
| 206 |
char filename[1024]; |
| 207 |
char* GetFilenameTex(); |
| 208 |
char* GetFilenameSnap(); |
| 209 |
char* GetMolName(); |
| 210 |
|
| 211 |
bool PrepareAOstep(int nsteps=1); |
| 212 |
float PredictAO(); |
| 213 |
|
| 214 |
void ResetAO(); |
| 215 |
|
| 216 |
bool DoingAO(); // true if AO is being computed |
| 217 |
bool DecentAO(); // true if AO (being computed) is "decent" |
| 218 |
|
| 219 |
// for testing purposes |
| 220 |
bool PrepareAOSingleView(); |
| 221 |
|
| 222 |
int natm, nhetatm; // number of atoms of type hetatm and not ... |
| 223 |
|
| 224 |
bool IsReady(){return ready;} |
| 225 |
|
| 226 |
void UpdateColors(); |
| 227 |
|
| 228 |
private: |
| 229 |
|
| 230 |
// unsigned int DL_bonds, DL_atoms; // display lists (UNUSED) |
| 231 |
|
| 232 |
void AddBond(int i, int j); |
| 233 |
|
| 234 |
void PrepareAOallAtOnce(); |
| 235 |
|
| 236 |
int AOdoneLvl; |
| 237 |
|
| 238 |
void PrepareAOstart(); |
| 239 |
bool AOready; |
| 240 |
bool AOstarted; |
| 241 |
bool ready; |
| 242 |
}; |
| 243 |
|
| 244 |
extern float stick_radius; |
| 245 |
|