~maddevelopers/mg5amcnlo/2.9.4

« back to all changes in this revision

Viewing changes to vendor/StdHEP/src/display/panelPara.c

pass to v2.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*******************************************************************************
 
2
*                                                                              *
 
3
* panelPara.c -- Nirvana Phase-Space Event Display, in the eta-Pt space        *
 
4
*                                                                              *
 
5
* Copyright (c) 1991 Universities Research Association, Inc.                   *
 
6
* All rights reserved.                                                         *
 
7
*                                                                              *
 
8
* This material resulted from work developed under a Government Contract and   *
 
9
* is subject to the following license:  The Government retains a paid-up,      *
 
10
* nonexclusive, irrevocable worldwide license to reproduce, prepare derivative *
 
11
* works, perform publicly and display publicly by or for the Government,       *
 
12
* including the right to distribute to other Government contractors.  Neither  *
 
13
* the United States nor the United States Department of Energy, nor any of     *
 
14
* their employees, makes any warrenty, express or implied, or assumes any      *
 
15
* legal liability or responsibility for the accuracy, completeness, or         *
 
16
* usefulness of any information, apparatus, product, or process disclosed, or  *
 
17
* represents that its use would not infringe privately owned rights.           *
 
18
*                                                                              *
 
19
* Fermilab Nirvana GUI Library                                                 *
 
20
* February 1994                                                                *
 
21
*                                                                              *
 
22
* Clone from panel.c ( by M. Edel), by P. Lebrun.                              *
 
23
*                                                                              *
 
24
*******************************************************************************/
 
25
static char SCCSID[] = "@(#)panel.c     1.2     4/10/92";
 
26
#include <stdio.h>
 
27
#include <math.h>
 
28
#include <stdarg.h>
 
29
#include <sys/param.h>
 
30
#include <limits.h>
 
31
#include <X11/Intrinsic.h>
 
32
#include <X11/Shell.h>
 
33
#include <X11/Xatom.h>
 
34
#include <Xm/Xm.h>
 
35
#include <Xm/MainW.h>
 
36
#include <Xm/Form.h>
 
37
#include <Xm/Frame.h>
 
38
#include <Xm/ArrowB.h>
 
39
#include <Xm/Text.h>
 
40
#include <Xm/PushBG.h>
 
41
#include <Xm/Scale.h>
 
42
#include <Xm/Label.h>
 
43
#include <Xm/ToggleBG.h>
 
44
#include <Xm/RowColumn.h>
 
45
#include <Xm/DrawingA.h>
 
46
#include "spin/Spin.h"
 
47
#include "util/DialogF.h"
 
48
#include "phase.h"
 
49
#include "space.h"
 
50
#include "phaseP.h"
 
51
#include "panelSpace.h"
 
52
#include "menu.h"
 
53
#include "pick.h"
 
54
#include "rotation.h"
 
55
 
 
56
#define INITIAL_RAPTOPT_RAT 1.0         /* The initial scale factor for the 
 
57
                                                conversion momentum to space */
 
58
#define INITIAL_ROT_INCR 10.            /* Key and button rotation (degrees) */
 
59
 
 
60
static Widget createContents(Widget parent, ParaWindow *window,
 
61
                             int hasEventBar, char *eventBarText);
 
62
static void closeCB(Widget w, ParaWindow *window, caddr_t call_data);
 
63
static void stableCB(Widget w, ParaWindow *window, caddr_t call_data);
 
64
static void unstableCB(Widget w, ParaWindow *window, caddr_t call_data);
 
65
static void chargedCB(Widget w, ParaWindow *window, caddr_t call_data);
 
66
static void neutralCB(Widget w, ParaWindow *window, caddr_t call_data);
 
67
static void electronsCB(Widget w, ParaWindow *window, caddr_t call_data);
 
68
static void muonsCB(Widget w, ParaWindow *window, caddr_t call_data);
 
69
static void neutrinosCB(Widget w, ParaWindow *window, caddr_t call_data);
 
70
static void gammasCB(Widget w, ParaWindow *window, caddr_t call_data);
 
71
static void quarksCB(Widget w, ParaWindow *window, caddr_t call_data);
 
72
static void hadronsCB(Widget w, ParaWindow *window, caddr_t call_data);
 
73
static Widget createSpaceSlider(Widget *scaleret, Widget *valueret, 
 
74
                         Widget parent, Widget attached,
 
75
                         char *namef, char *namel,
 
76
                         int initval, ParaWindow *window, 
 
77
                          void (*gensliderCB) ());
 
78
static void wzCB(Widget w, ParaWindow *window, caddr_t call_data);
 
79
static void zTransCB(Widget w, ParaWindow *window,caddr_t call_data);
 
80
static void rapToPtCB(Widget w, ParaWindow *window,caddr_t call_data);
 
81
static void viewRotXPosCB(Widget w, ParaWindow *window, caddr_t call_data); 
 
82
static void viewRotYPosCB(Widget w, ParaWindow *window, caddr_t call_data); 
 
83
static void viewRotZPosCB(Widget w, ParaWindow *window, caddr_t call_data); 
 
84
static void viewRotXNegCB(Widget w, ParaWindow *window, caddr_t call_data); 
 
85
static void viewRotYNegCB(Widget w, ParaWindow *window, caddr_t call_data); 
 
86
static void viewRotZNegCB(Widget w, ParaWindow *window, caddr_t call_data); 
 
87
static void coordRotXPosCB(Widget w, ParaWindow *window, caddr_t call_data); 
 
88
static void coordRotYPosCB(Widget w, ParaWindow *window, caddr_t call_data); 
 
