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