3 * This source code is part of
7 * GROningen MAchine for Chemical Simulations
10 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
11 * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
12 * Copyright (c) 2001-2004, The GROMACS development team,
13 * check out http://www.gromacs.org for more information.
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License
17 * as published by the Free Software Foundation; either version 2
18 * of the License, or (at your option) any later version.
20 * If you want to redistribute modifications, please consider that
21 * scientific software is very special. Version control is crucial -
22 * bugs must be traceable. We will be happy to consider code for
23 * inclusion in the official distribution, but derived work must not
24 * be called official GROMACS. Details are found in the README & COPYING
25 * files - if they are missing, get the official version at www.gromacs.org.
27 * To help us fund GROMACS development, we humbly ask that you cite
28 * the papers on the package - you can find them in the top README file.
30 * For more info, check our website at http://www.gromacs.org
33 * Gyas ROwers Mature At Cryogenic Speed
46 #include "gmx_fatal.h"
55 static void ps_draw_atom(t_psdata ps
,atom_id ai
,iv2 vec2
[],char **atomnm
[])
61 ps_rgb(ps
,Type2RGB(*atomnm
[ai
]));
62 ps_line(ps
,xi
-MSIZE
,yi
,xi
+MSIZE
+1,yi
);
63 ps_line(ps
,xi
,yi
-MSIZE
,xi
,yi
+MSIZE
+1);
66 /* Global variables */
67 static rvec gl_fbox
,gl_hbox
,gl_mhbox
;
69 static void init_pbc(matrix box
)
73 for(i
=0; (i
<DIM
); i
++) {
74 gl_fbox
[i
] = box
[i
][i
];
75 gl_hbox
[i
] = gl_fbox
[i
]*0.5;
76 gl_mhbox
[i
] = -gl_hbox
[i
];
80 static bool local_pbc_dx(rvec x1
, rvec x2
)
85 for(i
=0; (i
<DIM
); i
++) {
89 else if (dx
<= gl_mhbox
[i
])
95 static void ps_draw_bond(t_psdata ps
,
96 atom_id ai
,atom_id aj
,iv2 vec2
[],
97 rvec x
[],char **atomnm
[],int size
[],bool bBalls
)
104 ps_draw_atom(ps
,ai
,vec2
,atomnm
);
105 ps_draw_atom(ps
,aj
,vec2
,atomnm
);
108 if (local_pbc_dx(x
[ai
],x
[aj
])) {
120 ps_rgb(ps
,Type2RGB(ic
));
121 ps_line(ps
,xi
,yi
,xm
,ym
);
122 ps_rgb(ps
,Type2RGB(jc
));
123 ps_line(ps
,xm
,ym
,xj
,yj
);
126 ps_rgb(ps
,Type2RGB(ic
));
127 ps_line(ps
,xi
,yi
,xj
,yj
);
133 void ps_draw_objects(t_psdata ps
,int nobj
,t_object objs
[],iv2 vec2
[],rvec x
[],
134 char **atomnm
[],int size
[],bool bShowHydro
,int bond_type
,
142 for(i
=0; (i
<nobj
); i
++) {
146 ps_draw_atom(ps
,obj
->ai
,vec2
,atomnm
);
149 ps_draw_bond(ps
,obj
->ai
,obj
->aj
,vec2
,x
,atomnm
,size
,bBalls
);
153 ps_draw_bond(ps
,obj
->ai
,obj
->aj
,vec2
,x
,atomnm
,size
,bBalls
);
161 static void v4_to_iv2(vec4 x4
,iv2 v2
,int x0
,int y0
,real sx
,real sy
)
166 v2
[XX
]=x0
+sx
*x4
[XX
]*inv_z
;
167 v2
[YY
]=y0
-sy
*x4
[YY
]*inv_z
;
170 static void draw_box(t_psdata ps
,t_3dview
*view
,matrix box
,
171 int x0
,int y0
,real sx
,real sy
)
174 { 0,0,0,1 }, { 1,0,0,1 }, { 1,1,0,1 }, { 0,1,0,1 },
175 { 0,0,1,1 }, { 1,0,1,1 }, { 1,1,1,1 }, { 0,1,1,1 }
178 { 0,1 }, { 1,2 }, { 2,3 }, { 3,0 },
179 { 4,5 }, { 5,6 }, { 6,7 }, { 7,4 },
180 { 0,4 }, { 1,5 }, { 2,6 }, { 3,7 }
187 for (i
=0; (i
<8); i
++) {
188 for (j
=0; (j
<DIM
); j
++)
189 corner
[i
][j
] = ivec
[i
][j
]*box
[j
][j
];
190 m4_op(view
->proj
,corner
[i
],x4
);
191 v4_to_iv2(x4
,vec2
[i
],x0
,y0
,sx
,sy
);
193 ps_color(ps
,0,0,0.5);
194 for (i
=0; (i
<12); i
++)
196 vec2
[bonds
[i
][0]][XX
],vec2
[bonds
[i
][0]][YY
],
197 vec2
[bonds
[i
][1]][XX
],vec2
[bonds
[i
][1]][YY
]);
200 void ps_draw_mol(t_psdata ps
,t_manager
*man
)
202 static char tstr
[2][20];
212 if (man
->status
== -1)
223 sx
=win
->width
/2*view
->sc_x
;
224 sy
=win
->height
/2*view
->sc_y
;
228 /* create_visibility(man); */
230 for(i
=0; (i
<man
->natom
); i
++) {
232 m4_op(view
->proj
,man
->x
[i
],x4
);
234 v4_to_iv2(x4
,vec2
[i
],x0
,y0
,sx
,sy
);
237 set_sizes(man
,sx
,sy
);
239 z_fill (man
,man
->zz
);
242 XClearWindow(x11->disp,win->self); */
245 sprintf(tstr[ntime],"Time: %.3 ps",man->time);
246 if (strcmp(tstr[ntime],tstr[1-ntime]) != 0) {
247 set_vbtime(x11,man->vbox,tstr[ntime]);
251 if (mw
->boxtype
!= esbNone
)
252 draw_box(ps
,view
,man
->box
,x0
,y0
,sx
,sy
);
254 /* Should sort on Z-Coordinates here! */
255 nvis
=filter_vis(man
);
256 if (nvis
&& man
->bSort
)
257 qsort(man
->obj
,nvis
,sizeof(man
->obj
[0]),compare_obj
);
259 /* Draw the objects */
261 nvis
,man
->obj
,man
->ix
,man
->x
,man
->top
.atoms
.atomname
,
263 mw
->bShowHydrogen
,mw
->bond_type
,man
->bPlus
);
265 /* Draw the labels */
267 for(i
=0; (i
<man
->natom
); i
++)
268 if (man
->bLabel
[i
] && man
->bVis
[i
])
269 ps_text(ps
,vec2
[i
][XX
]+2,vec2
[i
][YY
]-2,man
->szLab
[i
]);