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
47 void DrawLoad(t_x11 *x11,t_windata *Win,int nloads,int *loadinfo)
49 static char *Strings[] = { "Unbalance","Single Node","Your Ad Here ?"};
50 int i,y0,bwidth,boff,bar,bmax,bmin,ym,yh;
57 XClearWindow(x11->disp, Win->self);
58 y0=XTextHeight(x11->font)+AIR;
59 yh=(Win->height-y0)/2;
61 XSetForeground(x11->disp,x11->gc,WHITE);
62 XDrawLine(x11->disp,Win->self,x11->gc,0,y0,Win->width,y0);
65 TextInRect(x11,Win->self,Strings[0],AIR,0,Win->width-2*AIR,y0,
67 if (loadinfo[0] == 0) {
73 if (loadinfo[nloads-1] == 0)
76 bwidth = (Win->width) / nloads;
77 boff = (Win->width % nloads)/2;
82 for (i=1; (i<nloads); i++) {
83 bmax = max (bmax,lb[i]);
84 bmin = min (bmin,lb[i]);
88 bscale = (yh-2)/max(fabs(bmax-bav),fabs(bav-bmin));
89 sprintf(maxstr,"(%d%%)",(int)(100.0*(bmax-bav)/bav));
90 TextInRect(x11,Win->self,maxstr,AIR,0,Win->width-2*AIR,y0,
93 XDrawLine(x11->disp,Win->self,x11->gc,0,ym,Win->width,ym);
95 for(i=0; i<nloads; i++) {
96 bar=(lb[i]-bav)*bscale;
99 XFillRectangle(x11->disp,Win->self,x11->gc,
100 (i*bwidth)+boff+1,ym-bar+1,bwidth-2,bar);
102 XFillRectangle(x11->disp,Win->self,x11->gc,
103 (i*bwidth)+boff+1,ym,bwidth-2,-bar);
110 TextInRect(x11,Win->self,Strings[1],AIR,0,Win->width,y0,eXLeft,eYCenter);
111 TextInRect(x11,Win->self,Strings[2],AIR,y0,Win->width,
112 Win->height-y0,eXLeft,eYCenter);
114 XSetForeground(x11->disp,x11->gc,x11->fg);
117 static gmx_bool LWCallBack(t_x11 *x11,XEvent *event, Window w, void *data)
121 lw=(t_loadwin *)data;
122 switch(event->type) {
124 DrawLoad(x11,&lw->wd,lw->nnodes,lw->load);
132 t_loadwin *init_lw(t_x11 *x11,Window Parent,
133 int x,int y,int width,int height,
134 unsigned long fg,unsigned long bg)
139 snew(lw->load,MAXNODES);
141 InitWin(&lw->wd,x,y,width,height,1,"Load Window");
142 lw->wd.self=XCreateSimpleWindow(x11->disp,Parent,x,y,1,1,1,fg,bg);
143 x11->RegisterCallback(x11,lw->wd.self,Parent,LWCallBack,lw);
144 x11->SetInputMask(x11,lw->wd.self,ExposureMask);
149 void map_lw(t_x11 *x11,t_loadwin *lw)
151 XMapWindow(x11->disp,lw->wd.self);
154 void set_load(t_x11 *x11,t_loadwin *lw,int nnodes,int load[])
157 gmx_bool bChange=FALSE;
160 for(i=0; (i<nnodes); i++)
161 if (lw->load[i] != load[i]) {
166 ExposeWin(x11->disp,lw->wd.self);
169 void done_lw(t_x11 *x11,t_loadwin *lw)
171 x11->UnRegisterCallback(x11,lw->wd.self);