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_nload_c
= "$Id$";
39 void DrawLoad(t_x11
*x11
,t_windata
*Win
,int nloads
,int *loadinfo
)
41 static char *Strings
[] = { "Unbalance","Single Processor","Your Ad Here ?"};
42 int i
,y0
,bwidth
,boff
,bar
,bmax
,bmin
,ym
,yh
;
49 XClearWindow(x11
->disp
, Win
->self
);
50 y0
=XTextHeight(x11
->font
)+AIR
;
51 yh
=(Win
->height
-y0
)/2;
53 XSetForeground(x11
->disp
,x11
->gc
,WHITE
);
54 XDrawLine(x11
->disp
,Win
->self
,x11
->gc
,0,y0
,Win
->width
,y0
);
57 TextInRect(x11
,Win
->self
,Strings
[0],AIR
,0,Win
->width
-2*AIR
,y0
,
59 if (loadinfo
[0] == 0) {
65 if (loadinfo
[nloads
-1] == 0)
68 bwidth
= (Win
->width
) / nloads
;
69 boff
= (Win
->width
% nloads
)/2;
74 for (i
=1; (i
<nloads
); i
++) {
75 bmax
= max (bmax
,lb
[i
]);
76 bmin
= min (bmin
,lb
[i
]);
80 bscale
= (yh
-2)/max(fabs(bmax
-bav
),fabs(bav
-bmin
));
81 sprintf(maxstr
,"(%d%%)",(int)(100.0*(bmax
-bav
)/bav
));
82 TextInRect(x11
,Win
->self
,maxstr
,AIR
,0,Win
->width
-2*AIR
,y0
,
85 XDrawLine(x11
->disp
,Win
->self
,x11
->gc
,0,ym
,Win
->width
,ym
);
87 for(i
=0; i
<nloads
; i
++) {
88 bar
=(lb
[i
]-bav
)*bscale
;
91 XFillRectangle(x11
->disp
,Win
->self
,x11
->gc
,
92 (i
*bwidth
)+boff
+1,ym
-bar
+1,bwidth
-2,bar
);
94 XFillRectangle(x11
->disp
,Win
->self
,x11
->gc
,
95 (i
*bwidth
)+boff
+1,ym
,bwidth
-2,-bar
);
102 TextInRect(x11
,Win
->self
,Strings
[1],AIR
,0,Win
->width
,y0
,eXLeft
,eYCenter
);
103 TextInRect(x11
,Win
->self
,Strings
[2],AIR
,y0
,Win
->width
,
104 Win
->height
-y0
,eXLeft
,eYCenter
);
106 XSetForeground(x11
->disp
,x11
->gc
,x11
->fg
);
109 static bool LWCallBack(t_x11
*x11
,XEvent
*event
, Window w
, void *data
)
113 lw
=(t_loadwin
*)data
;
114 switch(event
->type
) {
116 DrawLoad(x11
,&lw
->wd
,lw
->nprocs
,lw
->load
);
124 t_loadwin
*init_lw(t_x11
*x11
,Window Parent
,
125 int x
,int y
,int width
,int height
,
126 unsigned long fg
,unsigned long bg
)
131 snew(lw
->load
,MAXPROC
);
133 InitWin(&lw
->wd
,x
,y
,width
,height
,1,"Load Window");
134 lw
->wd
.self
=XCreateSimpleWindow(x11
->disp
,Parent
,x
,y
,1,1,1,fg
,bg
);
135 x11
->RegisterCallback(x11
,lw
->wd
.self
,Parent
,LWCallBack
,lw
);
136 x11
->SetInputMask(x11
,lw
->wd
.self
,ExposureMask
);
141 void map_lw(t_x11
*x11
,t_loadwin
*lw
)
143 XMapWindow(x11
->disp
,lw
->wd
.self
);
146 void set_load(t_x11
*x11
,t_loadwin
*lw
,int nprocs
,int load
[])
152 for(i
=0; (i
<nprocs
); i
++)
153 if (lw
->load
[i
] != load
[i
]) {
158 ExposeWin(x11
->disp
,lw
->wd
.self
);
161 void done_lw(t_x11
*x11
,t_loadwin
*lw
)
163 x11
->UnRegisterCallback(x11
,lw
->wd
.self
);