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-2002
|
---|
21 | !
|
---|
22 | !
|
---|
23 | \* ======================================================================== */
|
---|
24 |
|
---|
25 | #include "MGEvtDisplay.h"
|
---|
26 |
|
---|
27 | #include <stdlib.h> // atoi
|
---|
28 |
|
---|
29 | #include <TGTab.h> // TGTab
|
---|
30 | #include <TGMenu.h> // TGPopupMenu
|
---|
31 | #include <TCanvas.h> // TCanvas::Print
|
---|
32 | #include <TGLabel.h> // TGLabel
|
---|
33 | #include <TGButton.h> // TGPictureButton
|
---|
34 | #include <TGMsgBox.h> // TGMsgBox
|
---|
35 | #include <TGTextEntry.h> // TGTextEntry
|
---|
36 | #include <TGFileDialog.h> // TGFileDialog
|
---|
37 | #include <TRootEmbeddedCanvas.h> // TRootEmbeddedCanvas
|
---|
38 |
|
---|
39 | #include <TG3DLine.h> // TGHorizontal3DLine
|
---|
40 | // use TGSplitter instead for root<3.00
|
---|
41 |
|
---|
42 | #include "MParList.h"
|
---|
43 | #include "MTaskList.h"
|
---|
44 | #include "MEvtLoop.h"
|
---|
45 | #include "MCamDisplay.h"
|
---|
46 | #include "MReadMarsFile.h"
|
---|
47 | #include "MGeomCamMagic.h"
|
---|
48 | #include "MRawEvtHeader.h"
|
---|
49 |
|
---|
50 | #include "MMcEvt.hxx"
|
---|
51 |
|
---|
52 | ClassImp(MGEvtDisplay);
|
---|
53 |
|
---|
54 | enum MGCamDisplayCommand
|
---|
55 | {
|
---|
56 | kEvtPrev,
|
---|
57 | kEvtNext,
|
---|
58 | kEvtNumber,
|
---|
59 |
|
---|
60 | kFileSaveAs,
|
---|
61 | kFileSaveAsRoot,
|
---|
62 | kFileSaveAsC,
|
---|
63 | kFileSaveAsPS,
|
---|
64 | kFileSaveAsEPS,
|
---|
65 | kFileSaveAsGIF,
|
---|
66 | kFilePrint,
|
---|
67 | kClose
|
---|
68 | };
|
---|
69 |
|
---|
70 | // --------------------------------------------------------------------------
|
---|
71 | //
|
---|
72 | // Return a pointer to the parameter list.
|
---|
73 | //
|
---|
74 | MParList *MGEvtDisplay::GetParList() const
|
---|
75 | {
|
---|
76 | return fEvtLoop->GetParList();
|
---|
77 | }
|
---|
78 |
|
---|
79 | // --------------------------------------------------------------------------
|
---|
80 | //
|
---|
81 | // Return a pointer to the task list.
|
---|
82 | //
|
---|
83 | MTaskList *MGEvtDisplay::GetTaskList() const
|
---|
84 | {
|
---|
85 | return (MTaskList*)GetParList()->FindObject("MTaskList");
|
---|
86 | }
|
---|
87 |
|
---|
88 | // --------------------------------------------------------------------------
|
---|
89 | //
|
---|
90 | // Return a pointer to the reader task (MReadTree)
|
---|
91 | //
|
---|
92 | MReadTree *MGEvtDisplay::GetReader() const
|
---|
93 | {
|
---|
94 | return (MReadTree*)GetTaskList()->FindObject("MRead");
|
---|
95 | }
|
---|
96 |
|
---|
97 | // --------------------------------------------------------------------------
|
---|
98 | //
|
---|
99 | // Add the top part of the frame: This is filename and treename display
|
---|
100 | //
|
---|
101 | void MGEvtDisplay::AddTopFramePart1(TGVerticalFrame *frame,
|
---|
102 | const char *filename,
|
---|
103 | const char *treename)
|
---|
104 | {
|
---|
105 | //
|
---|
106 | // --- the top1 part of the window ---
|
---|
107 | //
|
---|
108 | TGHorizontalFrame *top1 = new TGHorizontalFrame(frame, 300, 100);
|
---|
109 | fList->Add(top1);
|
---|
110 |
|
---|
111 | //
|
---|
112 | // create gui elements
|
---|
113 | //
|
---|
114 | TGLabel *lfile = new TGLabel(top1, new TGString("File:"));
|
---|
115 | TGLabel *file = new TGLabel(top1, new TGString(filename));
|
---|
116 | TGLabel *ltree = new TGLabel(top1, new TGString("Tree:"));
|
---|
117 | TGLabel *tree = new TGLabel(top1, new TGString(treename));
|
---|
118 |
|
---|
119 | fList->Add(lfile);
|
---|
120 | fList->Add(file);
|
---|
121 | fList->Add(ltree);
|
---|
122 | fList->Add(tree);
|
---|
123 |
|
---|
124 | //
|
---|
125 | // layout and add gui elements in/to frame
|
---|
126 | //
|
---|
127 | TGLayoutHints *laystd = new TGLayoutHints(kLHintsLeft, 10, 10, 10, 10);
|
---|
128 | fList->Add(laystd);
|
---|
129 |
|
---|
130 | top1->AddFrame(lfile, laystd);
|
---|
131 | top1->AddFrame(file, laystd);
|
---|
132 | top1->AddFrame(ltree, laystd);
|
---|
133 | top1->AddFrame(tree, laystd);
|
---|
134 |
|
---|
135 | //
|
---|
136 | // --- the top1 part of the window ---
|
---|
137 | //
|
---|
138 | TGHorizontalFrame *top2 = new TGHorizontalFrame(frame, 300, 100);
|
---|
139 | fList->Add(top2);
|
---|
140 |
|
---|
141 | fEvtInfo = new TGLabel(top2, new TGString(""));
|
---|
142 | fList->Add(fEvtInfo);
|
---|
143 | top2->AddFrame(fEvtInfo, laystd);
|
---|
144 |
|
---|
145 | //
|
---|
146 | // layout and add frames
|
---|
147 | //
|
---|
148 | TGLayoutHints *laytop1 = new TGLayoutHints(kLHintsTop);
|
---|
149 | fList->Add(laytop1);
|
---|
150 | frame->AddFrame(top1, laytop1);
|
---|
151 | frame->AddFrame(top2, laytop1);
|
---|
152 | }
|
---|
153 |
|
---|
154 | // --------------------------------------------------------------------------
|
---|
155 | //
|
---|
156 | // Add the second part of the top frame: This are the event number controls
|
---|
157 | //
|
---|
158 | void MGEvtDisplay::AddTopFramePart2(TGVerticalFrame *frame)
|
---|
159 | {
|
---|
160 | //
|
---|
161 | // --- the top2 part of the window ---
|
---|
162 | //
|
---|
163 | TGHorizontalFrame *top2 = new TGHorizontalFrame(frame, 300, 100);
|
---|
164 | fList->Add(top2);
|
---|
165 |
|
---|
166 | //
|
---|
167 | // Create the gui elements
|
---|
168 | //
|
---|
169 | TGTextButton *prevevt = new TGTextButton(top2, "<< Previous Event", kEvtPrev);
|
---|
170 | prevevt->Associate(this);
|
---|
171 |
|
---|
172 | TGLabel *evtnr = new TGLabel(top2, new TGString("Event: "));
|
---|
173 |
|
---|
174 | fTxtEvtNr = new TGTextEntry(top2, new TGTextBuffer(100), kEvtNumber);
|
---|
175 | fTxtEvtNr->Resize(60, fTxtEvtNr->GetDefaultHeight());
|
---|
176 | fTxtEvtNr->Associate(this);
|
---|
177 |
|
---|
178 | fNumOfEvts = new TGLabel(top2, "out of Events.");
|
---|
179 |
|
---|
180 | TGTextButton *nextevt = new TGTextButton (top2, "Next Event >>", kEvtNext);
|
---|
181 | nextevt->Associate(this);
|
---|
182 |
|
---|
183 | //
|
---|
184 | // Add gui elements to 'atotodel'
|
---|
185 | //
|
---|
186 | fList->Add(prevevt);
|
---|
187 | fList->Add(evtnr);
|
---|
188 | fList->Add(fTxtEvtNr);
|
---|
189 | fList->Add(fNumOfEvts);
|
---|
190 | fList->Add(nextevt);
|
---|
191 |
|
---|
192 | //
|
---|
193 | // add the gui elements to the frame
|
---|
194 | //
|
---|
195 | TGLayoutHints *laystd = new TGLayoutHints(kLHintsLeft|kLHintsCenterY, 10, 10, 10, 10);
|
---|
196 |
|
---|
197 | fList->Add(laystd);
|
---|
198 |
|
---|
199 | top2->AddFrame(prevevt, laystd);
|
---|
200 | top2->AddFrame(evtnr, laystd);
|
---|
201 | top2->AddFrame(fTxtEvtNr, laystd);
|
---|
202 | top2->AddFrame(fNumOfEvts, laystd);
|
---|
203 | top2->AddFrame(nextevt, laystd);
|
---|
204 |
|
---|
205 | frame->AddFrame(top2, new TGLayoutHints(kLHintsCenterX));
|
---|
206 | }
|
---|
207 |
|
---|
208 | // --------------------------------------------------------------------------
|
---|
209 | //
|
---|
210 | // Add a tab with an embedded canvas for an camera display and return the
|
---|
211 | // pointer to the canvas
|
---|
212 | //
|
---|
213 | TCanvas *MGEvtDisplay::AddTab(TString name)
|
---|
214 | {
|
---|
215 | TGLayoutHints *laycanvas = new TGLayoutHints(kLHintsCenterX|kLHintsCenterY|kLHintsExpandX|kLHintsExpandY);
|
---|
216 | fList->Add(laycanvas);
|
---|
217 |
|
---|
218 | TGCompositeFrame *frame = fEvtDisplay->AddTab(name);
|
---|
219 | TRootEmbeddedCanvas *canvas = new TRootEmbeddedCanvas(name+"Display", frame, 400, 400);
|
---|
220 | frame->AddFrame(canvas, laycanvas);
|
---|
221 | fList->Add(canvas);
|
---|
222 | return canvas->GetCanvas();
|
---|
223 | }
|
---|
224 |
|
---|
225 | // --------------------------------------------------------------------------
|
---|
226 | //
|
---|
227 | // Add the mid frame: This are the two tabs with the canvas in the right one
|
---|
228 | //
|
---|
229 | void MGEvtDisplay::AddMidFrame(TGHorizontalFrame *frame)
|
---|
230 | {
|
---|
231 | //
|
---|
232 | // create tab control
|
---|
233 | //
|
---|
234 | TGTab *tabs = new TGTab(frame, 300, 300);
|
---|
235 |
|
---|
236 | //
|
---|
237 | // Create Tab1
|
---|
238 | //
|
---|
239 | fTab1 = tabs->AddTab("Setup");
|
---|
240 |
|
---|
241 | //
|
---|
242 | // Crete second gui elemet for tab1 (TGVertical Frame)
|
---|
243 | //
|
---|
244 | TGLayoutHints *laytabs = new TGLayoutHints(kLHintsNormal|kLHintsExpandY, 10, 10, 10, 10);
|
---|
245 | frame->AddFrame(tabs, laytabs);
|
---|
246 |
|
---|
247 | //
|
---|
248 | // Create second part of frame
|
---|
249 | //
|
---|
250 | fEvtDisplay = new TGTab(frame, 300, 300);
|
---|
251 |
|
---|
252 | fCanvas=AddTab("Photons");
|
---|
253 |
|
---|
254 | AddTab("Geometry");
|
---|
255 | MGeomCamMagic geom;
|
---|
256 | MCamDisplay *display = new MCamDisplay(&geom);
|
---|
257 | display->Draw();
|
---|
258 | display->DrawPixelNumbers();
|
---|
259 | fList->Add(display);
|
---|
260 |
|
---|
261 | //
|
---|
262 | // Add second part to frame
|
---|
263 | //
|
---|
264 | TGLayoutHints *laydisp = new TGLayoutHints(kLHintsNormal|kLHintsExpandY|kLHintsExpandX, 10, 10, 10, 10);
|
---|
265 | frame->AddFrame(fEvtDisplay, laydisp);
|
---|
266 |
|
---|
267 | //
|
---|
268 | // Now add all gui elements to 'autodel'-list
|
---|
269 | //
|
---|
270 | fList->Add(fEvtDisplay);
|
---|
271 | fList->Add(laydisp);
|
---|
272 | fList->Add(laytabs);
|
---|
273 | }
|
---|
274 |
|
---|
275 | // --------------------------------------------------------------------------
|
---|
276 | //
|
---|
277 | // Add the low frame: These are the buttons Print and Close
|
---|
278 | //
|
---|
279 | void MGEvtDisplay::AddLowFrame(TGHorizontalFrame *frame)
|
---|
280 | {
|
---|
281 | TGTextButton *but = new TGTextButton(frame, "Close", kClose);
|
---|
282 |
|
---|
283 | but->Associate(this);
|
---|
284 |
|
---|
285 | fList->Add(but);
|
---|
286 |
|
---|
287 | TGLayoutHints *laybut = new TGLayoutHints(kLHintsLeft, 10, 10, 10, 10);
|
---|
288 | fList->Add(laybut);
|
---|
289 |
|
---|
290 | frame->AddFrame(but, laybut);
|
---|
291 | }
|
---|
292 |
|
---|
293 | // --------------------------------------------------------------------------
|
---|
294 | //
|
---|
295 | // Create and setup all the three frames and build the window interieur
|
---|
296 | //
|
---|
297 | void MGEvtDisplay::AddFrames(const char *filename, const char *treename)
|
---|
298 | {
|
---|
299 | //
|
---|
300 | // Create the frame elements and add gui elements to it
|
---|
301 | //
|
---|
302 | TGVerticalFrame *frametop = new TGVerticalFrame(this, 300, 100);
|
---|
303 | fList->Add(frametop);
|
---|
304 |
|
---|
305 | AddTopFramePart1(frametop, filename, treename);
|
---|
306 | AddTopFramePart2(frametop);
|
---|
307 |
|
---|
308 | TGLayoutHints *laytop = new TGLayoutHints(kLHintsTop|kLHintsCenterX);
|
---|
309 | fList->Add(laytop);
|
---|
310 |
|
---|
311 | // -----
|
---|
312 |
|
---|
313 | TGHorizontalFrame *framemid = new TGHorizontalFrame(this, 300, 100);
|
---|
314 | fList->Add(framemid);
|
---|
315 |
|
---|
316 | AddMidFrame(framemid);
|
---|
317 |
|
---|
318 | TGLayoutHints *laymid = new TGLayoutHints(kLHintsExpandY|kLHintsExpandX);
|
---|
319 | fList->Add(laymid);
|
---|
320 |
|
---|
321 | //
|
---|
322 | // add frame elements to 'autodel'
|
---|
323 | //
|
---|
324 | TGHorizontal3DLine *line1 = new TGHorizontal3DLine(this);
|
---|
325 | TGHorizontal3DLine *line2 = new TGHorizontal3DLine(this);
|
---|
326 | fList->Add(line1);
|
---|
327 | fList->Add(line2);
|
---|
328 |
|
---|
329 | TGLayoutHints *layline = new TGLayoutHints(kLHintsTop|kLHintsExpandX);
|
---|
330 | fList->Add(layline);
|
---|
331 |
|
---|
332 | // -----
|
---|
333 | TGHorizontalFrame *framelow = new TGHorizontalFrame(this, 300, 100);
|
---|
334 | fList->Add(framelow);
|
---|
335 |
|
---|
336 | AddLowFrame(framelow);
|
---|
337 |
|
---|
338 | TGLayoutHints *laylow = new TGLayoutHints(kLHintsTop);
|
---|
339 | fList->Add(laylow);
|
---|
340 |
|
---|
341 | //
|
---|
342 | // Layout frame elements and add elements to frame
|
---|
343 | //
|
---|
344 | AddFrame(frametop, laytop);
|
---|
345 | AddFrame(line1, layline);
|
---|
346 | AddFrame(framemid, laymid);
|
---|
347 | AddFrame(line2, layline);
|
---|
348 | AddFrame(framelow, laylow);
|
---|
349 | }
|
---|
350 |
|
---|
351 | // --------------------------------------------------------------------------
|
---|
352 | //
|
---|
353 | // Constructor
|
---|
354 | //
|
---|
355 | void MGEvtDisplay::AddMenuBar()
|
---|
356 | {
|
---|
357 | //
|
---|
358 | // Add all GUI elements and update the event counter
|
---|
359 | //
|
---|
360 | TGLayoutHints *laymenubar = new TGLayoutHints(kLHintsTop|kLHintsLeft|kLHintsExpandX, 2, 2, 2, 2);
|
---|
361 | TGLayoutHints *laymenuitem = new TGLayoutHints(kLHintsTop|kLHintsLeft, 0, 4, 0, 0);
|
---|
362 | TGLayoutHints *laylinesep = new TGLayoutHints(kLHintsTop|kLHintsExpandX);
|
---|
363 |
|
---|
364 | fList->Add(laymenubar);
|
---|
365 | fList->Add(laymenuitem);
|
---|
366 | fList->Add(laylinesep);
|
---|
367 |
|
---|
368 | TGPopupMenu *filemenu = new TGPopupMenu(gClient->GetRoot());
|
---|
369 | filemenu->AddEntry("Save &As...", kFileSaveAs);
|
---|
370 | filemenu->AddEntry("Save As display.p&s", kFileSaveAsPS);
|
---|
371 | filemenu->AddEntry("Save As display.&eps", kFileSaveAsEPS);
|
---|
372 | filemenu->AddEntry("Save As display.&gif", kFileSaveAsGIF);
|
---|
373 | filemenu->AddEntry("Save As display.&C", kFileSaveAsC);
|
---|
374 | filemenu->AddEntry("Save As display.&root", kFileSaveAsRoot);
|
---|
375 | filemenu->AddSeparator();
|
---|
376 | filemenu->AddEntry("&Print...", kFilePrint);
|
---|
377 | filemenu->AddSeparator();
|
---|
378 | filemenu->AddEntry("E&xit", kClose);
|
---|
379 | filemenu->Associate(this);
|
---|
380 |
|
---|
381 | TGMenuBar *menubar = new TGMenuBar(this, 1, 1, kHorizontalFrame);
|
---|
382 | menubar->AddPopup("&File", filemenu, laymenuitem);
|
---|
383 | AddFrame(menubar, laymenubar);
|
---|
384 |
|
---|
385 | TGHorizontal3DLine *linesep = new TGHorizontal3DLine(this);
|
---|
386 | AddFrame(linesep, laylinesep);
|
---|
387 |
|
---|
388 | fList->Add(filemenu);
|
---|
389 | fList->Add(menubar);
|
---|
390 | fList->Add(linesep);
|
---|
391 | }
|
---|
392 |
|
---|
393 | MGEvtDisplay::MGEvtDisplay(const char *fname, const char *tname,
|
---|
394 | const TGWindow *p, /*const TGWindow *main,*/
|
---|
395 | UInt_t w, UInt_t h)
|
---|
396 | // : TGTransientFrame(p, main, w, h), fInitOk(kFALSE)
|
---|
397 | : TGMainFrame(p, w, h), fInitOk(kFALSE)
|
---|
398 | {
|
---|
399 | //
|
---|
400 | // create an autodelete-list for the gui elements
|
---|
401 | //
|
---|
402 | fList = new TList;
|
---|
403 | fList->SetOwner();
|
---|
404 |
|
---|
405 | //
|
---|
406 | // Setup an empty job, with a reader task only.
|
---|
407 | // All tasks and parameter containers are deleted automatically
|
---|
408 | // (via SetOwner())
|
---|
409 | //
|
---|
410 | MTaskList *tlist = new MTaskList;
|
---|
411 | tlist->SetOwner();
|
---|
412 |
|
---|
413 | MReadMarsFile *read = new MReadMarsFile(tname, fname);
|
---|
414 | read->DisableAutoScheme();
|
---|
415 | tlist->AddToList(read);
|
---|
416 |
|
---|
417 | MParList *plist = new MParList;
|
---|
418 | plist->SetOwner();
|
---|
419 | plist->AddToList(tlist);
|
---|
420 |
|
---|
421 | fEvtLoop = new MEvtLoop;
|
---|
422 | fEvtLoop->SetOwner();
|
---|
423 | fEvtLoop->SetParList(plist);
|
---|
424 |
|
---|
425 | AddMenuBar();
|
---|
426 | AddFrames(fname, tname);
|
---|
427 |
|
---|
428 | SetWMSizeHints(450, 400, 1000, 1000, 10, 10);
|
---|
429 | Move(rand()%100+50, rand()%100+50);
|
---|
430 | }
|
---|
431 |
|
---|
432 | // --------------------------------------------------------------------------
|
---|
433 | //
|
---|
434 | // Destructs the graphical members and the eventloop members
|
---|
435 | //
|
---|
436 | MGEvtDisplay::~MGEvtDisplay()
|
---|
437 | {
|
---|
438 | fEvtLoop->PostProcess();
|
---|
439 | delete fEvtLoop;
|
---|
440 |
|
---|
441 | delete fList;
|
---|
442 | }
|
---|
443 |
|
---|
444 | // --------------------------------------------------------------------------
|
---|
445 | //
|
---|
446 | // The close message is generated by the window manager when its close
|
---|
447 | // window menu item is selected.
|
---|
448 | //
|
---|
449 | void MGEvtDisplay::CloseWindow()
|
---|
450 | {
|
---|
451 | delete this;
|
---|
452 | }
|
---|
453 |
|
---|
454 | void MGEvtDisplay::UpdateMcLabel()
|
---|
455 | {
|
---|
456 | MMcEvt *evt=(MMcEvt*)GetParList()->FindObject("MMcEvt");
|
---|
457 | if (!evt)
|
---|
458 | return;
|
---|
459 |
|
---|
460 | TString txt = " ";
|
---|
461 |
|
---|
462 | switch (evt->GetPartId())
|
---|
463 | {
|
---|
464 | case kGAMMA:
|
---|
465 | txt += "Gamma";
|
---|
466 | break;
|
---|
467 | case kPROTON:
|
---|
468 | txt += "Proton";
|
---|
469 | break;
|
---|
470 | case kHELIUM:
|
---|
471 | txt += "Helium";
|
---|
472 | break;
|
---|
473 | default:
|
---|
474 | txt += "Unknown Particle Id#";
|
---|
475 | txt += evt->GetPartId();
|
---|
476 | }
|
---|
477 |
|
---|
478 | txt += ": E=";
|
---|
479 | txt += (int)(evt->GetEnergy()+.5);
|
---|
480 | txt += "GeV r=";
|
---|
481 | txt += (int)(evt->GetImpact()/100+.5);
|
---|
482 | txt += "m ZA=";
|
---|
483 | txt += (int)(evt->GetTheta()*180/TMath::Pi()+.5);
|
---|
484 | txt += "° ";
|
---|
485 | txt += evt->GetPhotElfromShower();
|
---|
486 | txt += "PhEl";
|
---|
487 |
|
---|
488 | const MRawEvtHeader *hed = (MRawEvtHeader*)GetParList()->FindObject("MRawEvtHeader");
|
---|
489 | if (hed)
|
---|
490 | {
|
---|
491 | txt += " DAQEvt #";
|
---|
492 | txt += hed->GetDAQEvtNumber();
|
---|
493 | }
|
---|
494 |
|
---|
495 | fEvtInfo->SetText(txt);
|
---|
496 |
|
---|
497 | //
|
---|
498 | // Seems to be necessary to newly layout the upper part to display
|
---|
499 | // the whole line of text
|
---|
500 | //
|
---|
501 | TGFrame &f = *(TGFrame*)fEvtInfo->GetParent()->GetParent();
|
---|
502 | f.Layout();
|
---|
503 | f.MapSubwindows();
|
---|
504 | }
|
---|
505 |
|
---|
506 | // --------------------------------------------------------------------------
|
---|
507 | //
|
---|
508 | // Checks if the event number is valid, and if so reads the new event
|
---|
509 | // and updates the display
|
---|
510 | //
|
---|
511 | void MGEvtDisplay::ReadinEvent()
|
---|
512 | {
|
---|
513 | if (GetTaskList()->Process())
|
---|
514 | {
|
---|
515 | GetReader()->DecEventNum();
|
---|
516 | UpdateDisplay();
|
---|
517 | UpdateMcLabel();
|
---|
518 | }
|
---|
519 |
|
---|
520 | fTxtEvtNr->SetText(Form("%d", GetReader()->GetNumEntry()+1));
|
---|
521 | }
|
---|
522 |
|
---|
523 | void MGEvtDisplay::ReadFirstEvent()
|
---|
524 | {
|
---|
525 | fInitOk = fEvtLoop->PreProcess();
|
---|
526 |
|
---|
527 | if (fInitOk)
|
---|
528 | ReadinEvent();
|
---|
529 |
|
---|
530 | TGString *txt = new TGString(Form("out of %d Events", GetReader()->GetEntries()));
|
---|
531 | fNumOfEvts->SetText(txt);
|
---|
532 | }
|
---|
533 |
|
---|
534 | // --------------------------------------------------------------------------
|
---|
535 | //
|
---|
536 | // Opens a save as dialog, and tries to store the canvas
|
---|
537 | // in the given output format
|
---|
538 | //
|
---|
539 | void MGEvtDisplay::SaveAsDialog() const
|
---|
540 | {
|
---|
541 | static const char *gSaveAsTypes[] =
|
---|
542 | {
|
---|
543 | "PostScript", "*.ps",
|
---|
544 | "Encapsulated PostScript", "*.eps",
|
---|
545 | "Gif files", "*.gif",
|
---|
546 | "Macro files", "*.C",
|
---|
547 | "ROOT files", "*.root",
|
---|
548 | "All files", "*",
|
---|
549 | NULL, NULL
|
---|
550 | };
|
---|
551 |
|
---|
552 | static TString dir(".");
|
---|
553 |
|
---|
554 | TGFileInfo fi; // fFileName and fIniDir deleted in ~TGFileInfo
|
---|
555 |
|
---|
556 | fi.fFileTypes = (const char**)gSaveAsTypes;
|
---|
557 | fi.fIniDir = StrDup(dir);
|
---|
558 |
|
---|
559 | new TGFileDialog(fClient->GetRoot(), this, kFDSave, &fi);
|
---|
560 |
|
---|
561 | if (!fi.fFilename)
|
---|
562 | return;
|
---|
563 |
|
---|
564 | dir = fi.fIniDir;
|
---|
565 |
|
---|
566 | if (strstr(fi.fFilename, ".root") ||
|
---|
567 | strstr(fi.fFilename, ".ps") ||
|
---|
568 | strstr(fi.fFilename, ".eps") ||
|
---|
569 | strstr(fi.fFilename, ".gif"))
|
---|
570 | {
|
---|
571 | fCanvas->SaveAs(fi.fFilename);
|
---|
572 | return;
|
---|
573 | }
|
---|
574 | if (strstr(fi.fFilename, ".C"))
|
---|
575 | {
|
---|
576 | fCanvas->SaveSource(fi.fFilename);
|
---|
577 | return;
|
---|
578 | }
|
---|
579 | Warning("SaveAsDialog", "Unknown Extension: %s", fi.fFilename);
|
---|
580 | }
|
---|
581 |
|
---|
582 | // --------------------------------------------------------------------------
|
---|
583 | //
|
---|
584 | // ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
|
---|
585 | //
|
---|
586 | // Processes information from all GUI items.
|
---|
587 | // Selecting an item usually generates an event with 4 parameters.
|
---|
588 | // The first two are packed into msg (first and second bytes).
|
---|
589 | // The other two are parm1 and parm2.
|
---|
590 | //
|
---|
591 | Bool_t MGEvtDisplay::ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
|
---|
592 | {
|
---|
593 | if (GET_MSG(msg)!=kC_TEXTENTRY && GET_MSG(msg)!=kC_COMMAND)
|
---|
594 | return kTRUE;
|
---|
595 |
|
---|
596 | switch(GET_SUBMSG(msg))
|
---|
597 | {
|
---|
598 | case kTE_ENTER:
|
---|
599 | case kCM_BUTTON:
|
---|
600 | if (parm1==kClose)
|
---|
601 | {
|
---|
602 | CloseWindow();
|
---|
603 | return kTRUE;
|
---|
604 | }
|
---|
605 |
|
---|
606 | if (!fInitOk)
|
---|
607 | return kTRUE;
|
---|
608 |
|
---|
609 | switch(GET_SUBMSG(msg))
|
---|
610 | {
|
---|
611 | case kTE_ENTER:
|
---|
612 | if (GetReader()->SetEventNum(atoi(fTxtEvtNr->GetText())-1))
|
---|
613 | ReadinEvent();
|
---|
614 | return kTRUE;
|
---|
615 |
|
---|
616 | case kCM_BUTTON:
|
---|
617 | switch (parm1)
|
---|
618 | {
|
---|
619 | case kEvtPrev:
|
---|
620 | if (GetReader()->DecEventNum())
|
---|
621 | ReadinEvent();
|
---|
622 | return kTRUE;
|
---|
623 |
|
---|
624 | case kEvtNext:
|
---|
625 | if (GetReader()->IncEventNum())
|
---|
626 | ReadinEvent();
|
---|
627 | return kTRUE;
|
---|
628 | }
|
---|
629 | return kTRUE;
|
---|
630 | }
|
---|
631 | return kTRUE;
|
---|
632 |
|
---|
633 | case kCM_MENU:
|
---|
634 | switch (parm1)
|
---|
635 | {
|
---|
636 | case kFileSaveAs:
|
---|
637 | SaveAsDialog();
|
---|
638 | return kTRUE;
|
---|
639 | case kFileSaveAsRoot:
|
---|
640 | fCanvas->SaveAs("display.root");
|
---|
641 | return kTRUE;
|
---|
642 | case kFileSaveAsC:
|
---|
643 | // FIXME: The line opening the canvas is wrong.
|
---|
644 | fCanvas->SaveSource("display.C");
|
---|
645 | return kTRUE;
|
---|
646 | case kFileSaveAsPS:
|
---|
647 | fCanvas->SaveAs("display.ps");
|
---|
648 | return kTRUE;
|
---|
649 | case kFileSaveAsEPS:
|
---|
650 | fCanvas->SaveAs("display.eps");
|
---|
651 | return kTRUE;
|
---|
652 | case kFileSaveAsGIF:
|
---|
653 | fCanvas->SaveAs("display.gif");
|
---|
654 | return kTRUE;
|
---|
655 | case kFilePrint:
|
---|
656 | fCanvas->Print();
|
---|
657 | return kTRUE;
|
---|
658 | case kClose:
|
---|
659 | CloseWindow();
|
---|
660 | return kTRUE;
|
---|
661 | }
|
---|
662 | return kTRUE;
|
---|
663 | }
|
---|
664 | return kTRUE;
|
---|
665 | }
|
---|
666 |
|
---|