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 |
|
---|
144 | top2->AddFrame(fEvtInfo, laystd);
|
---|
145 |
|
---|
146 | //
|
---|
147 | // layout and add frames
|
---|
148 | //
|
---|
149 | TGLayoutHints *laytop1 = new TGLayoutHints(kLHintsTop);
|
---|
150 | fList->Add(laytop1);
|
---|
151 | frame->AddFrame(top1, laytop1);
|
---|
152 | frame->AddFrame(top2, laytop1);
|
---|
153 | }
|
---|
154 |
|
---|
155 | // --------------------------------------------------------------------------
|
---|
156 | //
|
---|
157 | // Add the second part of the top frame: This are the event number controls
|
---|
158 | //
|
---|
159 | void MGEvtDisplay::AddTopFramePart2(TGVerticalFrame *frame)
|
---|
160 | {
|
---|
161 | //
|
---|
162 | // --- the top2 part of the window ---
|
---|
163 | //
|
---|
164 | TGHorizontalFrame *top2 = new TGHorizontalFrame(frame, 300, 100);
|
---|
165 | fList->Add(top2);
|
---|
166 |
|
---|
167 | //
|
---|
168 | // Create the gui elements
|
---|
169 | //
|
---|
170 | TGTextButton *prevevt = new TGTextButton(top2, "<< Previous Event", kEvtPrev);
|
---|
171 | prevevt->Associate(this);
|
---|
172 |
|
---|
173 | TGLabel *evtnr = new TGLabel(top2, new TGString("Event: "));
|
---|
174 |
|
---|
175 | fTxtEvtNr = new TGTextEntry(top2, new TGTextBuffer(100), kEvtNumber);
|
---|
176 | fTxtEvtNr->Resize(60, fTxtEvtNr->GetDefaultHeight());
|
---|
177 | fTxtEvtNr->Associate(this);
|
---|
178 |
|
---|
179 | fNumOfEvts = new TGLabel(top2, "out of Events.");
|
---|
180 |
|
---|
181 | TGTextButton *nextevt = new TGTextButton (top2, "Next Event >>", kEvtNext);
|
---|
182 | nextevt->Associate(this);
|
---|
183 |
|
---|
184 | //
|
---|
185 | // Add gui elements to 'atotodel'
|
---|
186 | //
|
---|
187 | fList->Add(prevevt);
|
---|
188 | fList->Add(evtnr);
|
---|
189 | fList->Add(fTxtEvtNr);
|
---|
190 | fList->Add(fNumOfEvts);
|
---|
191 | fList->Add(nextevt);
|
---|
192 |
|
---|
193 | //
|
---|
194 | // add the gui elements to the frame
|
---|
195 | //
|
---|
196 | TGLayoutHints *laystd = new TGLayoutHints(kLHintsLeft|kLHintsCenterY, 10, 10, 10, 10);
|
---|
197 |
|
---|
198 | fList->Add(laystd);
|
---|
199 |
|
---|
200 | top2->AddFrame(prevevt, laystd);
|
---|
201 | top2->AddFrame(evtnr, laystd);
|
---|
202 | top2->AddFrame(fTxtEvtNr, laystd);
|
---|
203 | top2->AddFrame(fNumOfEvts, laystd);
|
---|
204 | top2->AddFrame(nextevt, laystd);
|
---|
205 |
|
---|
206 | frame->AddFrame(top2, new TGLayoutHints(kLHintsCenterX));
|
---|
207 | }
|
---|
208 |
|
---|
209 | // --------------------------------------------------------------------------
|
---|
210 | //
|
---|
211 | // Add a tab with an embedded canvas for an camera display and return the
|
---|
212 | // pointer to the canvas
|
---|
213 | //
|
---|
214 | TCanvas *MGEvtDisplay::AddTab(TString name)
|
---|
215 | {
|
---|
216 | TGLayoutHints *laycanvas = new TGLayoutHints(kLHintsCenterX|kLHintsCenterY|kLHintsExpandX|kLHintsExpandY);
|
---|
217 | fList->Add(laycanvas);
|
---|
218 |
|
---|
219 | TGCompositeFrame *frame = fEvtDisplay->AddTab(name);
|
---|
220 | TRootEmbeddedCanvas *canvas = new TRootEmbeddedCanvas(name+"Display", frame, 400, 400);
|
---|
221 | frame->AddFrame(canvas, laycanvas);
|
---|
222 | fList->Add(canvas);
|
---|
223 | return canvas->GetCanvas();
|
---|
224 | }
|
---|
225 |
|
---|
226 | // --------------------------------------------------------------------------
|
---|
227 | //
|
---|
228 | // Add the mid frame: This are the two tabs with the canvas in the right one
|
---|
229 | //
|
---|
230 | void MGEvtDisplay::AddMidFrame(TGHorizontalFrame *frame)
|
---|
231 | {
|
---|
232 | //
|
---|
233 | // create tab control
|
---|
234 | //
|
---|
235 | TGTab *tabs = new TGTab(frame, 300, 300);
|
---|
236 |
|
---|
237 | //
|
---|
238 | // Create Tab1
|
---|
239 | //
|
---|
240 | fTab1 = tabs->AddTab("Setup");
|
---|
241 |
|
---|
242 | //
|
---|
243 | // Crete second gui elemet for tab1 (TGVertical Frame)
|
---|
244 | //
|
---|
245 | TGLayoutHints *laytabs = new TGLayoutHints(kLHintsNormal|kLHintsExpandY, 10, 10, 10, 10);
|
---|
246 | frame->AddFrame(tabs, laytabs);
|
---|
247 |
|
---|
248 | //
|
---|
249 | // Create second part of frame
|
---|
250 | //
|
---|
251 | fEvtDisplay = new TGTab(frame, 300, 300);
|
---|
252 |
|
---|
253 | fCanvas=AddTab("Photons");
|
---|
254 |
|
---|
255 | AddTab("Geometry");
|
---|
256 | MGeomCamMagic geom;
|
---|
257 | MCamDisplay *display = new MCamDisplay(&geom);
|
---|
258 | display->Draw();
|
---|
259 | display->DrawPixelNumbers();
|
---|
260 | fList->Add(display);
|
---|
261 |
|
---|
262 | //
|
---|
263 | // Add second part to frame
|
---|
264 | //
|
---|
265 | TGLayoutHints *laydisp = new TGLayoutHints(kLHintsNormal|kLHintsExpandY|kLHintsExpandX, 10, 10, 10, 10);
|
---|
266 | frame->AddFrame(fEvtDisplay, laydisp);
|
---|
267 |
|
---|
268 | //
|
---|
269 | // Now add all gui elements to 'autodel'-list
|
---|
270 | //
|
---|
271 | fList->Add(fEvtDisplay);
|
---|
272 | fList->Add(laydisp);
|
---|
273 | fList->Add(laytabs);
|
---|
274 | }
|
---|
275 |
|
---|
276 | // --------------------------------------------------------------------------
|
---|
277 | //
|
---|
278 | // Add the low frame: These are the buttons Print and Close
|
---|
279 | //
|
---|
280 | void MGEvtDisplay::AddLowFrame(TGHorizontalFrame *frame)
|
---|
281 | {
|
---|
282 | TGTextButton *but = new TGTextButton(frame, "Close", kClose);
|
---|
283 |
|
---|
284 | but->Associate(this);
|
---|
285 |
|
---|
286 | fList->Add(but);
|
---|
287 |
|
---|
288 | TGLayoutHints *laybut = new TGLayoutHints(kLHintsLeft, 10, 10, 10, 10);
|
---|
289 | fList->Add(laybut);
|
---|
290 |
|
---|
291 | frame->AddFrame(but, laybut);
|
---|
292 | }
|
---|
293 |
|
---|
294 | // --------------------------------------------------------------------------
|
---|
295 | //
|
---|
296 | // Create and setup all the three frames and build the window interieur
|
---|
297 | //
|
---|
298 | void MGEvtDisplay::AddFrames(const char *filename, const char *treename)
|
---|
299 | {
|
---|
300 | //
|
---|
301 | // Create the frame elements and add gui elements to it
|
---|
302 | //
|
---|
303 | TGVerticalFrame *frametop = new TGVerticalFrame(this, 300, 100);
|
---|
304 | fList->Add(frametop);
|
---|
305 |
|
---|
306 | AddTopFramePart1(frametop, filename, treename);
|
---|
307 | AddTopFramePart2(frametop);
|
---|
308 |
|
---|
309 | TGLayoutHints *laytop = new TGLayoutHints(kLHintsTop|kLHintsCenterX);
|
---|
310 | fList->Add(laytop);
|
---|
311 |
|
---|
312 | // -----
|
---|
313 |
|
---|
314 | TGHorizontalFrame *framemid = new TGHorizontalFrame(this, 300, 100);
|
---|
315 | fList->Add(framemid);
|
---|
316 |
|
---|
317 | AddMidFrame(framemid);
|
---|
318 |
|
---|
319 | TGLayoutHints *laymid = new TGLayoutHints(kLHintsExpandY|kLHintsExpandX);
|
---|
320 | fList->Add(laymid);
|
---|
321 |
|
---|
322 | //
|
---|
323 | // add frame elements to 'autodel'
|
---|
324 | //
|
---|
325 | TGHorizontal3DLine *line1 = new TGHorizontal3DLine(this);
|
---|
326 | TGHorizontal3DLine *line2 = new TGHorizontal3DLine(this);
|
---|
327 | fList->Add(line1);
|
---|
328 | fList->Add(line2);
|
---|
329 |
|
---|
330 | TGLayoutHints *layline = new TGLayoutHints(kLHintsTop|kLHintsExpandX);
|
---|
331 | fList->Add(layline);
|
---|
332 |
|
---|
333 | // -----
|
---|
334 | TGHorizontalFrame *framelow = new TGHorizontalFrame(this, 300, 100);
|
---|
335 | fList->Add(framelow);
|
---|
336 |
|
---|
337 | AddLowFrame(framelow);
|
---|
338 |
|
---|
339 | TGLayoutHints *laylow = new TGLayoutHints(kLHintsTop);
|
---|
340 | fList->Add(laylow);
|
---|
341 |
|
---|
342 | //
|
---|
343 | // Layout frame elements and add elements to frame
|
---|
344 | //
|
---|
345 | AddFrame(frametop, laytop);
|
---|
346 | AddFrame(line1, layline);
|
---|
347 | AddFrame(framemid, laymid);
|
---|
348 | AddFrame(line2, layline);
|
---|
349 | AddFrame(framelow, laylow);
|
---|
350 | }
|
---|
351 |
|
---|
352 | // --------------------------------------------------------------------------
|
---|
353 | //
|
---|
354 | // Constructor
|
---|
355 | //
|
---|
356 | void MGEvtDisplay::AddMenuBar()
|
---|
357 | {
|
---|
358 | //
|
---|
359 | // Add all GUI elements and update the event counter
|
---|
360 | //
|
---|
361 | TGLayoutHints *laymenubar = new TGLayoutHints(kLHintsTop|kLHintsLeft|kLHintsExpandX, 2, 2, 2, 2);
|
---|
362 | TGLayoutHints *laymenuitem = new TGLayoutHints(kLHintsTop|kLHintsLeft, 0, 4, 0, 0);
|
---|
363 | TGLayoutHints *laylinesep = new TGLayoutHints(kLHintsTop|kLHintsExpandX);
|
---|
364 |
|
---|
365 | fList->Add(laymenubar);
|
---|
366 | fList->Add(laymenuitem);
|
---|
367 | fList->Add(laylinesep);
|
---|
368 |
|
---|
369 | TGPopupMenu *filemenu = new TGPopupMenu(gClient->GetRoot());
|
---|
370 | filemenu->AddEntry("Save &As...", kFileSaveAs);
|
---|
371 | filemenu->AddEntry("Save As display.p&s", kFileSaveAsPS);
|
---|
372 | filemenu->AddEntry("Save As display.&eps", kFileSaveAsEPS);
|
---|
373 | filemenu->AddEntry("Save As display.&gif", kFileSaveAsGIF);
|
---|
374 | filemenu->AddEntry("Save As display.&C", kFileSaveAsC);
|
---|
375 | filemenu->AddEntry("Save As display.&root", kFileSaveAsRoot);
|
---|
376 | filemenu->AddSeparator();
|
---|
377 | filemenu->AddEntry("&Print...", kFilePrint);
|
---|
378 | filemenu->AddSeparator();
|
---|
379 | filemenu->AddEntry("E&xit", kClose);
|
---|
380 | filemenu->Associate(this);
|
---|
381 |
|
---|
382 | TGMenuBar *menubar = new TGMenuBar(this, 1, 1, kHorizontalFrame);
|
---|
383 | menubar->AddPopup("&File", filemenu, laymenuitem);
|
---|
384 | AddFrame(menubar, laymenubar);
|
---|
385 |
|
---|
386 | TGHorizontal3DLine *linesep = new TGHorizontal3DLine(this);
|
---|
387 | AddFrame(linesep, laylinesep);
|
---|
388 |
|
---|
389 | fList->Add(filemenu);
|
---|
390 | fList->Add(menubar);
|
---|
391 | fList->Add(linesep);
|
---|
392 | }
|
---|
393 |
|
---|
394 | MGEvtDisplay::MGEvtDisplay(const char *fname, const char *tname,
|
---|
395 | const TGWindow *p, const TGWindow *main,
|
---|
396 | UInt_t w, UInt_t h)
|
---|
397 | : TGTransientFrame(p, main, 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 | }
|
---|
476 |
|
---|
477 | txt += ": E=";
|
---|
478 | txt += (int)(evt->GetEnergy()+.5);
|
---|
479 | txt += "GeV r=";
|
---|
480 | txt += (int)(evt->GetImpact()/100+.5);
|
---|
481 | txt += "m ZA=";
|
---|
482 | txt += (int)(evt->GetTheta()*180/TMath::Pi()+.5);
|
---|
483 | txt += "° ";
|
---|
484 | txt += evt->GetPhotElfromShower();
|
---|
485 | txt += "PhEl";
|
---|
486 |
|
---|
487 | const MRawEvtHeader *hed = (MRawEvtHeader*)GetParList()->FindObject("MRawEvtHeader");
|
---|
488 | if (hed)
|
---|
489 | {
|
---|
490 | txt += " DAQEvt #";
|
---|
491 | txt += hed->GetDAQEvtNumber();
|
---|
492 | }
|
---|
493 |
|
---|
494 | fEvtInfo->SetText(txt);
|
---|
495 | }
|
---|
496 |
|
---|
497 | // --------------------------------------------------------------------------
|
---|
498 | //
|
---|
499 | // Checks if the event number is valid, and if so reads the new event
|
---|
500 | // and updates the display
|
---|
501 | //
|
---|
502 | void MGEvtDisplay::ReadinEvent()
|
---|
503 | {
|
---|
504 | if (GetTaskList()->Process())
|
---|
505 | {
|
---|
506 | GetReader()->DecEventNum();
|
---|
507 | UpdateDisplay();
|
---|
508 | UpdateMcLabel();
|
---|
509 | }
|
---|
510 |
|
---|
511 | fTxtEvtNr->SetText(Form("%d", GetReader()->GetEventNum()+1));
|
---|
512 | }
|
---|
513 |
|
---|
514 | void MGEvtDisplay::ReadFirstEvent()
|
---|
515 | {
|
---|
516 | fInitOk = fEvtLoop->PreProcess();
|
---|
517 |
|
---|
518 | if (fInitOk)
|
---|
519 | ReadinEvent();
|
---|
520 |
|
---|
521 | TGString *txt = new TGString(Form("out of %d Events", GetReader()->GetEntries()));
|
---|
522 | fNumOfEvts->SetText(txt);
|
---|
523 | }
|
---|
524 |
|
---|
525 | // --------------------------------------------------------------------------
|
---|
526 | //
|
---|
527 | // Opens a save as dialog, and tries to store the canvas
|
---|
528 | // in the given output format
|
---|
529 | //
|
---|
530 | void MGEvtDisplay::SaveAsDialog() const
|
---|
531 | {
|
---|
532 | static const char *gSaveAsTypes[] =
|
---|
533 | {
|
---|
534 | "PostScript", "*.ps",
|
---|
535 | "Encapsulated PostScript", "*.eps",
|
---|
536 | "Gif files", "*.gif",
|
---|
537 | "Macro files", "*.C",
|
---|
538 | "ROOT files", "*.root",
|
---|
539 | "All files", "*",
|
---|
540 | NULL, NULL
|
---|
541 | };
|
---|
542 |
|
---|
543 | static TString dir(".");
|
---|
544 |
|
---|
545 | TGFileInfo fi; // fFileName and fIniDir deleted in ~TGFileInfo
|
---|
546 |
|
---|
547 | fi.fFileTypes = (const char**)gSaveAsTypes;
|
---|
548 | fi.fIniDir = StrDup(dir);
|
---|
549 |
|
---|
550 | new TGFileDialog(fClient->GetRoot(), this, kFDSave, &fi);
|
---|
551 |
|
---|
552 | if (!fi.fFilename)
|
---|
553 | return;
|
---|
554 |
|
---|
555 | dir = fi.fIniDir;
|
---|
556 |
|
---|
557 | if (strstr(fi.fFilename, ".root") ||
|
---|
558 | strstr(fi.fFilename, ".ps") ||
|
---|
559 | strstr(fi.fFilename, ".eps") ||
|
---|
560 | strstr(fi.fFilename, ".gif"))
|
---|
561 | {
|
---|
562 | fCanvas->SaveAs(fi.fFilename);
|
---|
563 | return;
|
---|
564 | }
|
---|
565 | if (strstr(fi.fFilename, ".C"))
|
---|
566 | {
|
---|
567 | fCanvas->SaveSource(fi.fFilename);
|
---|
568 | return;
|
---|
569 | }
|
---|
570 | Warning("SaveAsDialog", "Unknown Extension: %s", fi.fFilename);
|
---|
571 | }
|
---|
572 |
|
---|
573 | // --------------------------------------------------------------------------
|
---|
574 | //
|
---|
575 | // ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
|
---|
576 | //
|
---|
577 | // Processes information from all GUI items.
|
---|
578 | // Selecting an item usually generates an event with 4 parameters.
|
---|
579 | // The first two are packed into msg (first and second bytes).
|
---|
580 | // The other two are parm1 and parm2.
|
---|
581 | //
|
---|
582 | Bool_t MGEvtDisplay::ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
|
---|
583 | {
|
---|
584 | if (GET_MSG(msg)!=kC_TEXTENTRY && GET_MSG(msg)!=kC_COMMAND)
|
---|
585 | return kTRUE;
|
---|
586 |
|
---|
587 | switch(GET_SUBMSG(msg))
|
---|
588 | {
|
---|
589 | case kTE_ENTER:
|
---|
590 | case kCM_BUTTON:
|
---|
591 | if (parm1==kClose)
|
---|
592 | {
|
---|
593 | CloseWindow();
|
---|
594 | return kTRUE;
|
---|
595 | }
|
---|
596 |
|
---|
597 | if (!fInitOk)
|
---|
598 | return kTRUE;
|
---|
599 |
|
---|
600 | switch(GET_SUBMSG(msg))
|
---|
601 | {
|
---|
602 | case kTE_ENTER:
|
---|
603 | if (GetReader()->SetEventNum(atoi(fTxtEvtNr->GetText())-1))
|
---|
604 | ReadinEvent();
|
---|
605 | return kTRUE;
|
---|
606 |
|
---|
607 | case kCM_BUTTON:
|
---|
608 | switch (parm1)
|
---|
609 | {
|
---|
610 | case kEvtPrev:
|
---|
611 | if (GetReader()->DecEventNum())
|
---|
612 | ReadinEvent();
|
---|
613 | return kTRUE;
|
---|
614 |
|
---|
615 | case kEvtNext:
|
---|
616 | if (GetReader()->IncEventNum())
|
---|
617 | ReadinEvent();
|
---|
618 | return kTRUE;
|
---|
619 | }
|
---|
620 | return kTRUE;
|
---|
621 | }
|
---|
622 | return kTRUE;
|
---|
623 |
|
---|
624 | case kCM_MENU:
|
---|
625 | switch (parm1)
|
---|
626 | {
|
---|
627 | case kFileSaveAs:
|
---|
628 | SaveAsDialog();
|
---|
629 | return kTRUE;
|
---|
630 | case kFileSaveAsRoot:
|
---|
631 | fCanvas->SaveAs("display.root");
|
---|
632 | return kTRUE;
|
---|
633 | case kFileSaveAsC:
|
---|
634 | // FIXME: The line opening the canvas is wrong.
|
---|
635 | fCanvas->SaveSource("display.C");
|
---|
636 | return kTRUE;
|
---|
637 | case kFileSaveAsPS:
|
---|
638 | fCanvas->SaveAs("display.ps");
|
---|
639 | return kTRUE;
|
---|
640 | case kFileSaveAsEPS:
|
---|
641 | fCanvas->SaveAs("display.eps");
|
---|
642 | return kTRUE;
|
---|
643 | case kFileSaveAsGIF:
|
---|
644 | fCanvas->SaveAs("display.gif");
|
---|
645 | return kTRUE;
|
---|
646 | case kFilePrint:
|
---|
647 | fCanvas->Print();
|
---|
648 | return kTRUE;
|
---|
649 | case kClose:
|
---|
650 | CloseWindow();
|
---|
651 | return kTRUE;
|
---|
652 | }
|
---|
653 | return kTRUE;
|
---|
654 | }
|
---|
655 | return kTRUE;
|
---|
656 | }
|
---|
657 |
|
---|