4 * This source code is part of
8 * GROningen MAchine for Chemical Simulations
12 * Copyright (c) 1991-2001
13 * BIOSON Research Institute, Dept. of Biophysical Chemistry
14 * University of Groningen, The Netherlands
16 * This program is free software; you can redistribute it and/or
17 * modify it under the terms of the GNU General Public License
18 * as published by the Free Software Foundation; either version 2
19 * of the License, or (at your option) any later version.
21 * If you want to redistribute modifications, please consider that
22 * scientific software is very special. Version control is crucial -
23 * bugs must be traceable. We will be happy to consider code for
24 * inclusion in the official distribution, but derived work must not
25 * be called official GROMACS. Details are found in the README & COPYING
26 * files - if they are missing, get the official version at www.gromacs.org.
28 * To help us fund GROMACS development, we humbly ask that you cite
29 * the papers on the package - you can find them in the top README file.
31 * Do check out http://www.gromacs.org , or mail us at gromacs@gromacs.org .
34 * Giving Russians Opium May Alter Current Situation
36 static char *SRCID_molps_c = "$Id$";
53 static void ps_draw_atom(FILE *ps,atom_id ai,iv2 vec2[],char **atomnm[])
59 ps_rgb(ps,Type2RGB(*atomnm[ai]));
60 ps_line(ps,xi-MSIZE,yi,xi+MSIZE+1,yi);
61 ps_line(ps,xi,yi-MSIZE,xi,yi+MSIZE+1);
64 /* Global variables */
65 static rvec gl_fbox,gl_hbox,gl_mhbox;
67 static void init_pbc(matrix box)
71 for(i=0; (i<DIM); i++) {
72 gl_fbox[i] = box[i][i];
73 gl_hbox[i] = gl_fbox[i]*0.5;
74 gl_mhbox[i] = -gl_hbox[i];
78 static bool local_pbc_dx(rvec x1, rvec x2)
83 for(i=0; (i<DIM); i++) {
87 else if (dx <= gl_mhbox[i])
93 static void ps_draw_bond(FILE *ps,
94 atom_id ai,atom_id aj,iv2 vec2[],
95 rvec x[],char **atomnm[],int size[],bool bBalls)
102 ps_draw_atom(ps,ai,vec2,atomnm);
103 ps_draw_atom(ps,aj,vec2,atomnm);
106 if (local_pbc_dx(x[ai],x[aj])) {
118 ps_rgb(ps,Type2RGB(ic));
119 ps_line(ps,xi,yi,xm,ym);
120 ps_rgb(ps,Type2RGB(jc));
121 ps_line(ps,xm,ym,xj,yj);
124 ps_rgb(ps,Type2RGB(ic));
125 ps_line(ps,xi,yi,xj,yj);
131 void ps_draw_objects(FILE *ps,int nobj,t_object objs[],iv2 vec2[],rvec x[],
132 char **atomnm[],int size[],bool bShowHydro,int bond_type,
140 for(i=0; (i<nobj); i++) {
144 ps_draw_atom(ps,obj->ai,vec2,atomnm);
147 ps_draw_bond(ps,obj->ai,obj->aj,vec2,x,atomnm,size,bBalls);
151 ps_draw_bond(ps,obj->ai,obj->aj,vec2,x,atomnm,size,bBalls);
159 static void v4_to_iv2(vec4 x4,iv2 v2,int x0,int y0,real sx,real sy)
164 v2[XX]=x0+sx*x4[XX]*inv_z;
165 v2[YY]=y0-sy*x4[YY]*inv_z;
168 static void draw_box(FILE *ps,t_3dview *view,matrix box,
169 int x0,int y0,real sx,real sy)
172 { 0,0,0,1 }, { 1,0,0,1 }, { 1,1,0,1 }, { 0,1,0,1 },
173 { 0,0,1,1 }, { 1,0,1,1 }, { 1,1,1,1 }, { 0,1,1,1 }
176 { 0,1 }, { 1,2 }, { 2,3 }, { 3,0 },
177 { 4,5 }, { 5,6 }, { 6,7 }, { 7,4 },
178 { 0,4 }, { 1,5 }, { 2,6 }, { 3,7 }
185 for (i=0; (i<8); i++) {
186 for (j=0; (j<DIM); j++)
187 corner[i][j] = ivec[i][j]*box[j][j];
188 m4_op(view->proj,corner[i],x4);
189 v4_to_iv2(x4,vec2[i],x0,y0,sx,sy);
191 ps_color(ps,0,0,0.5);
192 for (i=0; (i<12); i++)
194 vec2[bonds[i][0]][XX],vec2[bonds[i][0]][YY],
195 vec2[bonds[i][1]][XX],vec2[bonds[i][1]][YY]);
198 void ps_draw_mol(FILE *ps,t_manager *man)
200 static char tstr[2][20];
210 if (man->status == -1)
221 sx=win->width/2*view->sc_x;
222 sy=win->height/2*view->sc_y;
226 /* create_visibility(man); */
228 for(i=0; (i<man->natom); i++) {
230 m4_op(view->proj,man->x[i],x4);
232 v4_to_iv2(x4,vec2[i],x0,y0,sx,sy);
235 set_sizes(man,sx,sy);
237 z_fill (man,man->zz);
240 XClearWindow(x11->disp,win->self); */
243 sprintf(tstr[ntime],"Time: %.3 ps",man->time);
244 if (strcmp(tstr[ntime],tstr[1-ntime]) != 0) {
245 set_vbtime(x11,man->vbox,tstr[ntime]);
249 if (mw->boxtype != esbNone)
250 draw_box(ps,view,man->box,x0,y0,sx,sy);
252 /* Should sort on Z-Coordinates here! */
253 nvis=filter_vis(man);
254 if (nvis && man->bSort)
255 qsort(man->obj,nvis,sizeof(man->obj[0]),compare_obj);
257 /* Draw the objects */
259 nvis,man->obj,man->ix,man->x,man->top.atoms.atomname,
261 mw->bShowHydrogen,mw->bond_type,man->bPlus);
263 /* Draw the labels */
265 for(i=0; (i<man->natom); i++)
266 if (man->bLabel[i] && man->bVis[i])
267 ps_text(ps,vec2[i][XX]+2,vec2[i][YY]-2,man->szLab[i]);