2
* Grace - GRaphing, Advanced Computation and Exploration of data
4
* Home page: http://plasma-gate.weizmann.ac.il/Grace/
6
* Copyright (c) 1991-1995 Paul J Turner, Portland, OR
7
* Copyright (c) 1996-2000 Grace Development Team
9
* Maintained by Evgeny Stambulchik <fnevgeny@plasma-gate.weizmann.ac.il>
14
* This program is free software; you can redistribute it and/or modify
15
* it under the terms of the GNU General Public License as published by
16
* the Free Software Foundation; either version 2 of the License, or
17
* (at your option) any later version.
19
* This program is distributed in the hope that it will be useful,
20
* but WITHOUT ANY WARRANTY; without even the implied warranty of
21
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
* GNU General Public License for more details.
24
* You should have received a copy of the GNU General Public License
25
* along with this program; if not, write to the Free Software
26
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
30
* define regions and operate on regions
39
#include <Xm/DialogS.h>
42
#include <Xm/RowColumn.h>
43
#include <Xm/ScrolledW.h>
53
static Widget but1[2];
54
static Widget but2[2];
55
static Widget but3[3];
57
extern int regiontype; /* in regionutils.c */
59
static void do_define_region(Widget w, XtPointer client_data, XtPointer call_data);
60
static void do_clear_region(Widget w, XtPointer client_data, XtPointer call_data);
63
static Widget *define_region_item;
64
static Widget *define_type_item;
68
static Widget status_frame;
69
static Widget status_panel;
70
static Widget status_sw;
72
static Widget header_w;
75
static void do_define_region(Widget w, XtPointer client_data, XtPointer call_data)
77
int rtype = GetChoice(define_type_item);
79
nr = GetChoice(define_region_item);
80
define_region(nr, rtype);
83
void create_define_frame(void *data)
85
static Widget top, dialog;
92
top = XmCreateDialogShell(app_shell, "Define region", NULL, 0);
94
dialog = XmCreateRowColumn(top, "dialog_rc", NULL, 0);
96
define_region_item = CreatePanelChoice(dialog,
99
"0", "1", "2", "3", "4",
102
define_type_item = CreatePanelChoice(dialog,
113
"Out of Horiz. Range",
114
"Out of Vert. Range",
117
CreateSeparator(dialog);
119
CreateCommandButtons(dialog, 2, but2, label2);
120
XtAddCallback(but2[0], XmNactivateCallback, (XtCallbackProc) do_define_region, (XtPointer) NULL);
121
XtAddCallback(but2[1], XmNactivateCallback, (XtCallbackProc) destroy_dialog, (XtPointer) top);
129
static Widget *clear_region_item;
131
static void do_clear_region(Widget w, XtPointer client_data, XtPointer call_data)
136
if (GetChoice(clear_region_item) == MAXREGION) {
137
for (i = 0; i < MAXREGION; i++) {
141
kill_region(GetChoice(clear_region_item));
147
void create_clear_frame(void *data)
149
static Widget top, dialog;
154
label1[0] = "Accept";
156
top = XmCreateDialogShell(app_shell, "Clear region", NULL, 0);
158
dialog = XmCreateRowColumn(top, "dialog_rc", NULL, 0);
160
clear_region_item = CreatePanelChoice(dialog,
163
"0", "1", "2", "3", "4", "All",
166
CreateSeparator(dialog);
168
CreateCommandButtons(dialog, 2, but1, label1);
169
XtAddCallback(but1[0], XmNactivateCallback, (XtCallbackProc) do_clear_region, (XtPointer) NULL);
170
XtAddCallback(but1[1], XmNactivateCallback, (XtCallbackProc) destroy_dialog, (XtPointer) top);
178
Widget arealab, perimlab;
180
void create_area_frame(void *data)
182
static Widget top, dialog;
189
label3[1] = "Perimeter";
191
top = XmCreateDialogShell(app_shell, "Area/perimeter", NULL, 0);
193
dialog = XmCreateRowColumn(top, "dialog_rc", NULL, 0);
195
str = XmStringCreateLocalized("[ Area ]");
196
arealab = XtVaCreateManagedWidget("label Area", xmLabelWidgetClass, dialog,
200
str = XmStringCreateLocalized("[ Perim ]");
201
perimlab = XtVaCreateManagedWidget("label Perim", xmLabelWidgetClass, dialog,
206
CreateSeparator(dialog);
208
CreateCommandButtons(dialog, 3, but3, label3);
209
XtAddCallback(but3[0], XmNactivateCallback, (XtCallbackProc) do_select_area, (XtPointer) NULL);
210
XtAddCallback(but3[1], XmNactivateCallback, (XtCallbackProc) do_select_peri, (XtPointer) NULL);
211
XtAddCallback(but3[2], XmNactivateCallback, (XtCallbackProc) destroy_dialog, (XtPointer) top);
219
static Widget *reporton_region_item;
220
static Widget *reporton_type_item;
222
static void do_reporton_region(Widget w, XtPointer client_data, XtPointer call_data)
224
int regno = (int) GetChoice(reporton_region_item);
225
int type = (int) GetChoice(reporton_type_item);
227
reporton_region(get_cg(), regno, type);
231
void create_reporton_frame(void *data)
233
static Widget top, dialog;
238
label1[0] = "Accept";
240
top = XmCreateDialogShell(app_shell, "Report on sets in region", NULL, 0);
242
dialog = XmCreateRowColumn(top, "dialog_rc", NULL, 0);
244
reporton_region_item = CreatePanelChoice(dialog,
245
"Report on sets in region:",
247
"0", "1", "2", "3", "4", "Inside world", "Outside world",
250
reporton_type_item = CreatePanelChoice(dialog,
256
CreateSeparator(dialog);
258
CreateCommandButtons(dialog, 2, but1, label1);
259
XtAddCallback(but1[0], XmNactivateCallback, (XtCallbackProc) do_reporton_region, (XtPointer) NULL);
260
XtAddCallback(but1[1], XmNactivateCallback, (XtCallbackProc) destroy_dialog, (XtPointer) top);
268
static void set_status_label(Widget w, char *buf)
272
ls = XmStringCreateLocalized(buf);
273
XtSetArg(al, XmNlabelString, ls);
274
XtSetValues(w, &al, 1);
279
void clear_status(void)
282
for (i = 0; i < MAXREGION; i++) {
283
set_status_label(labx[i], " ");
287
void update_status_popup(Widget w, XtPointer client_data, XtPointer call_data)
292
sprintf(buf, " Region # Active Type");
293
set_status_label(header_w, buf);
295
for (rno = 0; rno < MAXREGION; rno++) {
296
sprintf(buf, " %2d %3s %6s", rno, on_or_off(rg[rno].active),
297
region_types(rg[rno].type, 0));
298
set_status_label(labx[rno], buf);
305
void define_status_popup(void *data)
309
if (status_frame == NULL) {
311
Widget wbut, rc, rc3, fr2;
313
status_frame = XmCreateDialogShell(app_shell, "Status", NULL, 0);
314
handle_close(status_frame);
316
status_panel = XmCreateForm(status_frame, "form", NULL, 0);
318
status_sw = XtVaCreateManagedWidget("sw",
319
xmScrolledWindowWidgetClass, status_panel,
320
XmNscrollingPolicy, XmAUTOMATIC,
324
rc3 = XmCreateRowColumn(status_sw, "rc3", NULL, 0);
325
header_w = XtVaCreateManagedWidget("header", xmLabelWidgetClass, rc3,
326
XmNalignment, XmALIGNMENT_BEGINNING,
327
XmNrecomputeSize, True,
329
SetFixedFont(header_w);
330
labx = (Widget *)xmalloc( MAXREGION*sizeof(Widget) );
331
for (i = 0; i < MAXREGION; i++) {
332
labx[i] = XtVaCreateManagedWidget("labx", xmLabelWidgetClass, rc3,
333
XmNalignment, XmALIGNMENT_BEGINNING,
334
XmNrecomputeSize, True,
336
SetFixedFont(labx[i]);
339
XtVaSetValues(status_sw, XmNworkWindow, rc3, NULL);
341
fr2 = CreateFrame(status_panel, NULL);
342
rc = XmCreateRowColumn(fr2, "rc", NULL, 0);
343
XtVaSetValues(rc, XmNorientation, XmHORIZONTAL, NULL);
345
wbut = XtVaCreateManagedWidget("Close", xmPushButtonWidgetClass, rc,
347
XtAddCallback(wbut, XmNactivateCallback, (XtCallbackProc) destroy_dialog, status_frame);
349
wbut = XtVaCreateManagedWidget("Update", xmPushButtonWidgetClass, rc,
351
XtAddCallback(wbut, XmNactivateCallback, (XtCallbackProc) update_status_popup, NULL);
355
XtVaSetValues(status_sw,
356
XmNtopAttachment, XmATTACH_FORM,
357
XmNleftAttachment, XmATTACH_FORM,
358
XmNrightAttachment, XmATTACH_FORM,
359
XmNbottomAttachment, XmATTACH_WIDGET,
360
XmNbottomWidget, fr2,
363
XmNleftAttachment, XmATTACH_FORM,
364
XmNrightAttachment, XmATTACH_FORM,
365
XmNbottomAttachment, XmATTACH_FORM,
367
ManageChild(status_panel);
370
RaiseWindow(status_frame);
371
update_status_popup(NULL, NULL, NULL);
375
void define_region(int nr, int rtype)
380
regiontype = REGION_POLYI;
384
regiontype = REGION_POLYO;
388
regiontype = REGION_ABOVE;
389
set_action(DO_NOTHING);
390
set_action(DEF_REGION1ST);
393
regiontype = REGION_BELOW;
394
set_action(DO_NOTHING);
395
set_action(DEF_REGION1ST);
398
regiontype = REGION_TOLEFT;
399
set_action(DO_NOTHING);
400
set_action(DEF_REGION1ST);
403
regiontype = REGION_TORIGHT;
404
set_action(DO_NOTHING);
405
set_action(DEF_REGION1ST);
408
regiontype= REGION_HORIZI;
409
set_action(DO_NOTHING);
410
set_action(DEF_REGION1ST);
413
regiontype= REGION_VERTI;
414
set_action(DO_NOTHING);
415
set_action(DEF_REGION1ST);
418
regiontype= REGION_HORIZO;
419
set_action(DO_NOTHING);
420
set_action(DEF_REGION1ST);
423
regiontype= REGION_VERTO;
424
set_action(DO_NOTHING);
425
set_action(DEF_REGION1ST);