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