Debian Codegraph @

src/Mol.h

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