]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TPC/AliTPCCalibViewerGUIAlarms.cxx
skim task first usable version
[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
cc65e4f5 117 TRootEmbeddedCanvas *cEmbed = new TRootEmbeddedCanvas("Alarm_Canvas", contCenterTop, 200, 200, kFitWidth | kFitHeight);
949d8707 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
cc65e4f5 184// printf("name: %s\n", item->GetText());
949d8707 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//______________________________________________________________________________
cc65e4f5 205void AliTPCCalibViewerGUIAlarms::ResetBrowser()
206{
207 //
208 //
209 //
210 if (!fAlarmTree->GetFirstItem()) return;
211 fAlarmTree->DeleteChildren(fAlarmTree->GetFirstItem());
212 fAlarmTree->DeleteItem(fAlarmTree->GetFirstItem());
213 fAlarmTree->ClearViewPort();
214}
215//______________________________________________________________________________
216void AliTPCCalibViewerGUIAlarms::OpenSubItems(TGListTreeItem *item)
217{
218 //
219 //
220 //
221 fAlarmTree->OpenItem(item);
222 TGListTreeItem *nextItem=0x0;
223 if ( (nextItem=item->GetFirstChild()) ) OpenSubItems(nextItem);
224 if ( (nextItem=item->GetNextSibling()) ) OpenSubItems(nextItem);
225}
226//______________________________________________________________________________
227void AliTPCCalibViewerGUIAlarms::OpenAllItems()
228{
229 //
230 //
231 //
232 if (!fAlarmTree->GetFirstItem()) return;
233 OpenSubItems(fAlarmTree->GetFirstItem());
234 fAlarmTree->ClearViewPort();
235}
236//______________________________________________________________________________
37f2177e 237void AliTPCCalibViewerGUIAlarms::OnDoubleClick(TGListTreeItem* item, Int_t /*id*/)
949d8707 238{
239 //
240 //
241 //
242// printf("DoubleClicked");
243 if (!fCalibViewerGUI && !fCalibViewerGUItime) return;
244 TGTextEntry *draw=0x0;
245 TGTextEntry *cuts=0x0;
246 TGTextEntry *opt=0x0;
247 if (fCalibViewerGUI){
248 draw=fCalibViewerGUI->GetDrawEntry();
249 cuts=fCalibViewerGUI->GetCutsEntry();
250 opt=fCalibViewerGUI->GetDrawOptEntry();
251 } else if (fCalibViewerGUItime){
252 draw=fCalibViewerGUItime->GetDrawEntry();
253 cuts=fCalibViewerGUItime->GetCutsEntry();
254 opt=fCalibViewerGUItime->GetDrawOptEntry();
255 }
256 draw->SetText(((AliTPCCalibQAChecker*)item->GetUserData())->GetDrawString());
257 cuts->SetText(((AliTPCCalibQAChecker*)item->GetUserData())->GetCutsString());
258 opt->SetText(((AliTPCCalibQAChecker*)item->GetUserData())->GetDrawOptString());
259}
260//______________________________________________________________________________
37f2177e 261void AliTPCCalibViewerGUIAlarms::OnClick(TGListTreeItem* item, Int_t /*id*/)
949d8707 262{
263 //
264 //
265 //
266// printf("Clicked");
267
268 TVirtualPad *pad=gPad;
269 fMainCanvas->cd();
270 fMainCanvas->Clear();
271 AliTPCCalibQAChecker *checker=(AliTPCCalibQAChecker*)item->GetUserData();
272 checker->Draw("nobc");
273 TString text(checker->GetQualityDescription());
274 if (text.IsNull()) fAlarmText->SetText("No description available!");
275 else fAlarmText->SetText(text.Data());
276 gPad->Modified();
277 gPad->Update();
278 if (pad) pad->cd();
279
280}
281//______________________________________________________________________________
282AliTPCCalibViewerGUIAlarms* AliTPCCalibViewerGUIAlarms::Show()
283{
284 //
285 //
286 //
287 TGMainFrame* frmMain = new TGMainFrame(gClient->GetRoot(), 1000, 600);
288 frmMain->SetWindowName("AliTPCCalibViewer GUI");
289 frmMain->SetCleanup(kDeepCleanup);
290
291 AliTPCCalibViewerGUIAlarms* calibViewer1 = new AliTPCCalibViewerGUIAlarms(frmMain, 1000, 600);
292 frmMain->AddFrame(calibViewer1, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
293
294 frmMain->MapSubwindows();
295 frmMain->Resize();
296 frmMain->MapWindow();
297
298 return calibViewer1;
299}
300//______________________________________________________________________________
301