4 * This source code is part of
8 * GROningen MAchine for Chemical Simulations
12 * Copyright (c) 1991-2001
13 * BIOSON Research Institute, Dept. of Biophysical Chemistry
14 * University of Groningen, The Netherlands
16 * This program is free software; you can redistribute it and/or
17 * modify it under the terms of the GNU General Public License
18 * as published by the Free Software Foundation; either version 2
19 * of the License, or (at your option) any later version.
21 * If you want to redistribute modifications, please consider that
22 * scientific software is very special. Version control is crucial -
23 * bugs must be traceable. We will be happy to consider code for
24 * inclusion in the official distribution, but derived work must not
25 * be called official GROMACS. Details are found in the README & COPYING
26 * files - if they are missing, get the official version at www.gromacs.org.
28 * To help us fund GROMACS development, we humbly ask that you cite
29 * the papers on the package - you can find them in the top README file.
31 * Do check out http://www.gromacs.org , or mail us at gromacs@gromacs.org .
34 * Good gRace! Old Maple Actually Chews Slate
36 static char *SRCID_filter_c = "$Id$";
47 t_filter *init_filter(t_atoms *atoms, char *fn, int natom_trx)
54 f->grps=init_index(fn,&f->grpnames);
57 snew(f->grps->index,1);
58 analyse(atoms,f->grps,&f->grpnames,FALSE,FALSE);
60 snew(f->bDisable,f->grps->nr);
61 for(g=0; g<f->grps->nr; g++)
62 for(i=f->grps->index[g]; i<f->grps->index[g+1] && !f->bDisable[g]; i++)
63 f->bDisable[g] = (f->grps->a[i] >= natom_trx);
65 snew(f->bShow,f->grps->nr);
70 static void FilterCB(t_x11 *x11,int dlg_mess,int item_id,
79 dlg=gmx->dlgs[edFilter];
83 printf("item_id: %d, set: %s\n",item_id,set);
88 if (sscanf(set,"%d",&nset)==1)
89 f->bShow[nset]=!f->bShow[nset];
93 write_gmx(x11,gmx,IDDOFILTER);
98 t_dlg *select_filter(t_x11 *x11,t_gmx *gmx)
100 static char *title="Group";
101 static char *dummy="\"FALSE\"";
102 static char *ok="\"Ok\"";
105 char tmpfile[L_tmpnam];
106 int i,j,k,len,tlen,ht,ncol,nrow,x0;
109 for(i=0; (i<(int)gmx->filter->grps->nr); i++)
110 len=max(len,(int)strlen(gmx->filter->grpnames[i]));
113 ncol=1+(gmx->filter->grps->nr / 15);
114 nrow=gmx->filter->grps->nr/ncol;
115 if (nrow*ncol < gmx->filter->grps->nr)
121 ht=1+(gmx->filter->grps->nr+1)*2+3;
125 fprintf(stderr,"file: %s\n",tmpfile);
127 tmp=fopen(tmpfile,"w");
129 fprintf(tmp,"grid %d %d {\n\n",tlen,ht);
131 for(k=j=0,x0=1; (j<ncol); j++,x0+=len+1) {
132 fprintf(tmp,"group \"%s-%d\" %d 1 %d %d {\n",title,j+1,x0,len,ht-5);
133 for(i=0; (i<nrow) && (k<gmx->filter->grps->nr); i++,k++)
134 if (!gmx->filter->bDisable[k])
135 fprintf(tmp,"checkbox \"%s\" \"%d\" %s %s %s\n",
136 gmx->filter->grpnames[k],k,dummy,dummy,dummy);
138 fprintf(tmp,"statictext { \" %s\" } \"%d\" %s %s %s\n",
139 gmx->filter->grpnames[k],k,dummy,dummy,dummy);
140 fprintf(tmp,"}\n\n");
142 fprintf(tmp,"simple 1 %d %d 2 {\n",ht-3,tlen-2);
143 fprintf(tmp,"defbutton %s %s %s %s %s\n",ok,ok,dummy,dummy,dummy);
144 fprintf(tmp,"}\n\n}\n");
147 dlg=ReadDlg(x11,gmx->wd->self,title,x11->fg,x11->bg,tmpfile,
148 0,0,TRUE,FALSE,FilterCB,gmx);