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_dialogs_c
= "$Id$";
43 #define MBFLAGS /* MB_APPLMODAL | */ MB_DONTSHOW
45 void write_gmx(t_x11
*x11
,t_gmx
*gmx
,int mess
)
49 letter
.type
=ClientMessage
;
50 letter
.xclient
.display
=x11
->disp
;
51 letter
.xclient
.window
=gmx
->wd
->self
;
52 letter
.xclient
.message_type
=0;
53 letter
.xclient
.format
=32;
54 letter
.xclient
.data
.l
[0]=mess
;
55 letter
.xclient
.data
.l
[1]=Button1
;
56 XSendEvent(x11
->disp
,letter
.xclient
.window
,True
,0,&letter
);
59 static void shell_comm(char *title
,char *script
,int nsleep
)
66 if ((tfil
=fopen(tmp
,"w"))==NULL
) {
70 fprintf(tfil
,"%s\n",script
);
71 fprintf(tfil
,"sleep %d\n",nsleep
);
74 sprintf(command
,"xterm -title %s -e sh %s",title
,tmp
);
76 fprintf(stderr
,"command: %s\n",command
);
84 void show_mb(t_gmx
*gmx
,int mb
)
86 if (mb
>=0 && mb
< emNR
) {
88 ShowDlg(gmx
->mboxes
[mb
]);
92 static void hide_mb(t_gmx
*gmx
)
94 if (gmx
->which_mb
> 0 && gmx
->which_mb
< emNR
)
95 HideDlg(gmx
->mboxes
[gmx
->which_mb
]);
98 static void MBCallback(t_x11
*x11
,int dlg_mess
,int item_id
,
104 if (dlg_mess
==DLG_EXIT
)
108 static t_dlg
*about_mb(t_x11
*x11
,t_gmx
*gmx
)
110 static char *lines
[]={
112 " Machine for Simulating Chemistry",
113 " Copyright (c) 1992",
114 " Dept. of Biophysical Chemistry",
115 " University of Groningen"
118 return MessageBox(x11
,gmx
->wd
->self
,gmx
->wd
->text
,
119 asize(lines
),lines
,MB_OK
| MB_ICONGMX
| MBFLAGS
,
123 static void QuitCB(t_x11
*x11
,int dlg_mess
,int item_id
,
124 char *set
,void *data
)
129 if (dlg_mess
==DLG_EXIT
) {
131 if (strcasecmp("yes",set
)==0)
132 write_gmx(x11
,gmx
,IDTERM
);
136 static t_dlg
*quit_mb(t_x11
*x11
,t_gmx
*gmx
)
138 static char *lines
[]={
139 " Do you really want to Quit ?"
142 return MessageBox(x11
,gmx
->wd
->self
,gmx
->wd
->text
,
144 MB_YESNO
| MB_ICONSTOP
| MBFLAGS
,
148 static t_dlg
*help_mb(t_x11
*x11
,t_gmx
*gmx
)
150 static char *lines
[]={
151 " Help will soon be added"
154 return MessageBox(x11
,gmx
->wd
->self
,gmx
->wd
->text
,
156 MB_OK
| MB_ICONINFORMATION
| MBFLAGS
,
160 static t_dlg
*ni_mb(t_x11
*x11
,t_gmx
*gmx
)
162 static char *lines
[]={
163 " This feature has not been",
167 return MessageBox(x11
,gmx
->wd
->self
,gmx
->wd
->text
,
169 MB_OK
| MB_ICONEXCLAMATION
| MBFLAGS
,
173 enum { eExE
, eExGrom
, eExPdb
, eExConf
, eExNR
};
175 static void ExportCB(t_x11
*x11
,int dlg_mess
,int item_id
,
176 char *set
,void *data
)
183 dlg
=gmx
->dlgs
[edExport
];
188 gmx
->ExpMode
=eExpGromos
;
191 gmx
->ExpMode
=eExpPDB
;
197 fprintf(stderr
,"exportcb: item_id=%d\n",item_id
);
201 if ((bOk
=(strcasecmp("ok",set
))==0))
202 strcpy(gmx
->confout
,EditText(dlg
,eExConf
));
205 write_gmx(x11
,gmx
,IDDOEXPORT
);
210 enum { eg0
, egTOPOL
, egCONFIN
, egPARAM
, eg1
, eg1PROC
, eg32PROC
};
212 static void Extract(t_dlg
*dlg
,int ID
,char *buf
)
221 enum bond_set
{ ebShowH
=6, ebDPlus
, ebSBox
, ebRMPBC
, ebCue
, ebSkip
};
223 static void BondsCB(t_x11
*x11
,int dlg_mess
,int item_id
,
224 char *set
,void *data
)
233 eb
=gmx
->man
->molw
->bond_type
;
241 #define DO_NOT(b) (b) = (!(b))
245 toggle_hydrogen(x11
,gmx
->man
->molw
);
248 DO_NOT(gmx
->man
->bPlus
);
250 fprintf(stderr
,"gmx->man->bPlus=%s\n",bool_names
[gmx
->man
->bPlus
]);
254 toggle_box(x11
,gmx
->man
->molw
);
257 toggle_pbc(gmx
->man
);
260 DO_NOT(gmx
->man
->bSort
);
262 fprintf(stderr
,"gmx->man->bSort=%s\n",bool_names
[gmx
->man
->bSort
]);
266 sscanf(set
,"%d",&nskip
);
268 fprintf(stderr
,"nskip: %d frames\n",nskip
);
271 gmx
->man
->nSkip
=nskip
;
275 fprintf(stderr
,"item_id: %d, set: %s\n",item_id
,set
);
282 bOk
=(strcasecmp("ok",set
)==0);
283 HideDlg(gmx
->dlgs
[edBonds
]);
287 write_gmx(x11
,gmx
,IDTHIN
);
290 write_gmx(x11
,gmx
,IDFAT
);
293 write_gmx(x11
,gmx
,IDVERYFAT
);
296 write_gmx(x11
,gmx
,IDBALLS
);
304 enum { esFUNCT
=1, esBSHOW
, esINFIL
, esINDEXFIL
, esLSQ
, esSHOW
, esPLOTFIL
};
306 static bool in_set(int i
,int n
,int set
[])
315 typedef t_dlg
*t_mmb(t_x11
*x11
,t_gmx
*gmx
);
329 void init_dlgs(t_x11
*x11
,t_gmx
*gmx
)
331 static t_dlginit di
[] = {
332 { edExport
, "export.dlg", ExportCB
},
333 { edBonds
, "bonds.dlg", BondsCB
}
335 static t_mbinit mi
[emNR
] = {
336 { emQuit
, quit_mb
, QuitCB
},
337 { emHelp
, help_mb
, MBCallback
},
338 { emAbout
, about_mb
, MBCallback
},
339 { emNotImplemented
, ni_mb
, MBCallback
}
343 snew(gmx
->dlgs
,edNR
);
344 for(i
=0; (i
<asize(di
)); i
++)
345 gmx
->dlgs
[i
]=ReadDlg(x11
,gmx
->wd
->self
,di
[i
].dlgfile
,
346 x11
->fg
,x11
->bg
,di
[i
].dlgfile
,
347 0,0,TRUE
,FALSE
,di
[i
].cb
,gmx
);
349 gmx
->dlgs
[edFilter
]=select_filter(x11
,gmx
);
351 snew(gmx
->mboxes
,emNR
);
352 for(i
=0; (i
<emNR
); i
++)
353 gmx
->mboxes
[i
]=mi
[i
].mmb(x11
,gmx
);
356 void done_dlgs(t_gmx
*gmx
)
360 for(i
=0; (i
<edNR
); i
++)
361 FreeDlg(gmx
->dlgs
[i
]);
362 for(i
=0; (i
<emNR
); i
++)
363 FreeDlg(gmx
->mboxes
[i
]);
366 void edit_file(char *fn
)
371 sprintf(script
,"vi %s",fn
);
372 shell_comm(fn
,script
,0);