source: trunk/MagicSoft/Mars/meventdisp/MGFadcDisp.cc@ 1015

Last change on this file since 1015 was 991, checked in by tbretz, 23 years ago
*** empty log message ***
File size: 7.2 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 fInitOk = fEvtLoop->PreProcess();
128
129 if (fInitOk)
130 GetTaskList()->Process();
131
132 //
133 // set the smallest and biggest size of the Main frame
134 //
135 SetWMSizeHints(450, 400, 1000, 1000, 10, 10);
136
137 //
138 // Map the window, set up the layout, etc.
139 //
140 MapSubwindows();
141
142 Layout();
143
144 SetWindowName("Fadc Event Display");
145 SetIconName("Fadc");
146
147 UpdateDisplay();
148 UpdateNumOfEvts();
149 UpdateEventCounter();
150
151 MapWindow();
152
153}
154
155// --------------------------------------------------------------------------
156//
157// return pointer to event data
158//
159MRawEvtData *MGFadcDisp::GetEvent() const
160{
161 return (MRawEvtData*)GetParList()->FindObject("MRawEvtData");
162}
163
164// --------------------------------------------------------------------------
165//
166// after a new event is read in one has to update
167// the list of pixels in the fPixelList (TGListBox)
168//
169void MGFadcDisp::DisplayPixel(Int_t lastsel, Bool_t update)
170{
171 MRawEvtData *data = GetEvent();
172
173 if (!data)
174 return;
175
176 MRawEvtPixelIter pixel(data);
177
178 if (update)
179 {
180 //
181 // put the selection of the last event in memory
182 //
183 while (pixel.Next())
184 {
185 char txt[100];
186 sprintf(txt, "%d", pixel.GetPixelId());
187 fPixelList->AddEntry(txt, pixel.GetPixelId());
188 }
189
190 fPixelList->MapSubwindows();
191 fPixelList->Layout();
192 }
193
194 //
195 // check if the pixel from last event also occurs in this event
196 //
197 fCanvas->Clear();
198 fCanvas->cd();
199
200 if (lastsel<0 || !pixel.Jump(lastsel))
201 {
202 pixel.Reset();
203 lastsel=0; //pixel.GetPixelId();
204 }
205
206 char txt[100];
207 sprintf(txt, "GRAPH%d", lastsel);
208 data->Draw(txt);
209 fPixelList->Select(lastsel, kTRUE);
210 fPixelList->SetTopEntry(lastsel);
211
212 fCanvas->Modified();
213 fCanvas->Update();
214}
215
216// --------------------------------------------------------------------------
217//
218// Update the contents of the canvas
219//
220void MGFadcDisp::UpdateDisplay()
221{
222 if (!fInitOk)
223 return;
224
225 const Int_t lastsel = fPixelList->GetSelected();
226
227 fPixelList->RemoveEntries(0, GetEvent()->GetNumPixels());
228
229 DisplayPixel(lastsel);
230}
231
232// --------------------------------------------------------------------------
233//
234// ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
235//
236// Processes information from all GUI items.
237// Selecting an item usually generates an event with 4 parameters.
238// The first two are packed into msg (first and second bytes).
239// The other two are parm1 and parm2.
240//
241Bool_t MGFadcDisp::ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
242{
243 switch(GET_MSG(msg))
244 {
245 case kC_COMMAND:
246 switch(GET_SUBMSG(msg))
247 {
248 case kCM_BUTTON:
249 switch (parm1)
250 {
251 case M_PREVPIXEL:
252 DisplayPixel(fPixelList->GetSelected()-1, kFALSE);
253 return kTRUE;
254
255 case M_NEXTPIXEL:
256 DisplayPixel(fPixelList->GetSelected()+1, kFALSE);
257 return kTRUE;
258 }
259 break;
260
261 case kCM_LISTBOX:
262 if (parm1 != M_PIXELLIST)
263 break;
264
265 DisplayPixel(fPixelList->GetSelected(), kFALSE);
266 return kTRUE;
267 }
268 break;
269 }
270
271 return MGEvtDisplay::ProcessMessage(msg, parm1, parm2);
272}
Note: See TracBrowser for help on using the repository browser.