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 static void DrawEGraph(t_x11
*x11
,t_enerwin
*ew
)
50 real epr
,scale
,MaxE
,MinE
;
56 XClearWindow(x11
->disp
,wd
->self
);
58 /* Calculate boundaries */
59 MaxE
=MinE
=ew
->e
[ew
->etype
][0];
60 for (i
=1; (i
<ew
->nlast
); i
++) {
61 MaxE
=max(ew
->e
[ew
->etype
][i
],MaxE
);
62 MinE
=min(ew
->e
[ew
->etype
][i
],MinE
);
66 epr
=max(fabs(MaxE
),fabs(MinE
));
67 sprintf(maxstr
,"%.0f",epr
);
68 EHeight
=XTextHeight(x11
->font
)+AIR
;
69 TextInRect(x11
,wd
->self
,EType
[ew
->etype
],AIR
,0,
70 wd
->width
-2*AIR
,EHeight
,eXLeft
,eYCenter
);
71 TextInRect(x11
,wd
->self
,maxstr
,AIR
,0,
72 wd
->width
-2*AIR
,EHeight
,eXRight
,eYCenter
);
73 XDrawLine(x11
->disp
, wd
->self
,x11
->gc
,0,EHeight
,wd
->width
,EHeight
);
78 if (fabs(MaxE
-MinE
) < 1e-5)
81 EZero
=(wd
->height
-EHeight
)/2;
82 scale
=EZero
/(real
) epr
;
84 XDrawLine(x11
->disp
,wd
->self
,x11
->gc
,0,EZero
,wd
->width
,EZero
);
86 for(i
=0; (i
<ew
->nlast
); i
++) {
87 y
=ew
->e
[ew
->etype
][i
]*scale
;
89 XDrawLine(x11
->disp
,wd
->self
,x11
->gc
,i
,EZero
,i
,EZero
-y
);
93 static bool EWCallBack(t_x11
*x11
,XEvent
*event
, Window w
, void *data
)
100 switch(event
->type
) {
102 XSetForeground(x11
->disp
,x11
->gc
,WHITE
);
104 XSetForeground(x11
->disp
,x11
->gc
,x11
->fg
);
106 case ConfigureNotify
:
107 ew
->wd
.x
=event
->xconfigure
.x
;
108 ew
->wd
.y
=event
->xconfigure
.y
;
109 ew
->wd
.width
=event
->xconfigure
.width
;
110 ew
->wd
.height
=event
->xconfigure
.height
;
111 if (ew
->wd
.width
> ew
->nwidth
) {
112 ew
->nwidth
=ew
->wd
.width
;
113 for (i
=0; (i
<ew
->nre
); i
++)
114 srenew(ew
->e
[i
],ew
->nwidth
);
119 y
=ew
->wd
.y
+event
->xbutton
.y
;
120 width
=menu_width(ew
->selener
);
121 x
=min(x
+ew
->wd
.x
,ew
->wd
.x
+ew
->wd
.width
-width
);
122 printf("Showing at %d,%d, width %d\n",x
,y
,width
);
123 show_menu(x11
,ew
->selener
,x
,y
,TRUE
);
126 ew
->etype
=event
->xclient
.data
.l
[0];
127 ExposeWin(x11
->disp
,ew
->wd
.self
);
130 hide_menu(x11
,ew
->selener
);
138 static void create_selener(t_x11
*x11
,t_enerwin
*ew
,Window Parent
)
144 for(i
=0; (i
<ew
->nre
); i
++) {
145 se
[i
].send_to
=ew
->wd
.self
;
147 se
[i
].bChecked
=FALSE
;
150 ew
->selener
=init_menu(x11
,Parent
,x11
->fg
,x11
->bg
,ew
->nre
,se
,1);
153 t_enerwin
*init_ew(t_x11
*x11
,Window Parent
,
154 int x
,int y
,int width
,int height
,
155 unsigned long fg
,unsigned long bg
)
166 for(i
=0; (i
<ew
->nre
); i
++)
167 snew(ew
->e
[i
],width
);
168 InitWin(&ew
->wd
,x
,y
,width
,height
,1,"Ener Window");
169 ew
->wd
.self
=XCreateSimpleWindow(x11
->disp
,Parent
,x
,y
,1,1,1,fg
,bg
);
170 x11
->RegisterCallback(x11
,ew
->wd
.self
,Parent
,EWCallBack
,ew
);
171 x11
->SetInputMask(x11
,ew
->wd
.self
,ExposureMask
| ButtonPressMask
|
172 ButtonReleaseMask
| StructureNotifyMask
|
173 OwnerGrabButtonMask
);
174 create_selener(x11
,ew
,Parent
);
179 void map_ewin(t_x11
*x11
,t_enerwin
*ew
)
181 XMapWindow(x11
->disp
,ew
->wd
.self
);
184 void add_ener(t_x11
*x11
,t_enerwin
*ew
,t_energy e
[])
189 if (ew
->nlast
>= ew
->nwidth
) {
190 for(j
=0; (j
<ew
->nre
); j
++)
192 ew
->e
[j
][i
]=ew
->e
[j
][i
+w
];
196 for(j
=0; (j
<ew
->nre
); j
++) {
197 ew
->e
[j
][ew
->nlast
]=e
[j
].e
;
200 ExposeWin(x11
->disp
,ew
->wd
.self
);
203 void rewind_ener(t_x11
*x11
,t_enerwin
*ew
)
206 ExposeWin(x11
->disp
,ew
->wd
.self
);
209 void done_ew(t_x11
*x11
,t_enerwin
*ew
)
211 done_menu(x11
,ew
->selener
);
212 x11
->UnRegisterCallback(x11
,ew
->wd
.self
);