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
51 #include "gmx_fatal.h"
53 #define MBFLAGS /* MB_APPLMODAL | */ MB_DONTSHOW
55 void write_gmx(t_x11 *x11,t_gmx *gmx,int mess)
59 letter.type=ClientMessage;
60 letter.xclient.display=x11->disp;
61 letter.xclient.window=gmx->wd->self;
62 letter.xclient.message_type=0;
63 letter.xclient.format=32;
64 letter.xclient.data.l[0]=mess;
65 letter.xclient.data.l[1]=Button1;
66 XSendEvent(x11->disp,letter.xclient.window,True,0,&letter);
69 static void shell_comm(const char *title,const char *script,int nsleep)
75 strcpy(tmp,"dialogXXXXXX");
78 if ((tfil = fopen(tmp,"w")) == NULL) {
79 sprintf(tmp,"%ctmp%cdialogXXXXXX",DIR_SEPARATOR,DIR_SEPARATOR);
86 if ((tfil = fopen(tmp,"w")) == NULL)
87 gmx_fatal(FARGS,"Can not open tmp file %s",tmp);
89 fprintf(tfil,"%s\n",script);
90 fprintf(tfil,"sleep %d\n",nsleep);
93 sprintf(command,"xterm -title %s -e sh %s",title,tmp);
95 fprintf(stderr,"command: %s\n",command);
99 printf("Warning-- No calls to system(3) supported on this platform.");
100 printf("Warning-- Skipping execution of 'system(\"%s\")'.", buf);
102 if(0 != system(command))
104 gmx_fatal(FARGS,"Failed to execute command: %s",command);
113 void show_mb(t_gmx *gmx,int mb)
115 if (mb >=0 && mb < emNR) {
117 ShowDlg(gmx->mboxes[mb]);
121 static void hide_mb(t_gmx *gmx)
123 if (gmx->which_mb >= 0 && gmx->which_mb < emNR) {
124 HideDlg(gmx->mboxes[gmx->which_mb]);
129 static void MBCallback(t_x11 *x11,int dlg_mess,int item_id,
130 char *set,void *data)
135 if (dlg_mess==DLG_EXIT)
139 static t_dlg *about_mb(t_x11 *x11,t_gmx *gmx)
143 " Machine for Simulating Chemistry",
144 " Copyright (c) 1992-2000",
145 " Dept. of Biophysical Chemistry",
146 " University of Groningen"
149 return MessageBox(x11,gmx->wd->self,gmx->wd->text,
150 asize(lines),lines,MB_OK | MB_ICONGMX | MBFLAGS,
154 static void QuitCB(t_x11 *x11,int dlg_mess,int item_id,
155 char *set,void *data)
161 if (dlg_mess==DLG_EXIT) {
162 if (gmx_strcasecmp("yes",set)==0)
163 write_gmx(x11,gmx,IDTERM);
167 static t_dlg *quit_mb(t_x11 *x11,t_gmx *gmx)
170 " Do you really want to Quit ?"
173 return MessageBox(x11,gmx->wd->self,gmx->wd->text,
175 MB_YESNO | MB_ICONSTOP | MBFLAGS,
179 static t_dlg *help_mb(t_x11 *x11,t_gmx *gmx)
182 " Help will soon be added"
185 return MessageBox(x11,gmx->wd->self,gmx->wd->text,
187 MB_OK | MB_ICONINFORMATION | MBFLAGS,
191 static t_dlg *ni_mb(t_x11 *x11,t_gmx *gmx)
194 " This feature has not been",
198 return MessageBox(x11,gmx->wd->self,gmx->wd->text,
200 MB_OK | MB_ICONEXCLAMATION | MBFLAGS,
204 enum { eExE, eExGrom, eExPdb, eExConf, eExNR };
206 static void ExportCB(t_x11 *x11,int dlg_mess,int item_id,
207 char *set,void *data)
214 dlg=gmx->dlgs[edExport];
219 gmx->ExpMode=eExpGromos;
222 gmx->ExpMode=eExpPDB;
228 fprintf(stderr,"exportcb: item_id=%d\n",item_id);
232 if ((bOk=gmx_strcasecmp("ok",set))==0)
233 strcpy(gmx->confout,EditText(dlg,eExConf));
236 write_gmx(x11,gmx,IDDOEXPORT);
241 enum { eg0, egTOPOL, egCONFIN, egPARAM, eg1, eg1PROC, eg32PROC };
243 static void Extract(t_dlg *dlg,int ID,char *buf)
252 enum bond_set { ebShowH=11, ebDPlus, ebRMPBC, ebCue, ebSkip, ebWait };
254 static void BondsCB(t_x11 *x11,int dlg_mess,int item_id,
255 char *set,void *data)
259 gmx_bool bOk,bBond=FALSE;
265 ebond = gmx->man->molw->bond_type;
266 ebox = gmx->man->molw->boxtype;
270 if (item_id <= eBNR) {
274 else if (item_id <= eBNR+esbNR+1) {
275 ebox = item_id-eBNR-2;
280 #define DO_NOT(b) (b) = (!(b))
284 toggle_hydrogen(x11,gmx->man->molw);
287 DO_NOT(gmx->man->bPlus);
289 fprintf(stderr,"gmx->man->bPlus=%s\n",gmx_bool_names[gmx->man->bPlus]);
293 set_box_type(x11,gmx->man->molw,ebond);
296 toggle_pbc(gmx->man);
299 DO_NOT(gmx->man->bSort);
301 fprintf(stderr,"gmx->man->bSort=%s\n",gmx_bool_names[gmx->man->bSort]);
305 sscanf(set,"%d",&nskip);
307 fprintf(stderr,"nskip: %d frames\n",nskip);
310 gmx->man->nSkip=nskip;
313 sscanf(set,"%d",&nwait);
315 fprintf(stderr,"wait: %d ms\n",nwait);
318 gmx->man->nWait=nwait;
321 fprintf(stderr,"item_id: %d, set: %s\n",item_id,set);
328 bOk=(gmx_strcasecmp("ok",set)==0);
329 HideDlg(gmx->dlgs[edBonds]);
334 write_gmx(x11,gmx,IDTHIN);
337 write_gmx(x11,gmx,IDFAT);
340 write_gmx(x11,gmx,IDVERYFAT);
343 write_gmx(x11,gmx,IDBALLS);
346 gmx_fatal(FARGS,"Invalid bond type %d at %s, %d",
347 ebond,__FILE__,__LINE__);
353 write_gmx(x11,gmx,IDNOBOX);
356 write_gmx(x11,gmx,IDRECTBOX);
359 write_gmx(x11,gmx,IDTRIBOX);
362 write_gmx(x11,gmx,IDTOBOX);
365 gmx_fatal(FARGS,"Invalid box type %d at %s, %d",
366 ebox,__FILE__,__LINE__);
374 enum { esFUNCT=1, esBSHOW, esINFIL, esINDEXFIL, esLSQ, esSHOW, esPLOTFIL };
376 static gmx_bool in_set(int i,int n,int set[])
385 typedef t_dlg *t_mmb(t_x11 *x11,t_gmx *gmx);
399 void init_dlgs(t_x11 *x11,t_gmx *gmx)
401 static t_dlginit di[] = {
402 { edExport, "export.dlg", ExportCB },
403 { edBonds, "bonds.dlg", BondsCB }
405 static t_mbinit mi[emNR] = {
406 { emQuit, quit_mb, QuitCB },
407 { emHelp, help_mb, MBCallback },
408 { emAbout, about_mb, MBCallback },
409 { emNotImplemented, ni_mb, MBCallback }
413 snew(gmx->dlgs,edNR);
414 for(i=0; (i<asize(di)); i++)
415 gmx->dlgs[i]=ReadDlg(x11,gmx->wd->self,di[i].dlgfile,
416 x11->fg,x11->bg,di[i].dlgfile,
417 0,0,TRUE,FALSE,di[i].cb,gmx);
419 gmx->dlgs[edFilter]=select_filter(x11,gmx);
421 snew(gmx->mboxes,emNR);
422 for(i=0; (i<emNR); i++)
423 gmx->mboxes[i]=mi[i].mmb(x11,gmx);
427 void done_dlgs(t_gmx *gmx)
431 for(i=0; (i<edNR); i++)
432 FreeDlg(gmx->dlgs[i]);
433 for(i=0; (i<emNR); i++)
434 FreeDlg(gmx->mboxes[i]);
437 void edit_file(const char *fn)
442 sprintf(script,"vi %s",fn);
443 shell_comm(fn,script,0);