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

Last change on this file since 2122 was 1939, checked in by tbretz, 22 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 <limits.h> // INT_MAX
28#include <stdlib.h> // atoi
29#include <iostream.h> // cout for debugging
30
31#include <TList.h> // TList
32#include <TCanvas.h> // TCanvas
33#include <TRootEmbeddedCanvas.h> // TRootEmbeddedCanvas
34
35#include <TGTab.h> // TGTab
36#include <TGLabel.h> // TGLabel
37#include <TGButton.h> // TGPictureButton
38#include <TGSlider.h> // TGVSlider
39#include <TGMsgBox.h> // TGMsgBox
40#include <TGListBox.h> // TGListBox
41#include <TGTextEntry.h> // TGTextEntry
42
43#include <TG3DLine.h> // TGHorizontal3DLine
44 // use TGSplitter instead for root<3.00
45#include "MParList.h"
46#include "MTaskList.h"
47#include "MReadTree.h"
48#include "MEvtLoop.h"
49#include "MRawEvtData.h"
50#include "MRawEvtPixelIter.h"
51
52ClassImp(MGFadcDisp);
53
54enum MGFadcDispCommand
55{
56 M_PREVPIXEL = 0x1000,
57 M_NEXTPIXEL = 0x1001,
58
59 M_PIXELLIST = 0x1002
60};
61
62// --------------------------------------------------------------------------
63//
64// Add the missing GUI elements: These are the pixel number controls
65//
66void MGFadcDisp::AddSetupElements()
67{
68 fTab1->ChangeOptions(kHorizontalFrame);
69
70 //
71 // Create first gui element for tab1
72 //
73 fPixelList = new TGListBox(fTab1, M_PIXELLIST);
74 fPixelList->Associate(this);
75 fPixelList->Resize(80, 230);
76
77 TGLayoutHints *layplist = new TGLayoutHints(kLHintsExpandY|kLHintsLeft, 5, 5, 5, 5);
78 fTab1->AddFrame(fPixelList, layplist);
79
80 TGVerticalFrame *midframe = new TGVerticalFrame(fTab1, 300, 100);
81 fList->Add(midframe);
82
83 TGLayoutHints *laytab = new TGLayoutHints(kLHintsRight|kLHintsExpandY, 5, 5, 5, 5);
84 fList->Add(laytab);
85
86 fTab1->AddFrame(midframe, laytab);
87
88 //
89 // Create gui elements for vertical frame
90 //
91 TGTextButton *prevpix = new TGTextButton(midframe, "<< Prev Pixel", M_PREVPIXEL);
92 TGTextButton *nextpix = new TGTextButton(midframe, "Next Pixel >>", M_NEXTPIXEL);
93 prevpix->Associate(this);
94 nextpix->Associate(this);
95
96 TGVSlider *slider = new TGVSlider(midframe, 200, kSlider1|kScaleBoth);
97 slider->Associate(this);
98 slider->SetRange(0, 576);
99
100 //
101 // Layout gui elements
102 //
103 TGLayoutHints *laybut = new TGLayoutHints(kLHintsRight);
104 TGLayoutHints *layslider = new TGLayoutHints(kLHintsCenterX|kLHintsExpandY);
105
106 midframe->AddFrame(prevpix, laybut);
107 midframe->AddFrame(slider, layslider);
108 midframe->AddFrame(nextpix, laybut);
109}
110
111// --------------------------------------------------------------------------
112//
113// Constructor
114//
115MGFadcDisp::MGFadcDisp(const char *filename, const char *treename,
116 const TGWindow *p, /*const TGWindow *main,*/
117 UInt_t w, UInt_t h)
118 : MGEvtDisplay(filename, treename, p, /*main,*/ w, h)
119{
120 //
121 // Add the missing GUI elements (pixellist, pixel number controls)
122 //
123 AddSetupElements();
124
125 //
126 // preprocess eventloop and read in first event (process)
127 //
128 GetReader()->DisableAutoScheme();
129 ReadFirstEvent();
130
131 //
132 // Map the window, set up the layout, etc.
133 //
134 MapSubwindows();
135
136 Layout();
137
138 SetWindowName("Fadc Event Display");
139 SetIconName("Fadc");
140
141 MapWindow();
142
143}
144
145// --------------------------------------------------------------------------
146//
147// return pointer to event data
148//
149MRawEvtData *MGFadcDisp::GetEvent() const
150{
151 return (MRawEvtData*)GetParList()->FindObject("MRawEvtData");
152}
153
154// --------------------------------------------------------------------------
155//
156// after a new event is read in one has to update
157// the list of pixels in the fPixelList (TGListBox)
158//
159void MGFadcDisp::DisplayPixel(Int_t lastsel, Bool_t update)
160{
161 MRawEvtData *data = GetEvent();
162
163 if (!data)
164 return;
165
166 MRawEvtPixelIter pixel(data);
167
168 if (update)
169 {
170 //
171 // put the selection of the last event in memory
172 //
173 while (pixel.Next())
174 {
175 TString txt;
176 txt += pixel.GetPixelId();
177 fPixelList->AddEntrySort(txt, pixel.GetPixelId());
178 }
179
180 fPixelList->MapSubwindows();
181 fPixelList->Layout();
182 }
183
184 //
185 // check if the pixel from last event also occurs in this event
186 //
187 fCanvas->Clear();
188 fCanvas->cd();
189
190 if (lastsel<0 || !pixel.Jump(lastsel))
191 {
192 pixel.Reset();
193 lastsel=0; //pixel.GetPixelId();
194 }
195
196 TString txt("GRAPH");
197 txt += lastsel;
198
199 data->Draw(txt);
200
201 fPixelList->Select(lastsel, kTRUE);
202 fPixelList->SetTopEntry(lastsel);
203
204 fCanvas->Modified();
205 fCanvas->Update();
206}
207
208// --------------------------------------------------------------------------
209//
210// Update the contents of the canvas
211//
212void MGFadcDisp::UpdateDisplay()
213{
214 if (!IsInitOk())
215 return;
216
217 const Int_t lastsel = fPixelList->GetSelected();
218
219 fPixelList->RemoveEntries(0, INT_MAX);
220
221 DisplayPixel(lastsel);
222}
223
224// --------------------------------------------------------------------------
225//
226// ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
227//
228// Processes information from all GUI items.
229// Selecting an item usually generates an event with 4 parameters.
230// The first two are packed into msg (first and second bytes).
231// The other two are parm1 and parm2.
232//
233Bool_t MGFadcDisp::ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
234{
235 switch(GET_MSG(msg))
236 {
237 case kC_COMMAND:
238 switch(GET_SUBMSG(msg))
239 {
240 case kCM_BUTTON:
241 switch (parm1)
242 {
243 case M_PREVPIXEL:
244 DisplayPixel(fPixelList->GetSelected()-1, kFALSE);
245 return kTRUE;
246
247 case M_NEXTPIXEL:
248 DisplayPixel(fPixelList->GetSelected()+1, kFALSE);
249 return kTRUE;
250 }
251 break;
252
253 case kCM_LISTBOX:
254 if (parm1 != M_PIXELLIST)
255 break;
256
257 DisplayPixel(fPixelList->GetSelected(), kFALSE);
258 return kTRUE;
259 }
260 break;
261 }
262
263 return MGEvtDisplay::ProcessMessage(msg, parm1, parm2);
264}
Note: See TracBrowser for help on using the repository browser.