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 | ! Author(s): Javier Rico 05/2004 <mailto:jrico@ifae.es>
|
---|
18 | !
|
---|
19 | ! Copyright: MAGIC Software Development, 2000-2004
|
---|
20 | !
|
---|
21 | !
|
---|
22 | \* ======================================================================== */
|
---|
23 |
|
---|
24 | //////////////////////////////////////////////////////////////////////////////
|
---|
25 | //
|
---|
26 | // MDisplay
|
---|
27 | //
|
---|
28 | // Class to display camera events (MCamEvent)
|
---|
29 | // You can set an event-by-event display with pause between two consecutive
|
---|
30 | // events. You can set an output PS file.
|
---|
31 | //
|
---|
32 | // Input containers (to be provided to the constructor):
|
---|
33 | //
|
---|
34 | // MCamEvent
|
---|
35 | // MGeomCam
|
---|
36 | //
|
---|
37 | // Output containers:
|
---|
38 | //
|
---|
39 | //
|
---|
40 | //////////////////////////////////////////////////////////////////////////////
|
---|
41 |
|
---|
42 | #include <fstream>
|
---|
43 | #include <math.h>
|
---|
44 |
|
---|
45 | #include "TCanvas.h"
|
---|
46 | #include "TPostScript.h"
|
---|
47 |
|
---|
48 | #include "MParList.h"
|
---|
49 | #include "MDisplay.h"
|
---|
50 | #include "MCamEvent.h"
|
---|
51 | #include "MGeomCam.h"
|
---|
52 | #include "MHCamera.h"
|
---|
53 |
|
---|
54 | #include "MLog.h"
|
---|
55 | #include "MLogManip.h"
|
---|
56 |
|
---|
57 | ClassImp(MDisplay);
|
---|
58 |
|
---|
59 | using namespace std;
|
---|
60 |
|
---|
61 | static const TString gsDefName = "MDisplay";
|
---|
62 | static const TString gsDefTitle = "Camera display task";
|
---|
63 | static const TString gsDefPSFileName = "display.ps";
|
---|
64 |
|
---|
65 | // -------------------------------------------------------------------------
|
---|
66 | //
|
---|
67 | // Constructor. Need to provide the MCamEvent container to be displayed <event>
|
---|
68 | // and camera geometry <geom>. Also the display type <type> can be specified
|
---|
69 | // (see the MHCamera documentation for more details)
|
---|
70 | //
|
---|
71 | MDisplay::MDisplay(MCamEvent* event, MGeomCam* geom, Int_t type, const char* name, const char* title)
|
---|
72 | : fGeomCam(geom), fCamEvent(event), fCanvas(NULL), fPSFile(NULL), fDisplayType(type), fCreatePSFile(kFALSE), fPause(kTRUE)
|
---|
73 | {
|
---|
74 | fName = name ? name : gsDefName.Data();
|
---|
75 | fTitle = title ? title : gsDefTitle.Data();
|
---|
76 |
|
---|
77 | fDisplay = new MHCamera(*geom);
|
---|
78 | fDisplay->SetPrettyPalette();
|
---|
79 |
|
---|
80 | fPSFileName = gsDefPSFileName;
|
---|
81 | }
|
---|
82 | // -------------------------------------------------------------------------
|
---|
83 | //
|
---|
84 | // Destructor
|
---|
85 | //
|
---|
86 | MDisplay::~MDisplay()
|
---|
87 | {
|
---|
88 | delete fDisplay;
|
---|
89 | if(fCanvas)
|
---|
90 | delete fCanvas;
|
---|
91 | if(fPSFile)
|
---|
92 | delete fPSFile;
|
---|
93 | }
|
---|
94 |
|
---|
95 | // -------------------------------------------------------------------------
|
---|
96 | //
|
---|
97 | // Create the canvas, eventually set the batch mode and open ps file
|
---|
98 | //
|
---|
99 | Int_t MDisplay::PreProcess(MParList* pList)
|
---|
100 | {
|
---|
101 | fCanvas = new TCanvas("myCanvas","Event Display",600,600);
|
---|
102 | if(fCreatePSFile)
|
---|
103 | fPSFile = new TPostScript(fPSFileName,111);
|
---|
104 | if(!fPause)
|
---|
105 | fCanvas->SetBatch();
|
---|
106 | fCanvas->cd(1);
|
---|
107 | fDisplay->Draw();
|
---|
108 |
|
---|
109 | return kTRUE;
|
---|
110 | }
|
---|
111 |
|
---|
112 | // -------------------------------------------------------------------------
|
---|
113 | //
|
---|
114 | // Set the new containt of the camera event and update the display.
|
---|
115 | // Set new page if ps file is requested
|
---|
116 | // Pause execution if event-by-event display is chosen
|
---|
117 | //
|
---|
118 | Int_t MDisplay::Process()
|
---|
119 | {
|
---|
120 | // new page in ps file
|
---|
121 | if(fPSFile)
|
---|
122 | fPSFile->NewPage();
|
---|
123 |
|
---|
124 | // update the display contents
|
---|
125 | fDisplay->SetCamContent(*fCamEvent);
|
---|
126 | fCanvas->GetPad(1)->Modified();
|
---|
127 | fCanvas->GetPad(1)->Update();
|
---|
128 |
|
---|
129 | // pause execution
|
---|
130 | if(fPause)
|
---|
131 | {
|
---|
132 | cout << "Type 'q' to exit, <return> to go on: ";
|
---|
133 | TString input;
|
---|
134 | input =cin.get();
|
---|
135 |
|
---|
136 | if (input=='q')
|
---|
137 | return kFALSE;
|
---|
138 | }
|
---|
139 |
|
---|
140 | return kTRUE;
|
---|
141 | }
|
---|
142 |
|
---|
143 | // -------------------------------------------------------------------------
|
---|
144 | //
|
---|
145 | // Close ps file if it was open
|
---|
146 | //
|
---|
147 | Int_t MDisplay::PostProcess()
|
---|
148 | {
|
---|
149 | if(fPSFile) fPSFile->Close();
|
---|
150 | return kTRUE;
|
---|
151 | }
|
---|