89
static void coordRotZPosCB(Widget w, ParaWindow *window, caddr_t call_data); 
 
90
static void coordRotXNegCB(Widget w, ParaWindow *window, caddr_t call_data); 
 
91
static void coordRotYNegCB(Widget w, ParaWindow *window, caddr_t call_data); 
 
92
static void coordRotZNegCB(Widget w, ParaWindow *window, caddr_t call_data); 
 
93
static void scaleUpCB(Widget w, ParaWindow *window, caddr_t call_data); 
 
94
static void scaleDownCB(Widget w, ParaWindow *window, caddr_t call_data); 
 
95
static void resetRotationCB(Widget w, ParaWindow *window, caddr_t call_data); 
 
96
static void scaleExposeCB(Widget w, ParaWindow *window, caddr_t call_data);
 
97
static void resizeCB(Widget w, ParaWindow *window, caddr_t call_data);
 
98
static void redisplayCB(Widget w, ParaWindow *window, caddr_t call_data);
 
99
static void spinSelectCB(Widget w, ParaWindow *window, SpinCallbackStruct *cb);
 
100
static void nextEvtCB(Widget w, ParaWindow *window,caddr_t call_data);
 
101
static void previousEvtCB(Widget w, ParaWindow *window,caddr_t call_data);
 
102
 
 
103
/*
 
104
** Create a new event display window
 
105
*/
 
106
ParaWindow *CreatePanelPa(Display *display, int setsEventNum,
 
107
    int canOpenFiles, int canExit, char *windowTitle, char *eventSelectorText)
 
108
{
 
109
    Widget appShell, main, menuBar, form;
 
110
    ParaWindow *window;
 
111
    static Atom wmpAtom, dwAtom = NULL;
 
112
    Arg al[20];
 
113
    int type, ac;
 
114
    XGCValues values;
 
115
 
 
116
    /* Allocate some memory for the new window data structure */
 
117
    window = (ParaWindow *)XtMalloc(sizeof(ParaWindow));
 
118
    
 
119
    /* Create an toplevel shell to hold the window */
 
120
    ac = 0;
 
121
    XtSetArg(al[ac], XmNtitle, windowTitle); ac++;
 
122
    XtSetArg(al[ac], XmNdeleteResponse, XmDO_NOTHING); ac++;
 
123
    XtSetArg(al[ac], XmNiconName, windowTitle); ac++;
 
124
    /* Keep the phase name here, to same valid XDefaults.. */
 
125
    appShell = XtAppCreateShell ("phase", "Space",
 
126
                applicationShellWidgetClass, display, al, ac);
 
127
            
 
128
    /*
 
129
    ** create a main window holding a menu bar and a form with the rest of
 
130
    ** the window contents.
 
131
    */
 
132
    main = XmCreateMainWindow(appShell, "main", NULL, 0);
 
133
    XtManageChild(main);
 
134
    type = STDHEP_PARA;
 
135
    menuBar = CreateMenuBar(main, (StdHepWindow *) window,
 
136
                                   canOpenFiles, canExit, type);
 
137
    XtManageChild(menuBar);
 
138
    form = createContents(main, window, setsEventNum, eventSelectorText);
 
139
    XtManageChild(form);
 
140
 
 
141
    /* add the window to the global window list */
 
142
    AddToWindowList((StdHepWindow *) window);
 
143
    
 
144
    /* realize all of the widgets in the new window */
 
145
    XtRealizeWidget(appShell);
 
146
 
 
147
    /* set up closeCB to be called when the user selects close from the
 
148
       window menu.  The close menu item usually activates f.kill which
 
149
       sends a WM_DELETE_WINDOW protocol request for the window. */
 
150
    if (dwAtom == NULL) {
 
151
        wmpAtom = XmInternAtom(display, "WM_PROTOCOLS", TRUE);
 
152
        dwAtom = XmInternAtom(display, "WM_DELETE_WINDOW", TRUE);
 
153
    }
 
154
    XmAddProtocolCallback(appShell, wmpAtom, dwAtom, closeCB, window);
 
155
 
 
156
    /* initialize window structure, including a read-only graphics contexts
 
157
       for drawing in scale area and highlighting in spin widget */
 
158
    window->shell = appShell;
 
159
    window->selectedTrack = NO_TRACK;
 
160
    window->trackWindowShell = NULL;
 
161
    window->btnRotationPanel = NULL;
 
162
    window->absRotationPanel = NULL;
 
163
    window->buttonRotateDegrees = INITIAL_ROT_INCR;
 
164
    window->event.nParticles = 0;
 
165
    window->event.particles = NULL;
 
166
    window->colorcode.nParticles = 0;
 
167
    window->colorcode.particles = NULL;
 
168
    ac = 0;
 
169
    XtSetArg(al[ac], XmNbackground, &values.background); ac++;
 
170
    XtSetArg(al[ac], XmNforeground, &values.foreground); ac++;
 
171
    XtGetValues(window->scaleArea, al, ac);
 
172
    window->scaleGC =
 
173
        XtGetGC(window->scaleArea, GCForeground|GCBackground, &values);
 
174
    window->highlightGC = SpinCopyGC(window->spin);
 
175
    XSetLineAttributes(display, window->highlightGC, 5, LineSolid,
 
176
                       CapRound, JoinMiter);
 
177
    return window;
 
178
}
 
179
 
 
180
static void closeCB (Widget w, ParaWindow *window, caddr_t call_data) 
 
181
{
 
182
    CloseWindow((StdHepWindow *) window);
 
183
}
 
184
 
 
185
static Widget createContents(Widget parent, ParaWindow *window,
 
186
                             int hasEventBar, char *eventBarText)
 
