1 #include "AliMUONMchViewApplication.h"
3 #include "AliCDBManager.h"
4 #include "AliCodeTimer.h"
6 #include "AliMUONPainterDataSourceFrame.h"
7 #include "AliMUONPainterHelper.h"
8 #include "AliMUONPainterMasterFrame.h"
9 #include "AliMUONPainterRegistry.h"
10 #include "AliMUONVTrackerData.h"
11 #include <Riostream.h>
16 #include <TGFileDialog.h>
24 /// \class AliMUONMchViewApplication
26 /// Main class for the mchview program
28 ///\author Laurent Aphecetche, Subatech
31 ClassImp(AliMUONMchViewApplication)
34 const Int_t AliMUONMchViewApplication::fgkFILESAVEAS(1);
35 const Int_t AliMUONMchViewApplication::fgkFILEOPEN(2);
36 const Int_t AliMUONMchViewApplication::fgkFILEEXIT(3);
38 //______________________________________________________________________________
39 AliMUONMchViewApplication::AliMUONMchViewApplication(const char* name,
40 int* argc, char** argv,
43 : TRint(name,argc,argv),
48 /// wfraction,hfraction are the fractions of display width and height
49 /// we want to draw on
51 UInt_t dw = gClient->GetDisplayWidth();
52 UInt_t dh = gClient->GetDisplayHeight();
54 UInt_t w = (UInt_t)(wfraction*dw);
55 UInt_t h = (UInt_t)(hfraction*dh);
57 fMainFrame = new TGMainFrame(gClient->GetRoot(),w,h);
63 // h -= 60; // menubar
65 TGTab* tabs = new TGTab(fMainFrame,w,h);
67 TGCompositeFrame* t = tabs->AddTab("Painter Master Frame");
69 AliMUONPainterMasterFrame* pf =
70 new AliMUONPainterMasterFrame(t,t->GetWidth()-kbs*2,t->GetHeight()-kbs*2);
72 t->AddFrame(pf, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY,kbs,kbs,kbs,kbs));
74 t = tabs->AddTab("Data Sources");
76 AliMUONPainterDataSourceFrame* dsf =
77 new AliMUONPainterDataSourceFrame(t,t->GetWidth()-kbs*2,t->GetHeight()-kbs*2);
79 t->AddFrame(dsf,new TGLayoutHints(kLHintsExpandX | kLHintsExpandY,kbs,kbs,kbs,kbs));
81 fMainFrame->AddFrame(tabs,new TGLayoutHints(kLHintsExpandX | kLHintsExpandY,0,0,0,0));
83 fMainFrame->SetWindowName("mchview - Visualization of MUON Tracker detector");
85 fMainFrame->MapSubwindows();
87 fMainFrame->MapWindow();
89 fMainFrame->Connect("CloseWindow()","AliMUONMchViewApplication",this,"Terminate()");
91 UInt_t x = dw/2 - w/2;
94 fMainFrame->MoveResize(x, y, w, h);
95 fMainFrame->SetWMPosition(x, y);
97 fMainFrame->SetWMSizeHints(w,h,w,h,0,0);
100 //______________________________________________________________________________
101 AliMUONMchViewApplication::~AliMUONMchViewApplication()
106 //______________________________________________________________________________
108 AliMUONMchViewApplication::CreateMenuBar(UInt_t w)
110 /// Create the application menu bar
112 TGPopupMenu* file = new TGPopupMenu(gClient->GetRoot());
114 file->AddEntry("&Open...",fgkFILEOPEN);
115 file->AddEntry("&Save As...",fgkFILESAVEAS);
116 file->AddEntry("&Exit",fgkFILEEXIT);
118 file->Connect("Activated(Int_t)","AliMUONMchViewApplication",this,"HandleMenu(Int_t)");
120 TGMenuBar* bar = new TGMenuBar(fMainFrame,w);
122 bar->AddPopup("&File",file,new TGLayoutHints(kLHintsLeft|kLHintsTop));
124 fMainFrame->AddFrame(bar,new TGLayoutHints(kLHintsLeft|kLHintsExpandX));
126 AliMUONPainterRegistry::Instance()->SetMenuBar(bar);
129 //______________________________________________________________________________
131 AliMUONMchViewApplication::HandleMenu(Int_t i)
133 /// Handle the click of one menu item
151 //______________________________________________________________________________
153 AliMUONMchViewApplication::Open()
159 new TGFileDialog(gClient->GetRoot(),gClient->GetRoot(),
162 Open(gSystem->ExpandPathName(Form("%s",fileInfo.fFilename)));
165 //______________________________________________________________________________
167 AliMUONMchViewApplication::Open(const char* filename)
169 /// Open a given file containing saved VTrackerData objects
173 TList* keys = f.GetListOfKeys();
178 while ( ( k = static_cast<TKey*>(next()) ) )
180 TObject* object = k->ReadObj();
182 if ( object->InheritsFrom("AliMUONVTrackerData") )
184 AliMUONVTrackerData* data = static_cast<AliMUONVTrackerData*>(object);
187 AliMUONPainterRegistry::Instance()->Register(data);
194 //______________________________________________________________________________
196 AliMUONMchViewApplication::Save()
198 /// Open "Save VTrackerData objects to file" dialog
202 new TGFileDialog(gClient->GetRoot(),gClient->GetRoot(),
205 Save(gSystem->ExpandPathName(Form("%s",fileInfo.fFilename)));
208 //______________________________________________________________________________
210 AliMUONMchViewApplication::Save(const char* filename)
212 /// Save VTrackerData objects into file of given name
214 AliMUONPainterRegistry* reg = AliMUONPainterRegistry::Instance();
216 TFile f(filename,"RECREATE");
218 for ( Int_t i = 0; i < reg->NumberOfDataSources(); ++i )
220 AliMUONVTrackerData* data = reg->DataSource(i);