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

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