source: tags/Mars-V0.5/meventdisp/MGFadcDisp.cc

Last change on this file was 1030, checked in by tbretz, 23 years ago
*** empty log message ***
File size: 7.1 KB
Line 
1/*======================================================================== *\
2!
3! *
4! * This file is part of MARS, the MAGIC Analysis and Reconstruction
5! * Software. It is distributed to you in the hope that it can be a useful
6! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
7! * It is distributed WITHOUT ANY WARRANTY.
8! *
9! * Permission to use, copy, modify and distribute this software and its
10! * documentation for any purpose is hereby granted without fee,
11! * provided that the above copyright notice appear in all copies and
12! * that both that copyright notice and this permission notice appear
13! * in supporting documentation. It is provided "as is" without express
14! * or implied warranty.
15! *
16!
17!
18! Author(s): Thomas Bretz 10/2001 (tbretz@uni-sw.gwdg.de)
19!
20! Copyright: MAGIC Software Development, 2000-2001
21!
22!
23\* ======================================================================== */
24
25#include "MGFadcDisp.h"
26
27#include <stdlib.h> // atoi
28#include <iostream.h> // cout for debugging
29
30#include <TList.h> // TList
31#include <TCanvas.h> // TCanvas
32#include <TRootEmbeddedCanvas.h> // TRootEmbeddedCanvas
33
34#include <TGTab.h> // TGTab
35#include <TGLabel.h> // TGLabel
36#include <TGButton.h> // TGPictureButton
37#include <TGSlider.h> // TGVSlider
38#include <TGMsgBox.h> // TGMsgBox
39#include <TGListBox.h> // TGListBox
40#include <TGTextEntry.h> // TGTextEntry
41
42#include <TG3DLine.h> // TGHorizontal3DLine
43 // use TGSplitter instead for root<3.00
44#include "MParList.h"
45#include "MTaskList.h"
46#include "MReadTree.h"
47#include "MEvtLoop.h"
48#include "MRawEvtData.h"
49#include "MRawEvtPixelIter.h"
50
51ClassImp(MGFadcDisp);
52
53enum MGFadcDispCommand
54{
55 M_PREVPIXEL = 0x1000,
56 M_NEXTPIXEL = 0x1001,
57
58 M_PIXELLIST = 0x1002
59};
60
61// --------------------------------------------------------------------------
62//
63// Add the missing GUI elements: These are the pixel number controls
64//
65void MGFadcDisp::AddSetupElements()
66{
67 fTab1->ChangeOptions(kHorizontalFrame);
68
69 //
70 // Create first gui element for tab1
71 //
72 fPixelList = new TGListBox(fTab1, M_PIXELLIST);
73 fPixelList->Associate(this);
74 fPixelList->Resize(80, 230);
75
76 TGLayoutHints *layplist = new TGLayoutHints(kLHintsExpandY|kLHintsLeft, 5, 5, 5, 5);
77 fTab1->AddFrame(fPixelList, layplist);
78
79 TGVerticalFrame *fMidFrame = new TGVerticalFrame(fTab1, 300, 100);
80 fList->Add(fMidFrame);
81
82 TGLayoutHints *laytab = new TGLayoutHints(kLHintsRight|kLHintsExpandY, 5, 5, 5, 5);
83 fList->Add(laytab);
84
85 fTab1->AddFrame(fMidFrame, laytab);
86
87 //
88 // Create gui elements for vertical frame
89 //
90 TGTextButton *prevpix = new TGTextButton(fMidFrame, "<< Prev Pixel", M_PREVPIXEL);
91 TGTextButton *nextpix = new TGTextButton(fMidFrame, "Next Pixel >>", M_NEXTPIXEL);
92 prevpix->Associate(this);
93 nextpix->Associate(this);
94
95 TGVSlider *slider = new TGVSlider(fMidFrame, 200, kSlider1|kScaleBoth);
96 slider->Associate(this);
97 slider->SetRange(0, 576);
98
99 //
100 // Layout gui elements
101 //
102 TGLayoutHints *laybut = new TGLayoutHints(kLHintsRight);
103 TGLayoutHints *layslider = new TGLayoutHints(kLHintsCenterX|kLHintsExpandY);
104
105 fMidFrame->AddFrame(prevpix, laybut);
106 fMidFrame->AddFrame(slider, layslider);
107 fMidFrame->AddFrame(nextpix, laybut);
108}
109
110// --------------------------------------------------------------------------
111//
112// Constructor
113//
114MGFadcDisp::MGFadcDisp(char *filename, char *treename,
115 const TGWindow *p, const TGWindow *main,
116 UInt_t w, UInt_t h)
117 : MGEvtDisplay(filename, treename, p, main, w, h)
118{
119 //
120 // Add the missing GUI elements (pixellist, pixel number controls)
121 //
122 AddSetupElements();
123
124 //
125 // preprocess eventloop and read in first event (process)
126 //
127 GetReader()->DisableAutoScheme();
128 ReadFirstEvent();
129
130 //
131 // set the smallest and biggest size of the Main frame
132 //
133 SetWMSizeHints(450, 400, 1000, 1000, 10, 10);
134
135 //
136 // Map the window, set up the layout, etc.
137 //
138 MapSubwindows();
139
140 Layout();
141
142 SetWindowName("Fadc Event Display");
143 SetIconName("Fadc");
144
145 MapWindow();
146
147}
148
149// --------------------------------------------------------------------------
150//
151// return pointer to event data
152//
153MRawEvtData *MGFadcDisp::GetEvent() const
154{
155 return (MRawEvtData*)GetParList()->FindObject("MRawEvtData");
156}
157
158// --------------------------------------------------------------------------
159//
160// after a new event is read in one has to update
161// the list of pixels in the fPixelList (TGListBox)
162//
163void MGFadcDisp::DisplayPixel(Int_t lastsel, Bool_t update)
164{
165 MRawEvtData *data = GetEvent();
166
167 if (!data)
168 return;
169
170 MRawEvtPixelIter pixel(data);
171
172 if (update)
173 {
174 //
175 // put the selection of the last event in memory
176 //
177 while (pixel.Next())
178 {
179 char txt[100];
180 sprintf(txt, "%d", pixel.GetPixelId());
181 fPixelList->AddEntry(txt, pixel.GetPixelId());
182 }
183
184 fPixelList->MapSubwindows();
185 fPixelList->Layout();
186 }
187
188 //
189 // check if the pixel from last event also occurs in this event
190 //
191 fCanvas->Clear();
192 fCanvas->cd();
193
194 if (lastsel<0 || !pixel.Jump(lastsel))
195 {
196 pixel.Reset();
197 lastsel=0; //pixel.GetPixelId();
198 }
199
200 char txt[100];
201 sprintf(txt, "GRAPH%d", lastsel);
202 data->Draw(txt);
203 fPixelList->Select(lastsel, kTRUE);
204 fPixelList->SetTopEntry(lastsel);
205
206 fCanvas->Modified();
207 fCanvas->Update();
208}
209
210// --------------------------------------------------------------------------
211//
212// Update the contents of the canvas
213//
214void MGFadcDisp::UpdateDisplay()
215{
216 if (!IsInitOk())
217 return;
218
219 const Int_t lastsel = fPixelList->GetSelected();
220
221 fPixelList->RemoveEntries(0, GetEvent()->GetNumPixels());
222
223 DisplayPixel(lastsel);
224}
225
226// --------------------------------------------------------------------------
227//
228// ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
229//
230// Processes information from all GUI items.
231// Selecting an item usually generates an event with 4 parameters.
232// The first two are packed into msg (first and second bytes).
233// The other two are parm1 and parm2.
234//
235Bool_t MGFadcDisp::ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
236{
237 switch(GET_MSG(msg))
238 {
239 case kC_COMMAND:
240 switch(GET_SUBMSG(msg))
241 {
242 case kCM_BUTTON:
243 switch (parm1)
244 {
245 case M_PREVPIXEL:
246 DisplayPixel(fPixelList->GetSelected()-1, kFALSE);
247 return kTRUE;
248
249 case M_NEXTPIXEL:
250 DisplayPixel(fPixelList->GetSelected()+1, kFALSE);
251 return kTRUE;
252 }
253 break;
254
255 case kCM_LISTBOX:
256 if (parm1 != M_PIXELLIST)
257 break;
258
259 DisplayPixel(fPixelList->GetSelected(), kFALSE);
260 return kTRUE;
261 }
262 break;
263 }
264
265 return MGEvtDisplay::ProcessMessage(msg, parm1, parm2);
266}
Note: See TracBrowser for help on using the repository browser.