source: trunk/MagicSoft/Mars/mmain/MOnlineDisplay.cc@ 2625

Last change on this file since 2625 was 2578, checked in by tbretz, 21 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 "MBlindPixelCalc.h" // MBlindPixelCalc
72#include "MFillH.h" // MFillH
73#include "MGTask.h" // MGTask
74
75//
76// Container
77//
78#include "MHEvent.h" // MHEvent
79#include "MHCamera.h" // MHCamera
80#include "MRawEvtData.h" // MRawEvtData
81
82ClassImp(MOnlineDisplay);
83
84// --------------------------------------------------------------------------
85//
86// Constructor.
87//
88MOnlineDisplay::MOnlineDisplay() : MStatusDisplay(), fTask(0)
89{
90 //
91 // Add MOnlineDisplay GUI elements to the display
92 //
93 AddUserFrame();
94
95 //
96 // Show new part of the window, resize to correct aspect ratio
97 //
98 // FIXME: This should be done by MStatusDisplay automatically
99 Resize(GetWidth(), GetHeight() + fUserFrame->GetDefaultHeight());
100 SetWindowName("Online Display");
101 MapSubwindows();
102}
103
104// --------------------------------------------------------------------------
105//
106// Add the top part of the frame: This is filename and treename display
107//
108void MOnlineDisplay::AddTopFramePart1(TGCompositeFrame *vf1)
109{
110 TGLabel *file = new TGLabel(vf1, new TGString("Magic Online Analysis -- MONA"));
111 TGLayoutHints *laystd = new TGLayoutHints(kLHintsCenterX, 5, 5);
112 fList->Add(file);
113 fList->Add(laystd);
114 vf1->AddFrame(file, laystd);
115}
116
117// --------------------------------------------------------------------------
118//
119// Add the second part of the top frame: This are the event number controls
120//
121void MOnlineDisplay::AddTopFramePart2(TGCompositeFrame *vf1)
122{
123 //
124 // --- the top2 part of the window ---
125 //
126 TGHorizontalFrame *top2 = new TGHorizontalFrame(vf1, 1, 1);
127 fList->Add(top2);
128
129 //
130 // Create the gui elements
131 //
132 TGTextButton *freeze = new TGTextButton(top2, " Freeze ", kFreeze);
133 freeze->SetUserData(freeze);
134 freeze->Associate(this);
135 freeze->SetToolTipText("Freeze the current Event");
136
137 fList->Add(freeze);
138
139 //
140 // add the gui elements to the frame
141 //
142 TGLayoutHints *laystd = new TGLayoutHints(kLHintsLeft|kLHintsCenterY, 5, 5);
143 fList->Add(laystd);
144
145 top2->AddFrame(freeze, laystd);
146
147 TGLayoutHints *laystd2 = new TGLayoutHints(kLHintsCenterX, 5, 5, 5, 5);
148 fList->Add(laystd2);
149 vf1->AddFrame(top2, laystd2);
150
151 //
152 // Add trailing line...
153 //
154 TGHorizontal3DLine *line = new TGHorizontal3DLine(vf1);
155 TGLayoutHints *layline = new TGLayoutHints(kLHintsExpandX);
156 fList->Add(line);
157 fList->Add(layline);
158 vf1->AddFrame(line, layline);
159}
160
161// --------------------------------------------------------------------------
162//
163// Add the user frame part of the display
164//
165void MOnlineDisplay::AddUserFrame()
166{
167 fUserFrame->ChangeOptions(kHorizontalFrame);
168
169 // Slider
170 TGVSlider *slider = new TGVSlider(fUserFrame, 1, kSlider1, kSlider);
171 slider->SetRange(10, 300);
172 slider->SetScale(15);
173 slider->SetPosition(10);
174 slider->Associate(this);
175 //slider->SetToolTipText("Change the update frequency of the event display (1-30s)");
176
177 // frame1/2
178 TGCompositeFrame *vf1 = new TGVerticalFrame(fUserFrame, 1, 1);
179 TGCompositeFrame *vf2 = new TGVerticalFrame(fUserFrame, 1, 1);
180
181 AddTopFramePart1(vf1);
182 AddTopFramePart2(vf1);
183
184 // create root embedded canvas and add it to the tab
185 TRootEmbeddedCanvas *ec = new TRootEmbeddedCanvas("Slices", vf2, vf1->GetDefaultHeight()*3/2, vf1->GetDefaultHeight(), 0);
186 vf2->AddFrame(ec);
187 fList->Add(ec);
188
189 // set background and border mode of the canvas
190 fCanvas = ec->GetCanvas();
191 fCanvas->SetBorderMode(0);
192 gROOT->GetListOfCanvases()->Add(fCanvas);
193 //fCanvas->SetBorderSize(1);
194 //fCanvas->SetBit(kNoContextMenu);
195 //fCanvas->SetFillColor(16);
196
197 // layout
198 TGLayoutHints *lays = new TGLayoutHints(kLHintsExpandY);
199 TGLayoutHints *lay = new TGLayoutHints(kLHintsExpandX);
200 fUserFrame->AddFrame(slider, lays);
201 fUserFrame->AddFrame(vf1, lay);
202 fUserFrame->AddFrame(vf2);
203
204 fList->Add(lay);
205 fList->Add(lays);
206 fList->Add(vf1);
207 fList->Add(vf2);
208 fList->Add(slider);
209}
210
211// --------------------------------------------------------------------------
212//
213// ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
214//
215// Processes information from all GUI items.
216// Selecting an item usually generates an event with 4 parameters.
217// The first two are packed into msg (first and second bytes).
218// The other two are parm1 and parm2.
219//
220Bool_t MOnlineDisplay::ProcessMessage(Long_t msg, Long_t mp1, Long_t mp2)
221{
222 if (fTask && fTask->ProcessMessage(GET_MSG(msg), GET_SUBMSG(msg), mp1, mp2))
223 return kTRUE;
224
225 return MStatusDisplay::ProcessMessage(msg, mp1, mp2);
226}
Note: See TracBrowser for help on using the repository browser.