187
{
 
188
    Arg         args[50];
 
189
    int         ac;
 
190
    XmString    s1, s2;
 
191
    char ctmp[10];
 
192
    Widget      form, displayMode, stability, particleType, rotation, stats;
 
193
    Widget      formt1, allSliders;
 
194
    Widget      controls, trackInfoFrame, trackInfo;
 
195
    Widget      scaleFrame, scaleRC, scaleLabel, scaleArea;
 
196
    Widget      stabilityLabel, particleTypeLabel;
 
197
    Widget      eventCtrlFrame, eventCtrlForm, eventNumLabel, upArrow;
 
198
    Widget      eventNumText, downArrow, eventCtrlText;
 
199
    Widget      widget, spin;
 
200
    Pixel       foreground, background;
 
201
    Pixmap      pm;
 
202
 
 
203
    /* Create the form onto which everything goes */
 
204
    ac = 0;
 
205
    XtSetArg(args[ac], XmNmarginHeight, 0); ac++;
 
206
    form = XmCreateForm(parent, "form", args, ac);
 
207
    XtManageChild(form);
 
208
  
 
209
    if (hasEventBar) {
 
210
        ac = 0;
 
211
        XtSetArg(args[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
 
212
        XtSetArg(args[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
 
213
        eventCtrlFrame = XmCreateFrame(form, "eventCtrlFrame", args, ac);
 
214
        XtManageChild(eventCtrlFrame);
 
215
        
 
216
        ac = 0;
 
217
        eventCtrlForm = XmCreateForm(eventCtrlFrame, "eventCtrlForm", args, ac);
 
218
        XtManageChild(eventCtrlForm);
 
219
        
 
220
        ac = 0;
 
221
        XtSetArg(args[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
 
222
        XtSetArg(args[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
 
223
        XtSetArg(args[ac], XmNlabelString, (s1=MKSTRING("Event #"))); ac++;
 
224
        eventNumLabel = (Widget) XmCreateLabelGadget(eventCtrlForm, "eventNumLabel",
 
225
                                            args, ac);
 
226
        XmStringFree(s1);
 
227
        XtManageChild(eventNumLabel);
 
228
        
 
229
        ac = 0;
 
230
        XtSetArg(args[ac], XmNarrowDirection, XmARROW_UP); ac++;
 
231
        XtSetArg(args[ac], XmNleftAttachment, XmATTACH_WIDGET); ac++;
 
232
        XtSetArg(args[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
 
233
        XtSetArg(args[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
 
234
        XtSetArg(args[ac], XmNleftWidget, eventNumLabel); ac++;
 
235
        upArrow = XmCreateArrowButton(eventCtrlForm, "upArrow", args, ac);
 
236
        XtAddCallback(upArrow, XmNactivateCallback,
 
237
                      (XtCallbackProc)  nextEvtCB, window); 
 
238
        XtManageChild(upArrow);
 
239
        
 
240
        ac = 0;
 
241
        
 
242
        sprintf(ctmp,"  %d  ", ac);
 
243
        XtSetArg(args[ac], XmNlabelString, (s1=MKSTRING(ctmp))); ac++;
 
244
        XtSetArg(args[ac], XmNcolumns, 7); ac++;
 
245
        XtSetArg(args[ac], XmNleftAttachment, XmATTACH_WIDGET); ac++;
 
246
        XtSetArg(args[ac], XmNleftWidget, upArrow); ac++;
 
247
        eventNumText = (Widget) XmCreateLabelGadget(eventCtrlForm, "eventNumText",
 
248
                                            args, ac);
 
249
/*      eventNumText = XmCreateText(eventCtrlForm, "eventNumText", args, ac); */
 
250
        XtManageChild(eventNumText);
 
251
        
 
252
        ac = 0;
 
253
        XtSetArg(args[ac], XmNarrowDirection, XmARROW_DOWN); ac++;
 
254
        XtSetArg(args[ac], XmNleftAttachment, XmATTACH_WIDGET); ac++;
 
255
        XtSetArg(args[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
 
256
        XtSetArg(args[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
 
257
        XtSetArg(args[ac], XmNleftWidget, eventNumText); ac++;
 
258
        downArrow = XmCreateArrowButton(eventCtrlForm, "downArrow", args, ac);
 
259
        XtAddCallback(downArrow, XmNactivateCallback,
 
260
                       (XtCallbackProc)  previousEvtCB, window); 
 
261
        XtManageChild(downArrow);
 
262
        
 
263
        ac = 0;
 
264
        XtSetArg(args[ac], XmNlabelString, (s1=MKSTRING(eventBarText))); ac++;
 
265
        XtSetArg(args[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
 
266
        XtSetArg(args[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
 
267
        XtSetArg(args[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
 
268
        eventCtrlText = (Widget) XmCreateLabelGadget(eventCtrlForm, "eventCtrlText",
 
269
                                            args, ac);
 
270
        XmStringFree(s1);
 
271
        XtManageChild(eventCtrlText);
 
272
    }
 
273
    
 
274
    /* Create a Form for the controls along the left edge of window */
 
275
    ac = 0;
 
276
    if (hasEventBar) {
 
277
        XtSetArg(args[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
 
278
        XtSetArg(args[ac], XmNtopWidget, eventCtrlFrame); ac++;
 
279
    } else {
 
280
        XtSetArg(args[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
 
281
    }
 
282
    controls = XmCreateForm(form, "controls", args, ac);
 
283
    XtManageChild(controls);
 
284
     
 
285
    ac = 0;
 
286
    XtSetArg(args[ac], XmNborderWidth, (Dimension)0); ac++;
 
287
    XtSetArg(args[ac], XmNpacking, XmPACK_COLUMN); ac++;
 
288
    XtSetArg(args[ac], XmNspacing, 0); ac++;
 
289
    XtSetArg(args[ac], XmNnumColumns, (short)2); ac++;
 
290
    stability = XmCreateRowColumn(controls, "stability", args, ac);
 
291
    XtManageChild(stability);
 
292
 
 
293
    ac = 0;
 
294
    XtSetArg(args[ac], XmNlabelString, (s1=MKSTRING("Particle Types"))); ac++;
 
295
    XtSetArg(args[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
 
296
    XtSetArg(args[ac], XmNtopWidget, stability); ac++;
 
297
    particleTypeLabel = (Widget) XmCreateLabelGadget(controls, "particleTypeLabel",
 
298
                                            args, ac);
 
299
    XmStringFree(s1);
 
300
    XtManageChild(particleTypeLabel);
 
301
 
 
302
    ac = 0;
 
303
    XtSetArg(args[ac], XmNborderWidth, (Dimension)0); ac++;
 
304
    XtSetArg(args[ac], XmNpacking, XmPACK_COLUMN); ac++;
 
305
    XtSetArg(args[ac], XmNspacing, 0); ac++;
 
306
    XtSetArg(args[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
 
307
    XtSetArg(args[ac], XmNnumColumns, (short)2); ac++;
 
308
    XtSetArg(args[ac], XmNtopWidget, particleTypeLabel); ac++;
 
309
    particleType = XmCreateRowColumn(controls, "particleType", args, ac);
 
310
    XtManageChild(particleType);
 
311
 
 
312
 
 
313
    ac = 0;
 
314
    XtSetArg(args[ac], XmNhighlightThickness, 0); ac++;
 
315
    XtSetArg(args[ac], XmNpacking, XmPACK_COLUMN); ac++;
 
316
    XtSetArg(args[ac], XmNspacing, 0); ac++;
 
317
    XtSetArg(args[ac], XmNorientation, XmHORIZONTAL); ac++;
 
318
    if (hasEventBar) {
 
319
        XtSetArg(args[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
 
320
        XtSetArg(args[ac], XmNtopWidget, eventCtrlFrame); ac++;
 
321
    } else {
 
322
        XtSetArg(args[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
 
323
    }
 
324
    XtSetArg(args[ac], XmNleftAttachment, XmATTACH_WIDGET); ac++;
 
325
    XtSetArg(args[ac], XmNleftWidget, controls); ac++;
 
326
    XtSetArg(args[ac], XmNtopOffset, (int)2); ac++;
 
327
    XtSetArg(args[ac], XmNleftOffset, (int)0); ac++;
 
328
    stats = XmCreateRowColumn(form, "stats", args, ac);
 
329
    XtManageChild(stats);
 
330
 
 
331
#define TOGGLE_BTN(parent, label, name, cb, set) \
 
332
    ac = 0; \
 
333
    XtSetArg(args[ac], XmNlabelString, (s1=MKSTRING(label))); ac++; \
 
334
    XtSetArg(args[ac], XmNset, set); ac++; \
 
335
    XtSetArg(args[ac], XmNmarginHeight, 0); ac++; \
 
336
    widget = XmCreateToggleButtonGadget(parent, name, args, ac); \
 
337
    XmStringFree(s1); \
 
338
    XtAddCallback(widget, XmNvalueChangedCallback, \
 
339
                 (XtCallbackProc)  cb, window); \
 
340
    XtManageChild(widget); \
 
341
 
 
342
    TOGGLE_BTN(stability, "Stable", "stable", stableCB, True);
 
343
    TOGGLE_BTN(stability, "Unstable", "unstable", unstableCB, True);
 
344
    TOGGLE_BTN(particleType, "Charged", "charged", chargedCB, True);
 
345
    TOGGLE_BTN(particleType, "Neutral", "neutral", neutralCB, True);
 
346
    TOGGLE_BTN(particleType, "Electrons", "electrons", electronsCB, True);
 
347
    TOGGLE_BTN(particleType, "Muons", "muons", muonsCB, True);
 
348
    TOGGLE_BTN(particleType, "Neutrinos", "neutrinos", neutrinosCB, True);
 
349
    TOGGLE_BTN(particleType, "Gammas", "gammas", gammasCB, True);
 
350
    TOGGLE_BTN(particleType, "Quarks/Gluons", "quarks", quarksCB, True);
 
351
    TOGGLE_BTN(particleType,"Hadrons", "hadrons", hadronsCB, True);
 
352
    TOGGLE_BTN(particleType,"W/Z", "wz", wzCB, True);
 
353
    
 
354
    /* Do now the slider.. X, Y ,Z translation first. */
 
355
    ac = 0;
 
356
    XtSetArg(args[ac], XmNborderWidth, (Dimension)0); ac++;
 
357
    XtSetArg(args[ac], XmNpacking, XmPACK_COLUMN); ac++;
 
358
    XtSetArg(args[ac], XmNspacing, 0); ac++;
 
359
    XtSetArg(args[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
 
360
/*    XtSetArg(args[ac], XmNrightAttachment, XmATTACH_WIDGET); ac++; */
 
361
    XtSetArg(args[ac], XmNnumColumns, (short)1); ac++;
 
362
    XtSetArg(args[ac], XmNtopWidget, particleType); ac++;
 
363
/*    XtSetArg(args[ac], XmNrightWidget, particleType); ac++; */
 
364
    allSliders = XmCreateRowColumn(controls, "allSliders", args, ac);
 
365
    XtManageChild(allSliders);
 
366
     
 
367
                                 
 
368
    ac = 0;
 
369
    XtSetArg(args[ac], XmNpacking, XmPACK_COLUMN); ac++;
 
370
    XtSetArg(args[ac], XmNadjustLast, False); ac++;    
 
371
    XtSetArg(args[ac], XmNspacing, 0); ac++;
 
372
    XtSetArg(args[ac], XmNnumColumns, (short)5); ac++;
 
373
    XtSetArg(args[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
 
374
    XtSetArg(args[ac], XmNtopWidget, allSliders); ac++;
 
375
    rotation = XmCreateRowColumn(controls, "rotation", args, ac);
 
376
    XtManageChild(rotation);
 
377
 
 
378
     /* Get foreground an background colors for pixmap buttons */
 
379
    ac = 0;
 
380
    XtSetArg(args[ac], XmNforeground, &foreground); ac++;
 
381
    XtSetArg(args[ac], XmNbackground, &background); ac++;
 
382
    XtGetValues(controls, args, ac);
 
383
 
 
384
#define ROTATE_BTN(pmName, widgetName, cb) \
 
385
    pm = XmGetPixmap(XtScreen(parent), pmName, foreground, background); \
 
386
    ac = 0; \
 
387
    XtSetArg(args[ac], XmNlabelType, XmPIXMAP); ac++; \
 
388
    XtSetArg(args[ac], XmNlabelPixmap, pm); ac++; \
 
389
    widget = XmCreatePushButtonGadget(rotation, widgetName, args, ac); \
 
390
    XtAddCallback(widget, XmNactivateCallback, \
 
391
                  (XtCallbackProc)  cb, window); \
 
392
    XtManageChild(widget);
 
393
    
 
394
    ROTATE_BTN("viewRotXPos", "viewRotXPos", viewRotXPosCB) 
 
395
    ROTATE_BTN("viewRotYPos", "viewRotYPos", viewRotYPosCB)
 
396
    ROTATE_BTN("viewRotZPos", "viewRotZPos", viewRotZPosCB)
 
397
    ROTATE_BTN("viewRotXNeg", "viewRotXNeg", viewRotXNegCB)
 
398
    ROTATE_BTN("viewRotYNeg", "viewRotYNeg", viewRotYNegCB)
 
399
    ROTATE_BTN("viewRotZNeg", "viewRotZNeg", viewRotZNegCB)
 
400
    ROTATE_BTN("coordRotXPos", "coordRotXPos", coordRotXPosCB)
 
401
    ROTATE_BTN("coordRotYPos", "coordRotYPos", coordRotYPosCB)
 
402
    ROTATE_BTN("coordRotZPos", "coordRotZPos", coordRotZPosCB)
 
403
    ROTATE_BTN("coordRotXNeg", "coordRotXNeg", coordRotXNegCB)
 
404
    ROTATE_BTN("coordRotYNeg", "coordRotYNeg", coordRotYNegCB)
 
405
    ROTATE_BTN("coordRotZNeg", "coordRotZNeg", coordRotZNegCB)
 
406
    ROTATE_BTN("scaleUp", "scaleUp", scaleUpCB)
 
407
    ROTATE_BTN("scaleDown", "scaleDown", scaleDownCB)
 
408
    ROTATE_BTN("resetRotation", "resetRotation", resetRotationCB)
 
409
 
 
410
    ac = 0;
 
411
    XtSetArg(args[ac], XmNshadowType, XmSHADOW_IN); ac++;
 
412
    XtSetArg(args[ac], XmNshadowThickness, 1); ac++;
 
413
    scaleFrame = XmCreateFrame(stats, "scaleFrame", args, ac);
 
414
    XtManageChild(scaleFrame);
 
415
    trackInfoFrame = XmCreateFrame(stats, "trackInfoFrame", args, ac);
 
416
    XtManageChild(trackInfoFrame);
 
417
    
 
418
    ac = 0;
 
419
    XtSetArg(args[ac], XmNpacking, XmPACK_COLUMN); ac++;
 
420
    XtSetArg(args[ac], XmNentryAlignment, XmALIGNMENT_CENTER); ac++;
 
421
    XtSetArg(args[ac], XmNspacing, 0); ac++;
 
422
    scaleRC = XmCreateRowColumn(scaleFrame, "scaleRC", args, ac);
 
423
    XtManageChild(scaleRC);
 
424
 
 
425
    ac = 0;
 
426
    scaleArea = XmCreateDrawingArea(scaleRC, "scaleArea", args, ac);
 
427
    XtAddCallback(scaleArea, XmNexposeCallback,
 
428
                  (XtCallbackProc)  scaleExposeCB, window);
 
429
    XtManageChild(scaleArea);
 
430
    
 
431
    ac = 0;
 
432
    XtSetArg(args[ac], XmNlabelString, (s1=MKSTRING("x"))); ac++;
 
433
    XtSetArg(args[ac], XmNmarginHeight, 0); ac++;
 
434
    scaleLabel = (Widget) XmCreateLabelGadget(scaleRC, "scaleLabel", args, ac);
 
435
    XmStringFree(s1);
 
436
    XtManageChild(scaleLabel);
 
437
    
 
438
    ac = 0;
 
439
    XtSetArg(args[ac], XmNalignment, XmALIGNMENT_BEGINNING); ac++;
 
440
    XtSetArg(args[ac], XmNrecomputeSize, False); ac++;
 
441
    XtSetArg(args[ac], XmNlabelString, (s1=MKSTRING(
 
442
     "00000 tracks, 00000 are stable\nx\nTrack of max. xxxxx is a(n) xxxx"))); ac++;
 
443
    trackInfo = (Widget) XmCreateLabelGadget(trackInfoFrame, "trackInfo", args, ac);
 
444
    XmStringFree(s1);
 
445
    XtManageChild(trackInfo);
 
446
    
 
447
    ac = 0;
 
448
    XtSetArg(args[ac], XmNshowAxes, True); ac++;
 
449
    XtSetArg(args[ac], XmNperspectiveOn, True); ac++;
 
450
    XtSetArg(args[ac], XmNdoubleBuffer, False); ac++;
 
451
    XtSetArg(args[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
 
452
    XtSetArg(args[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
 
453
    XtSetArg(args[ac], XmNleftAttachment, XmATTACH_WIDGET); ac++;
 
454
    XtSetArg(args[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
 
455
    XtSetArg(args[ac], XmNleftWidget, controls); ac++;
 
456
    XtSetArg(args[ac], XmNtopWidget, stats); ac++;
 
457
    XtSetArg(args[ac], XmNtopOffset, (int)0); ac++;
 
458
    XtSetArg(args[ac], XmNbottomOffset, (int)0); ac++;
 
459
    XtSetArg(args[ac], XmNleftOffset, (int)0); ac++;
 
460
    XtSetArg(args[ac], XmNrightOffset, (int)0); ac++;
 
461
    spin = XtCreateManagedWidget("spin", spinWidgetClass, form, args, ac);
 
462
    XtAddCallback(spin, XmNresizeCallback,
 
463
                   (XtCallbackProc)  resizeCB, window);
 
464
    XtAddCallback(spin, XmNredisplayCallback, 
 
465
                    (XtCallbackProc) redisplayCB, window);
 
466
    XtAddCallback(spin, XmNbtn2Callback,
 
467
                    (XtCallbackProc) spinSelectCB, window);
 
468
 
 
469
/* Place now the Sliders, right attached to the spin widget */ 
 
470
 
 
471
    formt1 = createSpaceSlider(&window->zTranslSliderScale, 
 
472
                                &window->zTranslSliderValue, 
 
473
                                allSliders, spin,
 
474
                                "scaleZ", "Eta Translation = 999.00000", 
 
475
                                (SLIDER_MAX/2), window, zTransCB);  
 
476
    formt1 = createSpaceSlider(&window->rapToPtSliderScale, 
 
477
                                &window->rapToPtSliderValue, 
 
478
                                allSliders, spin,
 
479
                                "momtospace",
 
480
                                 "Eta to P(GeV) = 999.00000       ", 
 
481
                               (SLIDER_MAX/2), window, rapToPtCB);  
 
482
/* This last string is in fact constraining the appearance of the widget */
 
483
    window->spin = spin;
 
484
    window->eventNumText = eventNumText;
 
485
    window->eventSelectorLabel = eventCtrlText;
 
486
    window->statsLabel = trackInfo;
 
487
    window->scaleArea = scaleArea;
 
488
    window->scaleLabel = scaleLabel;
 
489
    
 
490
    window->stable = True;
 
491
    window->unstable = True;
 
492
    window->charged = True;
 
493
    window->neutral = True;
 
494
    window->electrons = True;
 
495
    window->muons = True;
 
496
    window->gammas = True;
 
497
    window->neutrinos = True;
 
498
    window->quarks = True;
 
499
    window->hadrons = True;
 
500
    window->wz = True;
 
501
    
 
502
    return(form);
 
503
}
 
504
 
 
505
static Widget createSpaceSlider(Widget *scaleret, Widget *valueret, 
 
506
                         Widget parent, Widget attached,
 
507
                         char *namef, char *namel,
 
508
                         int initval, ParaWindow *window, 
 
509
                          void (*gensliderCB) ())
 
510
{
 
511
    Widget bulletin, scale, name, value;
 
512
    int i;
 
513
    Arg         args[20];
 
514
    int         ac;
 
515
    XmString s1;
 
516
        
 
517
    /* create the contents of the slider window */
 
518
    scale = XtVaCreateManagedWidget("scale", xmScaleWidgetClass, parent,
 
519
                        XmNorientation, XmHORIZONTAL,
 
520
                        XmNminimum, 0,
 
521
                        XmNmaximum, SLIDER_MAX,
 
522
                        XmNvalue, initval,
 
523
                        XmNtopOffset, 3,
 
524
                        XmNtopAttachment, XmATTACH_WIDGET,
 
525
                        XmNtopWidget, parent,
 
526
                        XmNleftAttachment, XmATTACH_WIDGET,
 
527
                        XmNleftWidget, parent,
 
528
                        XmNrightAttachment, XmATTACH_WIDGET,
 
529
                        XmNrightWidget, attached,
 
530
                        XmNuserData, 0, 0);
 
531
            XtAddCallback(scale, XmNdragCallback,
 
532
                          (XtCallbackProc)gensliderCB, (caddr_t) window);
 
533
            XtAddCallback(scale, XmNvalueChangedCallback,
 
534
                          (XtCallbackProc)gensliderCB, (caddr_t) window);
 
535
     *scaleret = scale;                   
 
536
    value = XtVaCreateManagedWidget("value", xmLabelWidgetClass, parent, 
 
537
                        XmNlabelString,s1=XmStringCreateSimple(namel),
 
538
                        XmNalignment, XmALIGNMENT_END,
 
539
                        XmNrecomputeSize, False, 0);
 
540
      *valueret = value;
 
541
      XmStringFree(s1);
 
542
        
 
543
    return bulletin;
 
544
}
 
545
 
 
546
static void chargedCB(Widget w, ParaWindow *window, caddr_t call_data)
 
547
{
 
548
    window->charged = XmToggleButtonGetState(w);
 
549
    DrawEvent((StdHepWindow *) window, False);
 
550
}
 
551
 
 
552
static void neutralCB(Widget w, ParaWindow *window, caddr_t call_data)
 
553
{
 
554
    window->neutral = XmToggleButtonGetState(w);
 
555
    DrawEvent((StdHepWindow *) window, False);
 
556
}
 
557
 
 
558
 
 
559
static void stableCB(Widget w, ParaWindow *window, caddr_t call_data)
 
560
{
 
561
    window->stable = XmToggleButtonGetState(w);
 
562
    DrawEvent((StdHepWindow *) window, False);
 
563
}
 
564
 
 
565
static void unstableCB(Widget w, ParaWindow *window, caddr_t call_data)
 
566
{
 
567
    window->unstable = XmToggleButtonGetState(w);
 
568
    DrawEvent((StdHepWindow *) window, False);
 
569
}
 
570
 
 
571
static void electronsCB(Widget w, ParaWindow *window, caddr_t call_data)
 
572
{
 
573
    window->electrons = XmToggleButtonGetState(w);
 
574
    DrawEvent((StdHepWindow *) window, False);
 
575
}
 
576
 
 
577
static void muonsCB(Widget w, ParaWindow *window, caddr_t call_data)
 
578
{
 
579
    window->muons = XmToggleButtonGetState(w);
 
580
    DrawEvent((StdHepWindow *) window, False);
 
581
}
 
582
 
 
583
static void gammasCB(Widget w, ParaWindow *window, caddr_t call_data)
 
584
{
 
585
    window->gammas = XmToggleButtonGetState(w);
 
586
    DrawEvent((StdHepWindow *) window, False);
 
587
}
 
588
 
 
589
static void neutrinosCB(Widget w, ParaWindow *window, caddr_t call_data)
 
590
{
 
591
    window->neutrinos = XmToggleButtonGetState(w);
 
592
    DrawEvent((StdHepWindow *) window, False);
 
593
}
 
594
 
 
595
static void quarksCB(Widget w, ParaWindow *window, caddr_t call_data)
 
596
{
 
597
    window->quarks = XmToggleButtonGetState(w);
 
598
    DrawEvent((StdHepWindow *) window, False);
 
599
}
 
600
 
 
601
static void hadronsCB(Widget w, ParaWindow *window, caddr_t call_data)
 
602
{
 
603
    window->hadrons = XmToggleButtonGetState(w);
 
604
    DrawEvent((StdHepWindow *) window, False);
 
605
}
 
606
 
 
607
static void wzCB(Widget w, ParaWindow *window, caddr_t call_data)
 
608
{
 
609
    window->wz = XmToggleButtonGetState(w);
 
610
    DrawEvent((StdHepWindow *) window, False);
 
611
}
 
612
 
 
613
static void zTransCB(Widget w, ParaWindow *window,caddr_t call_data)
 
614
{
 
615
     int sliderValue;
 
616
     char line[40];
 
617
     XmString s1;
 
618
     float curval;
 
619
     
 
620
    XtVaGetValues(w, XmNvalue, &sliderValue, 0);
 
621
    curval = window->minTranslz +
 
622
      sliderValue * (window->maxTranslz - window->minTranslz)/SLIDER_MAX;
 
623
    if (curval == window->currentTranslz)  return;
 
624
    window->currentTranslz = curval;
 
625
    sprintf(line,"Z Trans. = %12.5e",curval);
 
626
    s1=XmStringCreateSimple(line);
 
627
    XtVaSetValues(window->zTranslSliderValue, XmNlabelString, s1, 0);
 
628
    XmStringFree(s1);
 
629
    DrawEvent((StdHepWindow *) window, False);
 
630
}
 
631
     
 
632
static void rapToPtCB(Widget w, ParaWindow *window,caddr_t call_data)
 
633
{
 
634
     int sliderValue;
 
635
     char line[40];
 
636
     XmString s1;
 
637
     float curval;
 
638
     
 
639
    XtVaGetValues(w, XmNvalue, &sliderValue, 0);
 
640
    curval = window->minRapToPt + 
 
641
     sliderValue * (window->maxRapToPt - window->minRapToPt)/SLIDER_MAX;
 
642
    if (curval == window->currentRapToPt)  return;
 
643
    window->currentRapToPt = curval;
 
644
    sprintf(line,"Eta to P (Gev) = %12.5e",curval);
 
645
    s1=XmStringCreateSimple(line);
 
646
    XtVaSetValues(window->rapToPtSliderValue, XmNlabelString, s1, 0);
 
647
    XmStringFree(s1);
 
648
    DrawEvent((StdHepWindow *) window, False);
 
649
    DrawScale((StdHepWindow *) window);
 
650
}
 
651
         
 
652
 
 
653
static void viewRotXPosCB(Widget w, ParaWindow *window, caddr_t call_data)
 
654
{
 
655
    SpinStopSpinning(window->spin);
 
656
    SpinViewRotateX(window->spin, window->buttonRotateDegrees);
 
657
}
 
658
 
 
659
static void viewRotYPosCB(Widget w, ParaWindow *window, caddr_t call_data)
 
660
{
 
661
    SpinStopSpinning(window->spin);
 
662
    SpinViewRotateY(window->spin, window->buttonRotateDegrees);
 
663
}
 
664
 
 
665
static void viewRotZPosCB(Widget w, ParaWindow *window, caddr_t call_data)
 
666
{
 
667
    SpinStopSpinning(window->spin);
 
668
    SpinViewRotateZ(window->spin, window->buttonRotateDegrees);
 
669
}
 
670
 
 
671
static void viewRotXNegCB(Widget w, ParaWindow *window, caddr_t call_data)
 
672
{
 
673
    SpinStopSpinning(window->spin);
 
674
    SpinViewRotateX(window->spin, 0.-window->buttonRotateDegrees);
 
675
}
 
676
 
 
677
static void viewRotYNegCB(Widget w, ParaWindow *window, caddr_t call_data)
 
678
{
 
679
    SpinStopSpinning(window->spin);
 
680
    SpinViewRotateY(window->spin, 0.-window->buttonRotateDegrees);
 
681
}
 
682
 
 
683
static void viewRotZNegCB(Widget w, ParaWindow *window, caddr_t call_data)
 
684
{
 
685
    SpinStopSpinning(window->spin);
 
686
    SpinViewRotateZ(window->spin, 0.-window->buttonRotateDegrees);
 
687
}
 
688
 
 
689
static void coordRotXPosCB(Widget w, ParaWindow *window, caddr_t call_data)
 
690
{
 
691
    SpinStopSpinning(window->spin);
 
692
    SpinCoordRotateX(window->spin, window->buttonRotateDegrees);
 
693
}
 
694
 
 
695
static void coordRotYPosCB(Widget w, ParaWindow *window, caddr_t call_data)
 
696
{
 
697
    SpinStopSpinning(window->spin);
 
698
    SpinCoordRotateY(window->spin, window->buttonRotateDegrees);
 
699
}
 
700
 
 
701
static void coordRotZPosCB(Widget w, ParaWindow *window, caddr_t call_data)
 
702
{
 
703
    SpinStopSpinning(window->spin);
 
704
    SpinCoordRotateZ(window->spin, window->buttonRotateDegrees);
 
705
}
 
706
 
 
707
static void coordRotXNegCB(Widget w, ParaWindow *window, caddr_t call_data)
 
708
{
 
709
    SpinStopSpinning(window->spin);
 
710
    SpinCoordRotateX(window->spin, 0.-window->buttonRotateDegrees);
 
711
}
 
712
 
 
713
static void coordRotYNegCB(Widget w, ParaWindow *window, caddr_t call_data)
 
714
{
 
715
    SpinStopSpinning(window->spin);
 
716
    SpinCoordRotateY(window->spin, 0.-window->buttonRotateDegrees);
 
717
}
 
718
 
 
719
static void coordRotZNegCB(Widget w, ParaWindow *window, caddr_t call_data)
 
720
{
 
721
    SpinStopSpinning(window->spin);
 
722
    SpinCoordRotateZ(window->spin, 0.-window->buttonRotateDegrees);
 
723
}
 
724
 
 
725
static void scaleUpCB(Widget w, ParaWindow *window, caddr_t call_data)
 
726
{
 
727
    SpinSetScale(window->spin, SpinGetScale(window->spin) * (5./4.));
 
728
    DrawScale((StdHepWindow *) window);
 
729
}
 
730
 
 
731
static void scaleDownCB(Widget w, ParaWindow *window, caddr_t call_data)
 
732
{
 
733
    SpinSetScale(window->spin, SpinGetScale(window->spin) * (4./5.));
 
734
    DrawScale((StdHepWindow *) window);
 
735
}
 
736
 
 
737
static void resetRotationCB(Widget w, ParaWindow *window, caddr_t call_data)
 
738
{
 
739
    SpinStopSpinning(window->spin);
 
740
    SpinRestore(window->spin);
 
741
}
 
742
 
 
743
static void scaleExposeCB(Widget w, ParaWindow *window, caddr_t call_data)
 
744
{
 
745
    DrawScale((StdHepWindow *) window);
 
746
}
 
747
 
 
748
static void resizeCB(Widget w, ParaWindow *window, caddr_t call_data)
 
749
{
 
750
    DrawScale((StdHepWindow *) window);
 
751
}
 
752
 
 
753
static void redisplayCB(Widget w, ParaWindow *window, caddr_t call_data)
 
754
{
 
755
    ShowSelectedTrack((StdHepWindow *) window);
 
756
    UpdateRotationPanel((StdHepWindow *) window);
 
757
}
 
758
 
 
759
static void spinSelectCB(Widget w, ParaWindow *window, SpinCallbackStruct *cb)
 
760
{
 
761
    int particleIndex;
 
762
    particleIndex = FindTrack((StdHepWindow *)window,
 
763
                        cb->event->xbutton.x,cb->event->xbutton.y);
 
764
    SelectTrack((StdHepWindow *) window, particleIndex);
 
765
}
 
766
 
 
767
static void nextEvtCB(Widget w, ParaWindow *window, caddr_t call_data)
 
768
{
 
769
    int ievt = window->event.eventNum;
 
770
    ievt++;
 
771
    if (ievt > window->nEvents) {
 
772
        DialogF(DF_INF, w, 1,
 
773
         "You reached the end of this file",
 
774
                        "OK");
 
775
        return;
 
776
     }
 
777
    GetSetStdHep((StdHepWindow *) window, ievt);
 
778
}
 
779
 
 
780
static void previousEvtCB(Widget w, ParaWindow *window, caddr_t call_data)
 
781
{
 
782
    int ievt = window->event.eventNum;
 
783
    ievt--;
 
784
    if (ievt <= 0)  {
 
785
        DialogF(DF_INF, w, 1,
 
786
         "You went back to the beginning this file",
 
787
                        "OK");
 
788
        return;
 
789
     }
 
790
    GetSetStdHep((StdHepWindow *) window, ievt);
 
791
 
792