1
/*******************************************************************************
3
* phase.c -- Nirvana Phase Space Event Display *
5
* Copyright (c) 1991 Universities Research Association, Inc. *
6
* All rights reserved. *
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. *
19
* Fermilab Nirvana GUI Library *
22
* Written by Mark Edel *
24
*******************************************************************************/
25
static char SCCSID[] = "@(#)phase.c 1.2 5/22/92";
26
#include <sys/param.h>
28
#include <X11/Intrinsic.h>
29
#include <Xm/Xm.h> /* only for SpinSegment reqd by drawEvent.h */
30
#include "spin/Spin.h" /* "" "" */
35
#include "panelPara.h"
38
#include "drawEvent.h"
41
static int ColorsAndBitmapsInitialized = False;
43
static void initColorsAndBitmaps(Display *display);
44
static void initWindow(StdHepWindow *window);
49
** Puts up a phase space event display window to display a single event.
50
** DisplayOneEvent must be called from a properly initialized Motif environment.
51
** After calling DisplayOneEvent, the program must enter a standard Motif event
52
** loop (XtMainLoop, XtAppMainLoop, or a user written main loop).
56
** display The X display to use
57
** event The event to display (phase.h has details). The
58
** event data is copied including the particle list,
59
** so the caller does not need to maintain it after
61
** windowTitle A title for the event display window
62
** mode A int to declare the display type or mode,
63
** either PHASE or PARA ( Eta-Pt) plot.
64
** exitProc A procedure to execute when the user selects "Exit"
65
** from the "File", or "Window" menu of the event
66
** display window. Pass NULL to omit "Exit" from
70
EventWindow *DisplayOneEvent(Display *display, PhaseEvent *event,
71
char *windowTitle, int mode, void (*exitProc)())
73
char title[MAXPATHLEN + 10];
74
char eventControlText[MAXPATHLEN + 30];
77
StdHepWindow *winsthep;
80
if (ColorsAndBitmapsInitialized == False)
81
initColorsAndBitmaps(display);
83
if (mode == STDHEP_PHASE) {
84
window = CreatePanel(display, False, False,
85
exitProc != NULL, windowTitle, NULL);
86
window->type = STDHEP_PHASE;
87
winsthep = (StdHepWindow *) window;
88
} else if ( mode == STDHEP_PARA) {
89
winpa = CreatePanelPa(display, False, False,
90
exitProc != NULL, windowTitle, NULL);
91
winsthep = (StdHepWindow *) winpa;
92
winpa->type = STDHEP_PARA;
94
winsthep->exitProc = exitProc;
95
winsthep->getEventProc = NULL;
96
winsthep->openProc = NULL;
99
/* Copy the event so caller doesn't have to maintain it */
100
winsthep->event = *event;
101
particleBytes = event->nParticles * sizeof(PhaseParticle);
102
winsthep->event.particles = (PhaseParticle *)XtMalloc(particleBytes);
103
memcpy(winsthep->event.particles, event->particles, particleBytes);
105
if (mode == STDHEP_PARA) SetScaleParaSliders(winpa);
106
DrawEvent(winsthep, True);
107
if ( mode == STDHEP_PARA) {
108
XtSetSensitive(winsthep->eventTreeButton, TRUE);
109
if(winsthep->colorCodeButton != NULL)
110
XtSetSensitive(winsthep->colorCodeButton, TRUE);
112
return (EventWindow *)window;
118
** openProc should return # of events in file, or -1 if can't open
119
** should this allow an initial filename to be specified?
121
EventWindow *DisplayEventFile(Display *display, void (*exitProc)(),
122
int (*openProc)(char *filename),
123
void (*closeProc)(FILE *fs), PhaseEvent *(*getEventProc)(int eventNum))
125
static char title[] = "Event Phase Space Display (no file open)";
126
static char barText[] = "No file open";
129
if (ColorsAndBitmapsInitialized == False)
130
initColorsAndBitmaps(display);
132
window = CreatePanel(display, True, True,
133
exitProc != NULL, title, barText);
134
window->type = STDHEP_PHASE;
135
window->exitProc = exitProc;
136
window->getEventProc = getEventProc;
137
window->openProc = openProc;
138
window->closeProc = closeProc;
139
initWindow( (StdHepWindow *) window);
140
return (EventWindow *)window;
144
static void initColorsAndBitmaps(Display *display)
147
** Put the button bitmaps into the motif bitmap cache for later use
148
** in creating buttons with bitmap labels
150
RegisterPhaseBitmaps(DefaultScreenOfDisplay(display));
153
** Allocate color cells for particle colors
155
AllocateColors(DefaultScreenOfDisplay(display));
156
ColorsAndBitmapsInitialized = True;
159
static void initWindow(StdHepWindow *window)
161
window->filename=NULL;
162
window->event.particles = NULL;
163
window->event.eventNum = 0;
164
window->event.nParticles = 0;
165
window->dtree = NULL;
166
window->stree = NULL;
168
window->dtreecolorcode = NULL;
169
window->streecolorcode = NULL;
170
window->treecolorcode = NULL;
171
window->nodeWindowShell = NULL;
172
window->colorWindowShell = NULL;
173
window->treehead = NULL;
174
window->selectedTrack = NO_TRACK;
175
window->selectedNode = NULL;
176
window->selnodeNumTrack = 0;
177
window->selnodeTracks = NULL;
178
window->treeheadcolorcode = NULL;
179
window->modetreedisp = TREEDISPREAL;