source: branches/removing_cpp11_features/mmain/MOnlineDisplay.cc

Last change on this file was 4460, checked in by tbretz, 20 years ago
*** empty log message ***
File size: 6.8 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, 11/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
19!
20! Copyright: MAGIC Software Development, 2000-2003
21!
22!
23\* ======================================================================== */
24#include "MOnlineDisplay.h"
25
26//
27// C-lib
28//
29#include <stdlib.h> // atoi
30
31//
32// root
33//
34#include <TList.h> // TList::Add
35#include <TStyle.h> // gStyle->SetOptStat
36#include <TCanvas.h> // TCanvas::cd
37
38//
39// root GUI
40//
41#include <TGLabel.h> // TGLabel
42#include <TGButton.h> // TGPictureButton
43#include <TGSlider.h> // TGSlider
44#include <TG3DLine.h> // TGHorizontal3DLine
45#include <TGTextEntry.h> // TGTextEntry
46#include <TGButtonGroup.h> // TGVButtonGroup
47#include <TRootEmbeddedCanvas.h> // TRootEmbeddedCanvas
48
49//
50// General
51//
52#include "MGList.h" // MGList
53
54#include "MParList.h" // MParList::AddToList
55#include "MEvtLoop.h" // MEvtLoop::GetParList
56#include "MTaskList.h" // MTaskList::AddToList
57
58//
59// Tasks
60//
61#include "MReadMarsFile.h" // MReadMarsFile
62#include "MGeomApply.h" // MGeomApply
63#include "MFDataMember.h" // MFDataMember
64#include "MMcPedestalCopy.h" // MMcPedestalCopy
65#include "MMcPedestalNSBAdd.h" // MMcPedestalNSBAdd
66#include "MCerPhotCalc.h" // MCerPhotCalc
67#include "MCerPhotAnal2.h" // MCerPhotAnal2
68#include "MImgCleanStd.h" // MImgCleanStd
69#include "MHillasCalc.h" // MHillasCalc
70#include "MHillasSrcCalc.h" // MHillasSrcCalc
71#include "MFillH.h" // MFillH
72#include "MGTask.h" // MGTask
73
74//
75// Container
76//
77#include "MHEvent.h" // MHEvent
78#include "MHCamera.h" // MHCamera
79#include "MRawEvtData.h" // MRawEvtData
80
81ClassImp(MOnlineDisplay);
82
83// --------------------------------------------------------------------------
84//
85// Constructor.
86//
87MOnlineDisplay::MOnlineDisplay() : MStatusDisplay(), fTask(0)
88{
89 //
90 // Add MOnlineDisplay GUI elements to the display
91 //
92 AddUserFrame();
93
94 //
95 // Show new part of the window, resize to correct aspect ratio
96 //
97 // FIXME: This should be done by MStatusDisplay automatically
98 Resize(GetWidth(), GetHeight() + fUserFrame->GetDefaultHeight());
99 SetWindowName("Online Display");
100 MapSubwindows();
101}
102
103// --------------------------------------------------------------------------
104//
105// Add the top part of the frame: This is filename and treename display
106//
107void MOnlineDisplay::AddTopFramePart1(TGCompositeFrame *vf1)
108{
109 TGLabel *file = new TGLabel(vf1, new TGString("Magic Online Analysis -- MONA"));
110 TGLayoutHints *laystd = new TGLayoutHints(kLHintsCenterX, 5, 5);
111 fList->Add(file);
112 fList->Add(laystd);
113 vf1->AddFrame(file, laystd);
114}
115
116// --------------------------------------------------------------------------
117//
118// Add the second part of the top frame: This are the event number controls
119//
120void MOnlineDisplay::AddTopFramePart2(TGCompositeFrame *vf1)
121{
122 //
123 // --- the top2 part of the window ---
124 //
125 TGHorizontalFrame *top2 = new TGHorizontalFrame(vf1, 1, 1);
126 fList->Add(top2);
127
128 //
129 // Create the gui elements
130 //
131 TGTextButton *freeze = new TGTextButton(top2, " Freeze ", kFreeze);
132 freeze->SetUserData(freeze);
133 freeze->Associate(this);
134 freeze->SetToolTipText("Freeze the current Event");
135
136 fList->Add(freeze);
137
138 //
139 // add the gui elements to the frame
140 //
141 TGLayoutHints *laystd = new TGLayoutHints(kLHintsLeft|kLHintsCenterY, 5, 5);
142 fList->Add(laystd);
143
144 top2->AddFrame(freeze, laystd);
145
146 TGLayoutHints *laystd2 = new TGLayoutHints(kLHintsCenterX, 5, 5, 5, 5);
147 fList->Add(laystd2);
148 vf1->AddFrame(top2, laystd2);
149
150 //
151 // Add trailing line...
152 //
153 TGHorizontal3DLine *line = new TGHorizontal3DLine(vf1);
154 TGLayoutHints *layline = new TGLayoutHints(kLHintsExpandX);
155 fList->Add(line);
156 fList->Add(layline);
157 vf1->AddFrame(line, layline);
158}
159
160// --------------------------------------------------------------------------
161//
162// Add the user frame part of the display
163//
164void MOnlineDisplay::AddUserFrame()
165{
166 fUserFrame->ChangeOptions(kHorizontalFrame);
167
168 // Slider
169 TGVSlider *slider = new TGVSlider(fUserFrame, 1, kSlider1, kSlider);
170 slider->SetRange(10, 300);
171 slider->SetScale(15);
172 slider->SetPosition(10);
173 slider->Associate(this);
174 //slider->SetToolTipText("Change the update frequency of the event display (1-30s)");
175
176 // frame1/2
177 TGCompositeFrame *vf1 = new TGVerticalFrame(fUserFrame, 1, 1);
178 TGCompositeFrame *vf2 = new TGVerticalFrame(fUserFrame, 1, 1);
179
180 AddTopFramePart1(vf1);
181 AddTopFramePart2(vf1);
182
183 // create root embedded canvas and add it to the tab
184 TRootEmbeddedCanvas *ec = new TRootEmbeddedCanvas("Slices", vf2, vf1->GetDefaultHeight()*3/2, vf1->GetDefaultHeight(), 0);
185 vf2->AddFrame(ec);
186 fList->Add(ec);
187
188 // set background and border mode of the canvas
189 fCanvas = ec->GetCanvas();
190 fCanvas->SetBorderMode(0);
191 gROOT->GetListOfCanvases()->Add(fCanvas);
192 //fCanvas->SetBorderSize(1);
193 //fCanvas->SetBit(kNoContextMenu);
194 //fCanvas->SetFillColor(16);
195
196 // layout
197 TGLayoutHints *lays = new TGLayoutHints(kLHintsExpandY);
198 TGLayoutHints *lay = new TGLayoutHints(kLHintsExpandX);
199 fUserFrame->AddFrame(slider, lays);
200 fUserFrame->AddFrame(vf1, lay);
201 fUserFrame->AddFrame(vf2);
202
203 fList->Add(lay);
204 fList->Add(lays);
205 fList->Add(vf1);
206 fList->Add(vf2);
207 fList->Add(slider);
208}
209
210// --------------------------------------------------------------------------
211//
212// ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
213//
214// Processes information from all GUI items.
215// Selecting an item usually generates an event with 4 parameters.
216// The first two are packed into msg (first and second bytes).
217// The other two are parm1 and parm2.
218//
219Bool_t MOnlineDisplay::ProcessMessage(Long_t msg, Long_t mp1, Long_t mp2)
220{
221 if (fTask && fTask->ProcessMessage(GET_MSG(msg), GET_SUBMSG(msg), mp1, mp2))
222 return kTRUE;
223
224 return MStatusDisplay::ProcessMessage(msg, mp1, mp2);
225}
Note: See TracBrowser for help on using the repository browser.