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)
80 sprintf(tmp, "%ctmp%cdialogXXXXXX", DIR_SEPARATOR, DIR_SEPARATOR);
87 if ((tfil = fopen(tmp, "w")) == NULL)
89 gmx_fatal(FARGS, "Can not open tmp file %s", tmp);
92 fprintf(tfil, "%s\n", script);
93 fprintf(tfil, "sleep %d\n", nsleep);
96 sprintf(command, "xterm -title %s -e sh %s", title, tmp);
98 fprintf(stderr, "command: %s\n", command);
102 printf("Warning-- No calls to system(3) supported on this platform.");
103 printf("Warning-- Skipping execution of 'system(\"%s\")'.", buf);
105 if (0 != system(command))
107 gmx_fatal(FARGS, "Failed to execute command: %s", command);
116 void show_mb(t_gmx *gmx, int mb)
118 if (mb >= 0 && mb < emNR)
121 ShowDlg(gmx->mboxes[mb]);
125 static void hide_mb(t_gmx *gmx)
127 if (gmx->which_mb >= 0 && gmx->which_mb < emNR)
129 HideDlg(gmx->mboxes[gmx->which_mb]);
134 static void MBCallback(t_x11 *x11, int dlg_mess, int item_id,
135 char *set, void *data)
140 if (dlg_mess == DLG_EXIT)
146 static t_dlg *about_mb(t_x11 *x11, t_gmx *gmx)
150 " Machine for Simulating Chemistry",
151 " Copyright (c) 1992-2000",
152 " Dept. of Biophysical Chemistry",
153 " University of Groningen"
156 return MessageBox(x11, gmx->wd->self, gmx->wd->text,
157 asize(lines), lines, MB_OK | MB_ICONGMX | MBFLAGS,
161 static void QuitCB(t_x11 *x11, int dlg_mess, int item_id,
162 char *set, void *data)
168 if (dlg_mess == DLG_EXIT)
170 if (gmx_strcasecmp("yes", set) == 0)
172 write_gmx(x11, gmx, IDTERM);
177 static t_dlg *quit_mb(t_x11 *x11, t_gmx *gmx)
180 " Do you really want to Quit ?"
183 return MessageBox(x11, gmx->wd->self, gmx->wd->text,
185 MB_YESNO | MB_ICONSTOP | MBFLAGS,
189 static t_dlg *help_mb(t_x11 *x11, t_gmx *gmx)
192 " Help will soon be added"
195 return MessageBox(x11, gmx->wd->self, gmx->wd->text,
197 MB_OK | MB_ICONINFORMATION | MBFLAGS,
201 static t_dlg *ni_mb(t_x11 *x11, t_gmx *gmx)
204 " This feature has not been",
208 return MessageBox(x11, gmx->wd->self, gmx->wd->text,
210 MB_OK | MB_ICONEXCLAMATION | MBFLAGS,
215 eExE, eExGrom, eExPdb, eExConf, eExNR
218 static void ExportCB(t_x11 *x11, int dlg_mess, int item_id,
219 char *set, void *data)
226 dlg = gmx->dlgs[edExport];
233 gmx->ExpMode = eExpGromos;
236 gmx->ExpMode = eExpPDB;
242 fprintf(stderr, "exportcb: item_id=%d\n", item_id);
246 if ((bOk = gmx_strcasecmp("ok", set)) == 0)
248 strcpy(gmx->confout, EditText(dlg, eExConf));
253 write_gmx(x11, gmx, IDDOEXPORT);
260 eg0, egTOPOL, egCONFIN, egPARAM, eg1, eg1PROC, eg32PROC
263 static void Extract(t_dlg *dlg, int ID, char *buf)
267 et = EditText(dlg, ID);
275 ebShowH = 11, ebDPlus, ebRMPBC, ebCue, ebSkip, ebWait
278 static void BondsCB(t_x11 *x11, int dlg_mess, int item_id,
279 char *set, void *data)
281 static int ebond = -1;
282 static int ebox = -1;
283 gmx_bool bOk, bBond = FALSE;
290 ebond = gmx->man->molw->bond_type;
291 ebox = gmx->man->molw->boxtype;
301 else if (item_id <= eBNR+esbNR+1)
303 ebox = item_id-eBNR-2;
309 #define DO_NOT(b) (b) = (!(b))
314 toggle_hydrogen(x11, gmx->man->molw);
317 DO_NOT(gmx->man->bPlus);
319 fprintf(stderr, "gmx->man->bPlus=%s\n", gmx_bool_names[gmx->man->bPlus]);
323 set_box_type(x11,gmx->man->molw,ebond);
326 toggle_pbc(gmx->man);
329 DO_NOT(gmx->man->bSort);
331 fprintf(stderr, "gmx->man->bSort=%s\n", gmx_bool_names[gmx->man->bSort]);
335 sscanf(set, "%d", &nskip);
337 fprintf(stderr, "nskip: %d frames\n", nskip);
341 gmx->man->nSkip = nskip;
345 sscanf(set, "%d", &nwait);
347 fprintf(stderr, "wait: %d ms\n", nwait);
351 gmx->man->nWait = nwait;
355 fprintf(stderr, "item_id: %d, set: %s\n", item_id, set);
362 bOk = (gmx_strcasecmp("ok", set) == 0);
363 HideDlg(gmx->dlgs[edBonds]);
371 write_gmx(x11, gmx, IDTHIN);
374 write_gmx(x11, gmx, IDFAT);
377 write_gmx(x11, gmx, IDVERYFAT);
380 write_gmx(x11, gmx, IDBALLS);
383 gmx_fatal(FARGS, "Invalid bond type %d at %s, %d",
384 ebond, __FILE__, __LINE__);
392 write_gmx(x11, gmx, IDNOBOX);
395 write_gmx(x11, gmx, IDRECTBOX);
398 write_gmx(x11, gmx, IDTRIBOX);
401 write_gmx(x11, gmx, IDTOBOX);
404 gmx_fatal(FARGS, "Invalid box type %d at %s, %d",
405 ebox, __FILE__, __LINE__);
414 esFUNCT = 1, esBSHOW, esINFIL, esINDEXFIL, esLSQ, esSHOW, esPLOTFIL
417 static gmx_bool in_set(int i, int n, int set[])
420 for (j = 0; (j < n); j++)
430 typedef t_dlg *t_mmb (t_x11 *x11, t_gmx *gmx);
444 void init_dlgs(t_x11 *x11, t_gmx *gmx)
446 static t_dlginit di[] = {
447 { edExport, "export.dlg", ExportCB },
448 { edBonds, "bonds.dlg", BondsCB }
450 static t_mbinit mi[emNR] = {
451 { emQuit, quit_mb, QuitCB },
452 { emHelp, help_mb, MBCallback },
453 { emAbout, about_mb, MBCallback },
454 { emNotImplemented, ni_mb, MBCallback }
458 snew(gmx->dlgs, edNR);
459 for (i = 0; (i < asize(di)); i++)
461 gmx->dlgs[i] = ReadDlg(x11, gmx->wd->self, di[i].dlgfile,
462 x11->fg, x11->bg, di[i].dlgfile,
463 0, 0, TRUE, FALSE, di[i].cb, gmx);
466 gmx->dlgs[edFilter] = select_filter(x11, gmx);
468 snew(gmx->mboxes, emNR);
469 for (i = 0; (i < emNR); i++)
471 gmx->mboxes[i] = mi[i].mmb(x11, gmx);
476 void done_dlgs(t_gmx *gmx)
480 for (i = 0; (i < edNR); i++)
482 FreeDlg(gmx->dlgs[i]);
484 for (i = 0; (i < emNR); i++)
486 FreeDlg(gmx->mboxes[i]);
490 void edit_file(const char *fn)
496 sprintf(script, "vi %s", fn);
497 shell_comm(fn, script, 0);