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

Last change on this file since 971 was 961, 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 fEvtLoop->PreProcess();
128 GetTaskList()->Process();
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 UpdateDisplay();
146 UpdateNumOfEvts();
147 UpdateEventCounter();
148
149 MapWindow();
150
151}
152
153// --------------------------------------------------------------------------
154//
155// return pointer to event data
156//
157MRawEvtData *MGFadcDisp::GetEvent() const
158{
159 return (MRawEvtData*)GetParList()->FindObject("MRawEvtData");
160}
161
162// --------------------------------------------------------------------------
163//
164// after a new event is read in one has to update
165// the list of pixels in the fPixelList (TGListBox)
166//
167void MGFadcDisp::DisplayPixel(Int_t lastsel, Bool_t update)
168{
169 MRawEvtData *data = GetEvent();
170
171 MRawEvtPixelIter pixel(data);
172
173 if (update)
174 {
175 //
176 // put the selection of the last event in memory
177 //
178 while (pixel.Next())
179 {
180 char txt[100];
181 sprintf(txt, "%d", pixel.GetPixelId());
182 fPixelList->AddEntry(txt, pixel.GetPixelId());
183 }
184
185 fPixelList->MapSubwindows();
186 fPixelList->Layout();
187 }
188
189 //
190 // check if the pixel from last event also occurs in this event
191 //
192 fCanvas->Clear();
193 fCanvas->cd();
194
195 if (lastsel<0 || !pixel.Jump(lastsel))
196 {
197 pixel.Reset();
198 lastsel=0; //pixel.GetPixelId();
199 }
200
201 char txt[100];
202 sprintf(txt, "GRAPH%d", lastsel);
203 data->Draw(txt);
204 fPixelList->Select(lastsel, kTRUE);
205 fPixelList->SetTopEntry(lastsel);
206
207 fCanvas->Modified();
208 fCanvas->Update();
209}
210
211// --------------------------------------------------------------------------
212//
213// Update the contents of the canvas
214//
215void MGFadcDisp::UpdateDisplay()
216{
217 const Int_t lastsel = fPixelList->GetSelected();
218
219 fPixelList->RemoveEntries(0, GetEvent()->GetNumPixels());
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.