4 * This source code is part of
8 * GROningen MAchine for Chemical Simulations
11 * Copyright (c) 1991-2001, University of Groningen, The Netherlands
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * If you want to redistribute modifications, please consider that
18 * scientific software is very special. Version control is crucial -
19 * bugs must be traceable. We will be happy to consider code for
20 * inclusion in the official distribution, but derived work must not
21 * be called official GROMACS. Details are found in the README & COPYING
22 * files - if they are missing, get the official version at www.gromacs.org.
24 * To help us fund GROMACS development, we humbly ask that you cite
25 * the papers on the package - you can find them in the top README file.
27 * For more info, check our website at http://www.gromacs.org
30 * Glycine aRginine prOline Methionine Alanine Cystine Serine
40 static void DrawEGraph(t_x11
*x11
,t_enerwin
*ew
)
44 real epr
,scale
,MaxE
,MinE
;
50 XClearWindow(x11
->disp
,wd
->self
);
52 /* Calculate boundaries */
53 MaxE
=MinE
=ew
->e
[ew
->etype
][0];
54 for (i
=1; (i
<ew
->nlast
); i
++) {
55 MaxE
=max(ew
->e
[ew
->etype
][i
],MaxE
);
56 MinE
=min(ew
->e
[ew
->etype
][i
],MinE
);
60 epr
=max(fabs(MaxE
),fabs(MinE
));
61 sprintf(maxstr
,"%.0f",epr
);
62 EHeight
=XTextHeight(x11
->font
)+AIR
;
63 TextInRect(x11
,wd
->self
,EType
[ew
->etype
],AIR
,0,
64 wd
->width
-2*AIR
,EHeight
,eXLeft
,eYCenter
);
65 TextInRect(x11
,wd
->self
,maxstr
,AIR
,0,
66 wd
->width
-2*AIR
,EHeight
,eXRight
,eYCenter
);
67 XDrawLine(x11
->disp
, wd
->self
,x11
->gc
,0,EHeight
,wd
->width
,EHeight
);
72 if (fabs(MaxE
-MinE
) < 1e-5)
75 EZero
=(wd
->height
-EHeight
)/2;
76 scale
=EZero
/(real
) epr
;
78 XDrawLine(x11
->disp
,wd
->self
,x11
->gc
,0,EZero
,wd
->width
,EZero
);
80 for(i
=0; (i
<ew
->nlast
); i
++) {
81 y
=ew
->e
[ew
->etype
][i
]*scale
;
83 XDrawLine(x11
->disp
,wd
->self
,x11
->gc
,i
,EZero
,i
,EZero
-y
);
87 static bool EWCallBack(t_x11
*x11
,XEvent
*event
, Window w
, void *data
)
96 XSetForeground(x11
->disp
,x11
->gc
,WHITE
);
98 XSetForeground(x11
->disp
,x11
->gc
,x11
->fg
);
100 case ConfigureNotify
:
101 ew
->wd
.x
=event
->xconfigure
.x
;
102 ew
->wd
.y
=event
->xconfigure
.y
;
103 ew
->wd
.width
=event
->xconfigure
.width
;
104 ew
->wd
.height
=event
->xconfigure
.height
;
105 if (ew
->wd
.width
> ew
->nwidth
) {
106 ew
->nwidth
=ew
->wd
.width
;
107 for (i
=0; (i
<ew
->nre
); i
++)
108 srenew(ew
->e
[i
],ew
->nwidth
);
113 y
=ew
->wd
.y
+event
->xbutton
.y
;
114 width
=menu_width(ew
->selener
);
115 x
=min(x
+ew
->wd
.x
,ew
->wd
.x
+ew
->wd
.width
-width
);
116 printf("Showing at %d,%d, width %d\n",x
,y
,width
);
117 show_menu(x11
,ew
->selener
,x
,y
,TRUE
);
120 ew
->etype
=event
->xclient
.data
.l
[0];
121 ExposeWin(x11
->disp
,ew
->wd
.self
);
124 hide_menu(x11
,ew
->selener
);
132 static void create_selener(t_x11
*x11
,t_enerwin
*ew
,Window Parent
)
138 for(i
=0; (i
<ew
->nre
); i
++) {
139 se
[i
].send_to
=ew
->wd
.self
;
141 se
[i
].bChecked
=FALSE
;
144 ew
->selener
=init_menu(x11
,Parent
,x11
->fg
,x11
->bg
,ew
->nre
,se
,1);
147 t_enerwin
*init_ew(t_x11
*x11
,Window Parent
,
148 int x
,int y
,int width
,int height
,
149 unsigned long fg
,unsigned long bg
)
160 for(i
=0; (i
<ew
->nre
); i
++)
161 snew(ew
->e
[i
],width
);
162 InitWin(&ew
->wd
,x
,y
,width
,height
,1,"Ener Window");
163 ew
->wd
.self
=XCreateSimpleWindow(x11
->disp
,Parent
,x
,y
,1,1,1,fg
,bg
);
164 x11
->RegisterCallback(x11
,ew
->wd
.self
,Parent
,EWCallBack
,ew
);
165 x11
->SetInputMask(x11
,ew
->wd
.self
,ExposureMask
| ButtonPressMask
|
166 ButtonReleaseMask
| StructureNotifyMask
|
167 OwnerGrabButtonMask
);
168 create_selener(x11
,ew
,Parent
);
173 void map_ewin(t_x11
*x11
,t_enerwin
*ew
)
175 XMapWindow(x11
->disp
,ew
->wd
.self
);
178 void add_ener(t_x11
*x11
,t_enerwin
*ew
,t_energy e
[])
183 if (ew
->nlast
>= ew
->nwidth
) {
184 for(j
=0; (j
<ew
->nre
); j
++)
186 ew
->e
[j
][i
]=ew
->e
[j
][i
+w
];
190 for(j
=0; (j
<ew
->nre
); j
++) {
191 ew
->e
[j
][ew
->nlast
]=e
[j
].e
;
194 ExposeWin(x11
->disp
,ew
->wd
.self
);
197 void rewind_ener(t_x11
*x11
,t_enerwin
*ew
)
200 ExposeWin(x11
->disp
,ew
->wd
.self
);
203 void done_ew(t_x11
*x11
,t_enerwin
*ew
)
205 done_menu(x11
,ew
->selener
);
206 x11
->UnRegisterCallback(x11
,ew
->wd
.self
);