~maddevelopers/mg5amcnlo/2.9.4

« back to all changes in this revision

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

pass to v2.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*******************************************************************************
 
2
*                                                                              *
 
3
* phase.c -- Nirvana Phase Space Event Display                                 *
 
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
* August 10, 1991                                                              *
 
21
*                                                                              *
 
22
* Written by Mark Edel                                                         *
 
23
*                                                                              *
 
24
*******************************************************************************/
 
25
static char SCCSID[] = "@(#)phase.c     1.2     5/22/92";
 
26
#include <sys/param.h>
 
27
#include <stdio.h>
 
28
#include <X11/Intrinsic.h>
 
29
#include <Xm/Xm.h>              /* only for SpinSegment reqd by drawEvent.h */
 
30
#include "spin/Spin.h"  /* "" "" */
 
31
#include "phase.h"
 
32
#include "space.h"
 
33
#include "phaseP.h"
 
34
#include "panel.h"
 
35
#include "panelPara.h"
 
36
#include "pixmaps.h"
 
37
#include "pick.h"
 
38
#include "drawEvent.h"
 
39
#include "dispTree.h"
 
40
 
 
41
static int ColorsAndBitmapsInitialized = False;
 
42
 
 
43
static void initColorsAndBitmaps(Display *display);
 
44
static void initWindow(StdHepWindow *window);
 
45
 
 
46
/*
 
47
** DisplayOneEvent
 
48
**
 
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).
 
53
**
 
54
** Parameters
 
55
**
 
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
 
60
**                      the call.
 
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
 
67
**                      the menu.
 
68
**                      
 
69
*/
 
70
EventWindow *DisplayOneEvent(Display *display, PhaseEvent *event,
 
71
    char *windowTitle, int mode, void (*exitProc)())
 
72
{
 
73
    char title[MAXPATHLEN + 10];
 
74
    char eventControlText[MAXPATHLEN + 30];
 
75
    PhaseWindow *window;
 
76
    ParaWindow *winpa;
 
77
    StdHepWindow *winsthep;
 
78
    int particleBytes;
 
79
 
 
80
    if (ColorsAndBitmapsInitialized == False)
 
81
        initColorsAndBitmaps(display);
 
82
 
 
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;
 
93
    }
 
94
    winsthep->exitProc = exitProc;
 
95
    winsthep->getEventProc = NULL;
 
96
    winsthep->openProc = NULL;
 
97
    initWindow(winsthep);
 
98
    
 
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);
 
104
    
 
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);
 
111
        }                           
 
112
    return (EventWindow *)window;
 
113
}
 
114
 
 
115
/*
 
116
** DisplayEventFile
 
117
**
 
118
** openProc should return # of events in file, or -1 if can't open
 
119
** should this allow an initial filename to be specified?
 
120
*/
 
121
EventWindow *DisplayEventFile(Display *display, void (*exitProc)(),
 
122
    int (*openProc)(char *filename),
 
123
    void (*closeProc)(FILE *fs), PhaseEvent *(*getEventProc)(int eventNum))
 
124
{
 
125
    static char title[] = "Event Phase Space Display (no file open)";
 
126
    static char barText[] = "No file open";
 
127
    PhaseWindow *window;
 
128
   
 
129
    if (ColorsAndBitmapsInitialized == False)
 
130
        initColorsAndBitmaps(display);
 
131
 
 
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;
 
141
}
 
142
 
 
143
 
 
144
static void initColorsAndBitmaps(Display *display)
 
145
{   
 
146
    /*
 
147
    ** Put the button bitmaps into the motif bitmap cache for later use
 
148
    ** in creating buttons with bitmap labels
 
149
    */
 
150
    RegisterPhaseBitmaps(DefaultScreenOfDisplay(display));
 
151
    
 
152
    /*
 
153
    ** Allocate color cells for particle colors
 
154
    */
 
155
    AllocateColors(DefaultScreenOfDisplay(display));
 
156
    ColorsAndBitmapsInitialized = True;
 
157
}
 
158
 
 
159
static void initWindow(StdHepWindow *window)
 
160
{
 
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;
 
167
    window->tree = 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;
 
180
}