Update data QA
[u/mrichter/AliRoot.git] / TPC / AliTPCCalibViewerGUIAlarms.cxx
CommitLineData
949d8707 1
2#include <TGClient.h>
3#include <TGSplitter.h>
4#include <TGListTree.h>
5#include <TGTextEntry.h>
6#include <TGFrame.h>
7#include <TGLabel.h>
8#include <TRootEmbeddedCanvas.h>
9#include <TCanvas.h>
10#include <TPad.h>
11#include <TVirtualPad.h>
12
13#include "AliLog.h"
14#include "AliTPCCalibQAChecker.h"
15#include "AliTPCCalibViewerGUI.h"
16#include "AliTPCCalibViewerGUItime.h"
17
18#include "AliTPCCalibViewerGUIAlarms.h"
19
20
21ClassImp(AliTPCCalibViewerGUIAlarms)
22
23AliTPCCalibViewerGUIAlarms::AliTPCCalibViewerGUIAlarms(const TGWindow *p, UInt_t w, UInt_t h) :
24 TGCompositeFrame(p,w,h),
25 fCalibChecker(0x0),
26 fAlarmTree(0x0),
27 fMainCanvas(0x0),
28 fTreeCanvas(0x0),
29 fAlarmText(0x0),
30 fCalibViewerGUI(0x0),
31 fCalibViewerGUItime(0x0)
32{
33 //
34 //
35 //
36 DrawGUI(p,w,h);
37}
38//______________________________________________________________________________
39AliTPCCalibViewerGUIAlarms::~AliTPCCalibViewerGUIAlarms()
40{
41 //
42 //
43 //
44// gClient->FreePicture("interrupt.xpm");
45}
46//______________________________________________________________________________
47void AliTPCCalibViewerGUIAlarms::DrawGUI(const TGWindow */*p*/, UInt_t w, UInt_t h)
48{
49 //
50 // draw the GUI
51 //
52
53 //GUI elements
54 SetCleanup(kDeepCleanup);
55
56 // *****************************************************************************
57 // ************************* content of this MainFrame *************************
58 // *****************************************************************************
59 // top level container with horizontal layout
60
61 TGCompositeFrame *contLCR = new TGCompositeFrame(this, w, h, kHorizontalFrame | kFixedWidth | kFixedHeight);
62 AddFrame(contLCR, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
63
64 // ***********************************************************************
65 // ************************* content of contLCR *************************
66 // ***********************************************************************
67 // left container
68 TGCompositeFrame *contLeft = new TGCompositeFrame(contLCR, 200, 200, kVerticalFrame | kFixedWidth | kFitHeight);
69 contLCR->AddFrame(contLeft, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandY, 5, 3, 3, 3));
70
71 // left vertical splitter
72 TGVSplitter *splitLeft = new TGVSplitter(contLCR);
73 splitLeft->SetFrame(contLeft, kTRUE);
74 contLCR->AddFrame(splitLeft, new TGLayoutHints(kLHintsLeft | kLHintsExpandY, 0, 0, 0, 0));
75
76 // right container
77 TGCompositeFrame *contRight = new TGCompositeFrame(contLCR, 150, 200, kVerticalFrame | kFixedWidth | kFitHeight);
78 contLCR->AddFrame(contRight, new TGLayoutHints(kLHintsTop | kLHintsRight | kLHintsExpandY, 3, 5, 3, 3));
79
80 // center container
81 TGCompositeFrame *contCenter = new TGCompositeFrame(contLCR, 200, 200, kVerticalFrame | kFixedWidth | kFitHeight);
82 contLCR->AddFrame(contCenter, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
83
84 // right vertical splitter
85 TGVSplitter *splitRight = new TGVSplitter(contLCR);
86 splitRight->SetFrame(contRight, kFALSE);
87 contLCR->AddFrame(splitRight, new TGLayoutHints(kLHintsLeft | kLHintsExpandY, 0, 0, 0, 0));
88
89 // ***********************************************************************
90 // ******************* left container ************************
91 // ***********************************************************************
92
93 //Alarm list view
94 TGCanvas *treeCanvas = new TGCanvas(contLeft, 200, 200);
95 fAlarmTree = new TGListTree(treeCanvas, kHorizontalFrame);
96 contLeft->AddFrame(treeCanvas,new TGLayoutHints(kLHintsExpandX | kLHintsExpandY | kLHintsTop));
97 fAlarmTree->Connect("DoubleClicked(TGListTreeItem*,Int_t)","AliTPCCalibViewerGUIAlarms",this,
98 "OnDoubleClick(TGListTreeItem*,Int_t)");
99 fAlarmTree->Connect("Clicked(TGListTreeItem*,Int_t)","AliTPCCalibViewerGUIAlarms",this,
100 "OnClick(TGListTreeItem*,Int_t)");
101 fAlarmTree->SetColorMode(TGListTree::kColorBox);
102
103 // ***********************************************************************
104 // ******************* center container ************************
105 // ***********************************************************************
106
107 // top container
108 TGCompositeFrame *contCenterTop = new TGCompositeFrame(contCenter, 200, 200, kVerticalFrame | kFixedWidth | kFitHeight);
109 contCenter->AddFrame(contCenterTop, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
110
111 // bottom container
112 TGCompositeFrame *contCenterBottom = new TGCompositeFrame(contCenter, 200, 100, kVerticalFrame | kFixedWidth | kFixedHeight);
113 contCenter->AddFrame(contCenterBottom, new TGLayoutHints( kLHintsExpandX, 0, 0, 0, 0));
114
115 //--------------
116 // canvas on top
117 TRootEmbeddedCanvas *cEmbed = new TRootEmbeddedCanvas("Main_Canvas", contCenterTop, 200, 200, kFitWidth | kFitHeight);
118 contCenterTop->AddFrame(cEmbed, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
119// cEmbed->GetCanvas()->Connect("ProcessedEvent(Int_t, Int_t, Int_t, TObject*)", "AliTPCCalibViewerGUIAlarms", this, "MouseMove(Int_t, Int_t, Int_t, TObject*)");
120 cEmbed->GetCanvas()->SetToolTipText("Alarm histograms are displayed in this region.");
121 fMainCanvas=cEmbed->GetCanvas();
122 //--------------
123 // alarm text on bottom
124 // canvas
125 TGCanvas *textCanvas = new TGCanvas(contCenterBottom, 200, 200);
126 fAlarmText = new TGLabel(textCanvas->GetViewPort(),"Alarm descriptions can be found here");
127 textCanvas->SetContainer(fAlarmText);
128 contCenterBottom->AddFrame(textCanvas,new TGLayoutHints(kLHintsExpandX | kLHintsExpandY | kLHintsTop));
129
130// textCanvas->AddFrame(fAlarmText,new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
131
132
133 // ***********************************************************************
134 // ******************* right container ************************
135 // ***********************************************************************
136
137 TGGroupFrame *grpInfo = new TGGroupFrame(contRight, "Alarm Info", kVerticalFrame | kFitWidth | kFitHeight);
138 contRight->AddFrame(grpInfo, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
139
140
141 SetWindowName("AliTPCCalibViewer GUI - Alarms");
142 MapSubwindows();
143 Resize(GetDefaultSize());
144 MapWindow();
145
146}
147//______________________________________________________________________________
148void AliTPCCalibViewerGUIAlarms::AddSubItems(AliTPCCalibQAChecker *checker, TGListTreeItem *item)
149{
150 //
151 //
152 //
153 TGListTreeItem *newitem=fAlarmTree->AddItem(item,checker->GetName(),(void*)checker);
154 newitem->SetColor(checker->GetQualityColor());
155 newitem->SetTipText(checker->GetTitle());
156 if (checker->HasSubCheckers()) {
157 AliTPCCalibQAChecker *ch=0x0;
158 while ( (ch=checker->NextSubChecker()) ) AddSubItems(ch,newitem);
159 } else {
160 newitem->SetPictures(gClient->GetPicture("interrupt.xpm"),gClient->GetPicture("interrupt.xpm"));
161 }
162
163}
164//______________________________________________________________________________
165void AliTPCCalibViewerGUIAlarms::InitBrowser()
166{
167 //
168 //
169 //
170 if (!fAlarmTree){
171 AliError("Alarms not set!");
172 return;
173 }
174 AddSubItems(fCalibChecker,0);
175 fAlarmTree->ClearViewPort();
176}
177//______________________________________________________________________________
178void AliTPCCalibViewerGUIAlarms::UpdateSubItem(TGListTreeItem *item)
179{
180 //
181 //
182 //
183
184 printf("name: %s\n", item->GetText());
185 AliTPCCalibQAChecker *checker=dynamic_cast<AliTPCCalibQAChecker*>((TObject*)item->GetUserData());
186 if (checker){
187 item->SetColor(checker->GetQualityColor());
188 } else {
189 item->ClearColor();
190 }
191 TGListTreeItem *nextItem=0x0;
192 if ( (nextItem=item->GetFirstChild()) ) UpdateSubItem(nextItem);
193 if ( (nextItem=item->GetNextSibling()) ) UpdateSubItem(nextItem);
194}
195//______________________________________________________________________________
196void AliTPCCalibViewerGUIAlarms::UpdateBrowser()
197{
198 //
199 //
200 //
201 UpdateSubItem(fAlarmTree->GetFirstItem());
202 fAlarmTree->ClearViewPort();
203}
204//______________________________________________________________________________
37f2177e 205void AliTPCCalibViewerGUIAlarms::OnDoubleClick(TGListTreeItem* item, Int_t /*id*/)
949d8707 206{
207 //
208 //
209 //
210// printf("DoubleClicked");
211 if (!fCalibViewerGUI && !fCalibViewerGUItime) return;
212 TGTextEntry *draw=0x0;
213 TGTextEntry *cuts=0x0;
214 TGTextEntry *opt=0x0;
215 if (fCalibViewerGUI){
216 draw=fCalibViewerGUI->GetDrawEntry();
217 cuts=fCalibViewerGUI->GetCutsEntry();
218 opt=fCalibViewerGUI->GetDrawOptEntry();
219 } else if (fCalibViewerGUItime){
220 draw=fCalibViewerGUItime->GetDrawEntry();
221 cuts=fCalibViewerGUItime->GetCutsEntry();
222 opt=fCalibViewerGUItime->GetDrawOptEntry();
223 }
224 draw->SetText(((AliTPCCalibQAChecker*)item->GetUserData())->GetDrawString());
225 cuts->SetText(((AliTPCCalibQAChecker*)item->GetUserData())->GetCutsString());
226 opt->SetText(((AliTPCCalibQAChecker*)item->GetUserData())->GetDrawOptString());
227}
228//______________________________________________________________________________
37f2177e 229void AliTPCCalibViewerGUIAlarms::OnClick(TGListTreeItem* item, Int_t /*id*/)
949d8707 230{
231 //
232 //
233 //
234// printf("Clicked");
235
236 TVirtualPad *pad=gPad;
237 fMainCanvas->cd();
238 fMainCanvas->Clear();
239 AliTPCCalibQAChecker *checker=(AliTPCCalibQAChecker*)item->GetUserData();
240 checker->Draw("nobc");
241 TString text(checker->GetQualityDescription());
242 if (text.IsNull()) fAlarmText->SetText("No description available!");
243 else fAlarmText->SetText(text.Data());
244 gPad->Modified();
245 gPad->Update();
246 if (pad) pad->cd();
247
248}
249//______________________________________________________________________________
250AliTPCCalibViewerGUIAlarms* AliTPCCalibViewerGUIAlarms::Show()
251{
252 //
253 //
254 //
255 TGMainFrame* frmMain = new TGMainFrame(gClient->GetRoot(), 1000, 600);
256 frmMain->SetWindowName("AliTPCCalibViewer GUI");
257 frmMain->SetCleanup(kDeepCleanup);
258
259 AliTPCCalibViewerGUIAlarms* calibViewer1 = new AliTPCCalibViewerGUIAlarms(frmMain, 1000, 600);
260 frmMain->AddFrame(calibViewer1, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
261
262 frmMain->MapSubwindows();
263 frmMain->Resize();
264 frmMain->MapWindow();
265
266 return calibViewer1;
267}
268//______________________________________________________________________________
269