4 * This source code is part of
8 * GROningen MAchine for Chemical Simulations
12 * Copyright (c) 1991-1999
13 * BIOSON Research Institute, Dept. of Biophysical Chemistry
14 * University of Groningen, The Netherlands
17 * GROMACS: A message-passing parallel molecular dynamics implementation
18 * H.J.C. Berendsen, D. van der Spoel and R. van Drunen
19 * Comp. Phys. Comm. 91, 43-56 (1995)
21 * Also check out our WWW page:
22 * http://md.chem.rug.nl/~gmx
27 * Great Red Oystrich Makes All Chemists Sane
29 static char *SRCID_molps_c = "$Id$";
47 static void ps_draw_atom(FILE *ps,atom_id ai,iv2 vec2[],char **atomnm[])
53 ps_rgb(ps,Type2RGB(*atomnm[ai]));
54 ps_line(ps,xi-MSIZE,yi,xi+MSIZE+1,yi);
55 ps_line(ps,xi,yi-MSIZE,xi,yi+MSIZE+1);
58 /* Global variables */
59 static rvec gl_fbox,gl_hbox,gl_mhbox;
61 static void init_pbc(matrix box)
65 for(i=0; (i<DIM); i++) {
66 gl_fbox[i] = box[i][i];
67 gl_hbox[i] = gl_fbox[i]*0.5;
68 gl_mhbox[i] = -gl_hbox[i];
72 static bool local_pbc_dx(rvec x1, rvec x2)
77 for(i=0; (i<DIM); i++) {
81 else if (dx <= gl_mhbox[i])
87 static void ps_draw_bond(FILE *ps,
88 atom_id ai,atom_id aj,iv2 vec2[],
89 rvec x[],char **atomnm[],int size[],bool bBalls)
96 ps_draw_atom(ps,ai,vec2,atomnm);
97 ps_draw_atom(ps,aj,vec2,atomnm);
100 if (local_pbc_dx(x[ai],x[aj])) {
112 ps_rgb(ps,Type2RGB(ic));
113 ps_line(ps,xi,yi,xm,ym);
114 ps_rgb(ps,Type2RGB(jc));
115 ps_line(ps,xm,ym,xj,yj);
118 ps_rgb(ps,Type2RGB(ic));
119 ps_line(ps,xi,yi,xj,yj);
125 void ps_draw_objects(FILE *ps,int nobj,t_object objs[],iv2 vec2[],rvec x[],
126 char **atomnm[],int size[],bool bShowHydro,int bond_type,
134 for(i=0; (i<nobj); i++) {
138 ps_draw_atom(ps,obj->ai,vec2,atomnm);
141 ps_draw_bond(ps,obj->ai,obj->aj,vec2,x,atomnm,size,bBalls);
145 ps_draw_bond(ps,obj->ai,obj->aj,vec2,x,atomnm,size,bBalls);
153 static void v4_to_iv2(vec4 x4,iv2 v2,int x0,int y0,real sx,real sy)
158 v2[XX]=x0+sx*x4[XX]*inv_z;
159 v2[YY]=y0-sy*x4[YY]*inv_z;
162 static void draw_box(FILE *ps,t_3dview *view,matrix box,
163 int x0,int y0,real sx,real sy)
166 { 0,0,0,1 }, { 1,0,0,1 }, { 1,1,0,1 }, { 0,1,0,1 },
167 { 0,0,1,1 }, { 1,0,1,1 }, { 1,1,1,1 }, { 0,1,1,1 }
170 { 0,1 }, { 1,2 }, { 2,3 }, { 3,0 },
171 { 4,5 }, { 5,6 }, { 6,7 }, { 7,4 },
172 { 0,4 }, { 1,5 }, { 2,6 }, { 3,7 }
179 for (i=0; (i<8); i++) {
180 for (j=0; (j<DIM); j++)
181 corner[i][j] = ivec[i][j]*box[j][j];
182 m4_op(view->proj,corner[i],x4);
183 v4_to_iv2(x4,vec2[i],x0,y0,sx,sy);
185 ps_color(ps,0,0,0.5);
186 for (i=0; (i<12); i++)
188 vec2[bonds[i][0]][XX],vec2[bonds[i][0]][YY],
189 vec2[bonds[i][1]][XX],vec2[bonds[i][1]][YY]);
192 void ps_draw_mol(FILE *ps,t_manager *man)
194 static char tstr[2][20];
204 if (man->status == -1)
215 sx=win->width/2*view->sc_x;
216 sy=win->height/2*view->sc_y;
220 /* create_visibility(man); */
222 for(i=0; (i<man->natom); i++) {
224 m4_op(view->proj,man->x[i],x4);
226 v4_to_iv2(x4,vec2[i],x0,y0,sx,sy);
229 set_sizes(man,sx,sy);
231 z_fill (man,man->zz);
234 XClearWindow(x11->disp,win->self); */
237 sprintf(tstr[ntime],"Time: %.3 ps",man->time);
238 if (strcmp(tstr[ntime],tstr[1-ntime]) != 0) {
239 set_vbtime(x11,man->vbox,tstr[ntime]);
243 if (mw->boxtype != esbNone)
244 draw_box(ps,view,man->box,x0,y0,sx,sy);
246 /* Should sort on Z-Coordinates here! */
247 nvis=filter_vis(man);
248 if (nvis && man->bSort)
249 qsort(man->obj,nvis,sizeof(man->obj[0]),compare_obj);
251 /* Draw the objects */
253 nvis,man->obj,man->ix,man->x,man->top.atoms.atomname,
255 mw->bShowHydrogen,mw->bond_type,man->bPlus);
257 /* Draw the labels */
259 for(i=0; (i<man->natom); i++)
260 if (man->bLabel[i] && man->bVis[i])
261 ps_text(ps,vec2[i][XX]+2,vec2[i][YY]-2,man->szLab[i]);