3 #include <TApplication.h>
25 init(p, test, tabname);
31 UInt_t w = fGui->getTabs()->GetWidth();
32 UInt_t h = fGui->getTabs()->GetHeight();
34 fTabFrame = fGui->getTabs()->AddTab(fTabName.c_str());
37 fhFrame =
new TGCompositeFrame(fTabFrame, w, h, kHorizontalFrame);
40 fV1 =
new TGVerticalFrame(fhFrame);
41 fhFrame->AddFrame(fV1,
new TGLayoutHints(kLHintsLeft | kLHintsExpandX | kLHintsExpandY, fBorderN, fBorderN, fBorderN, fBorderN));
42 fV2 =
new TGVerticalFrame(fhFrame);
43 fhFrame->AddFrame(fV2,
new TGLayoutHints(kLHintsRight | kLHintsExpandX | kLHintsExpandY, fBorderN, fBorderN, fBorderN, fBorderN));
46 fEc1 =
new TRootEmbeddedCanvas(Form(
"%s", tabname.c_str()), fV1, 500, 500);
47 fV1->AddFrame(fEc1,
new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX | kLHintsExpandY, 1, 1, 1, 1));
51 Int_t wid = fEc1->GetCanvasWindowId();
52 TCanvas *myc =
new TCanvas(Form(
"%sCanvas", tabname.c_str()), 10, 10, wid);
53 fEc1->AdoptCanvas(myc);
54 myc->Connect(
"ProcessedEvent(Int_t,Int_t,Int_t,TObject*)",
"PixTab",
this,
"statusBarUpdate(Int_t,Int_t,Int_t,TObject*)");
56 Int_t parts[] = {45, 55};
57 fStatusBar =
new TGStatusBar(fV1, 50, 10, kVerticalFrame);
58 fStatusBar->SetParts(parts, 2);
59 fStatusBar->Draw3DCorner(kFALSE);
60 fV1->AddFrame(fStatusBar,
new TGLayoutHints(kLHintsExpandX, 1, 1, 1, 1));
63 vector<pair<string, string> > amap = fTest->getParameters();
67 TGTextButton *tset(0);
68 TGCheckButton *tcheck(0);
70 TGHorizontalFrame *hFrame(0);
73 for (
unsigned int i = 0; i < amap.size(); ++i) {
74 if (amap[i].second ==
"button") {
75 hFrame =
new TGHorizontalFrame(fV2, 300, 30, kLHintsExpandX);
76 tset =
new TGTextButton(hFrame, amap[i].first.c_str(), 1234);
77 hFrame->AddFrame(tset,
new TGLayoutHints(kLHintsCenterY | kLHintsLeft, fBorderN, fBorderN, fBorderN, fBorderN));
78 tset->SetToolTipText(
"run this subtest");
79 tset->GetToolTip()->SetDelay(2000);
80 tset->Connect(
"Clicked()",
"PixTab",
this,
"buttonClicked()");
81 tset->SetBackgroundColor(fGui->fDarkSalmon);
82 fV2->AddFrame(hFrame,
new TGLayoutHints(kLHintsRight | kLHintsTop));
86 if (string::npos != amap[i].second.find(
"checkbox")) {
87 hFrame =
new TGHorizontalFrame(fV2, 300, 30, kLHintsExpandX);
88 tcheck =
new TGCheckButton(hFrame, amap[i].first.c_str(), 1234);
89 hFrame->AddFrame(tcheck,
new TGLayoutHints(kLHintsRight, fBorderN, fBorderN, fBorderN, fBorderN));
90 fV2->AddFrame(hFrame,
new TGLayoutHints(kLHintsRight | kLHintsTop));
91 if (string::npos != amap[i].second.find(
"(1)")) {
92 tcheck->SetState(kButtonDown);
93 }
else if (string::npos != amap[i].second.find(
"(0)")) {
94 tcheck->SetState(kButtonUp);
96 tcheck->SetState(kButtonUp);
98 string sTitle = tcheck->GetTitle();
99 tcheck->Connect(
"Clicked()",
"PixTab",
this,
"boxChecked()");
104 hFrame =
new TGHorizontalFrame(fV2, 300, 30, kLHintsExpandX);
105 fV2->AddFrame(hFrame,
new TGLayoutHints(kLHintsRight | kLHintsTop));
107 tb =
new TGTextBuffer(5);
108 tl =
new TGLabel(hFrame, amap[i].first.c_str());
110 hFrame->AddFrame(tl,
new TGLayoutHints(kLHintsCenterY | kLHintsLeft, fBorderN, fBorderN, fBorderN, fBorderN));
112 te =
new TGTextEntry(hFrame, tb, cnt); te->SetWidth(100);
113 hFrame->AddFrame(te,
new TGLayoutHints(kLHintsCenterY | kLHintsCenterX, fBorderN, fBorderN, fBorderN, fBorderN));
114 fParIds.push_back(amap[i].first);
115 fParTextEntries.insert(make_pair(amap[i].first, te));
117 te->SetText(amap[i].second.c_str());
118 te->Connect(
"ReturnPressed()",
"PixTab",
this,
"setParameter()");
119 te->Connect(
"TextChanged(const char*)",
"PixTab",
this,
"yellow()");
120 te->Connect(
"ShiftTabPressed()",
"PixTab",
this,
"moveUp()");
121 te->Connect(
"TabPressed()",
"PixTab",
this,
"moveDown()");
123 tset =
new TGTextButton(hFrame,
"Set", cnt);
124 tset->Connect(
"Clicked()",
"PixTab",
this,
"setParameter()");
125 hFrame->AddFrame(tset,
new TGLayoutHints(kLHintsCenterY | kLHintsLeft, fBorderN, fBorderN, fBorderN, fBorderN));
126 tset->SetToolTipText(
"set the parameter\nor click *return* after changing the numerical value");
127 tset->GetToolTip()->SetDelay(2000);
132 hFrame =
new TGHorizontalFrame(fV2);
133 TGTextButton * previous =
new TGTextButton(hFrame,
"Previous");
134 previous->SetToolTipText(
"display previous histogram in this test's list");
135 previous->Connect(
"Clicked()",
"PixTab",
this,
"previousHistogram()");
136 hFrame->AddFrame(previous,
new TGLayoutHints(kLHintsCenterX | kLHintsCenterY, fBorderN, fBorderN, fBorderN, fBorderN));
138 TGTextButton * next =
new TGTextButton(hFrame,
"Next");
139 next->SetToolTipText(
"display next histogram in this test's list");
140 next->Connect(
"Clicked()",
"PixTab",
this,
"nextHistogram()");
141 hFrame->AddFrame(next,
new TGLayoutHints(kLHintsCenterX | kLHintsCenterY, fBorderN, fBorderN, fBorderN, fBorderN));
143 TGTextButton * update =
new TGTextButton(hFrame,
"Update");
144 update->SetToolTipText(
"update canvas");
145 update->Connect(
"Clicked()",
"PixTab",
this,
"update()");
146 hFrame->AddFrame(update,
new TGLayoutHints(kLHintsCenterX | kLHintsCenterY, fBorderN, fBorderN, fBorderN, fBorderN));
148 TGTextButton * clear =
new TGTextButton(hFrame,
"Clear");
149 clear->SetToolTipText(
"clear canvas and resest histogram list");
150 clear->Connect(
"Clicked()",
"PixTab",
this,
"clearHistList()");
151 hFrame->AddFrame(clear,
new TGLayoutHints(kLHintsCenterX | kLHintsCenterY, fBorderN, fBorderN, fBorderN, fBorderN));
153 fV2->AddFrame(hFrame,
new TGLayoutHints(kLHintsLeft | kLHintsBottom, fBorderN, fBorderN, fBorderN, fBorderN));
156 hFrame =
new TGHorizontalFrame(fV2);
158 fbDoTest =
new TGTextButton(hFrame,
" doTest ", B_DOTEST);
159 fbDoTest->ChangeOptions(fbDoTest->GetOptions() | kFixedWidth);
160 hFrame->AddFrame(fbDoTest,
new TGLayoutHints(kLHintsLeft | kLHintsTop, fBorderN, fBorderN, fBorderN, fBorderN));
161 fbDoTest->Connect(
"Clicked()",
"PixTest", test,
"doTest()");
162 fbDoTest->SetBackgroundColor(fGui->fDarkSalmon);
165 TGTextButton *bStop =
new TGTextButton(hFrame,
" stop ", B_DOSTOP);
166 bStop->SetToolTipText(fTest->getStopTip().c_str());
167 bStop->ChangeOptions(bStop->GetOptions() | kFixedWidth);
168 hFrame->AddFrame(bStop,
new TGLayoutHints(kLHintsLeft | kLHintsTop, fBorderN, fBorderN, fBorderN, fBorderN));
169 bStop->Connect(
"Clicked()",
"PixTab",
this,
"handleButtons(Int_t)");
172 TGTextButton *bPrint =
new TGTextButton(hFrame,
" print ", B_PRINT);
173 bPrint->SetToolTipText(
"create a pdf of the canvas");
174 bPrint->ChangeOptions(bPrint->GetOptions() | kFixedWidth);
175 hFrame->AddFrame(bPrint,
new TGLayoutHints(kLHintsLeft | kLHintsTop, fBorderN, fBorderN, fBorderN, fBorderN));
176 bPrint->Connect(
"Clicked()",
"PixTab",
this,
"handleButtons(Int_t)");
179 fbModMap =
new TGTextButton(hFrame,
" summary ", B_MODMAP);
180 fbModMap->ChangeOptions(fbModMap->GetOptions() | kFixedWidth);
181 hFrame->AddFrame(fbModMap,
new TGLayoutHints(kLHintsLeft | kLHintsTop, fBorderN, fBorderN, fBorderN, fBorderN));
182 fbModMap->Connect(
"Clicked()",
"PixTab",
this,
"handleButtons(Int_t)");
185 fbBrowser =
new TGTextButton(hFrame,
" browser ", B_BROWSER);
186 fbBrowser->ChangeOptions(fbBrowser->GetOptions() | kFixedWidth);
187 fbBrowser->SetToolTipText(
"open a TBrowser (for easier histogram navigation)");
188 hFrame->AddFrame(fbBrowser,
new TGLayoutHints(kLHintsLeft | kLHintsTop, fBorderN, fBorderN, fBorderN, fBorderN));
189 fbBrowser->Connect(
"Clicked()",
"PixTab",
this,
"handleButtons(Int_t)");
192 TGTextButton *bClose =
new TGTextButton(hFrame,
" close ", B_CLOSETAB);
193 bClose->ChangeOptions(bClose->GetOptions() | kFixedWidth);
194 bClose->SetToolTipText(
"close the test tab");
195 hFrame->AddFrame(bClose,
new TGLayoutHints(kLHintsRight | kLHintsTop, fBorderN, fBorderN, fBorderN, fBorderN));
196 bClose->Connect(
"Clicked()",
"PixTab",
this,
"handleButtons(Int_t)");
198 fV2->AddFrame(hFrame,
new TGLayoutHints(kLHintsLeft | kLHintsBottom, fBorderN, fBorderN, fBorderN, fBorderN));
206 fTabFrame->AddFrame(fhFrame,
207 new TGLayoutHints(kLHintsRight | kLHintsExpandX | kLHintsExpandY, fBorderN, fBorderN, fBorderN, fBorderN));
208 fTabFrame->MapSubwindows();
209 fTabFrame->Resize(fTabFrame->GetDefaultSize());
210 fTabFrame->MapWindow();
221 void PixTab::init(
PixGui *p,
PixTest *test,
string tabname) {
237 void PixTab::handleButtons(Int_t
id) {
239 if (!fGui->getTabs())
return;
242 TGButton *btn = (TGButton*)gTQSender;
243 id = btn->WidgetId();
248 LOG(logDEBUG) <<
"and now what???";
253 fTest->runCommand(
"stop");
254 LOG(logDEBUG) <<
"stopping...and now what???";
259 new TBrowser(getName().c_str(), fTest->getDirectory());
264 fTest->moduleMap(
"what");
270 LOG(logINFO) << Form(
"Canvas printed to %s-%d.pdf", fTabName.c_str(), fCount);
271 fEc1->GetCanvas()->SaveAs(Form(
"%s-%d.pdf", fTabName.c_str(), fCount));
276 delete fEc1; fEc1 = 0;
277 LOG(logDEBUG) << Form(
"Tab %s closed", fTabName.c_str());
278 fGui->getTabs()->RemoveTab(fGui->getTabs()->GetCurrent());
279 fGui->getTabs()->Layout();
292 void PixTab::buttonClicked() {
293 TGButton *btn = (TGButton*)gTQSender;
294 LOG(logDEBUG) <<
"xxxPressed(): " << btn->GetTitle();
295 fTest->runCommand(btn->GetTitle());
300 void PixTab::boxChecked() {
301 TGCheckButton *btn = (TGCheckButton*) gTQSender;
302 string sTitle = btn->GetTitle();
303 LOG(logDEBUG) <<
"xxxPressed(): " << btn->GetTitle();
304 fTest->setParameter(sTitle,
string(btn->IsDown()?
"1":
"0")) ;
309 void PixTab::yellow() {
310 TGButton *btn = (TGButton *) gTQSender;
312 id = btn->WidgetId();
314 LOG(logDEBUG) <<
"ASLFDKHAPIUDF ";
318 string svalue = ((TGTextEntry*)(fParTextEntries[fParIds[
id]]))->GetText();
319 if (fTest->getParameter(fParIds[
id]).compare(svalue)) {
320 ((TGTextEntry*)(fParTextEntries[fParIds[
id]]))->SetBackgroundColor(fGui->fYellow);
322 ((TGTextEntry*)(fParTextEntries[fParIds[
id]]))->SetBackgroundColor(fGui->fWhite);
328 void PixTab::moveUp() {
329 TGButton *btn = (TGButton *) gTQSender;
331 id = btn->WidgetId();
333 LOG(logDEBUG) <<
"ASLFDKHAPIUDF ";
338 ((TGTextEntry*)(fParTextEntries[fParIds[
id-1]]))->SetFocus();
340 ((TGTextEntry*)(fParTextEntries[fParIds[fParIds.size()-1]]))->SetFocus();
345 void PixTab::moveDown() {
346 TGButton *btn = (TGButton *) gTQSender;
348 id = btn->WidgetId();
350 LOG(logDEBUG) <<
"ASLFDKHAPIUDF ";
354 if (
id < static_cast<int>(fParIds.size()) - 1) {
355 ((TGTextEntry*)(fParTextEntries[fParIds[
id+1]]))->SetFocus();
357 ((TGTextEntry*)(fParTextEntries[fParIds[0]]))->SetFocus();
362 void PixTab::setParameter() {
363 if (!fGui->getTabs())
return;
366 TGButton *btn = (TGButton *) gTQSender;
368 id = btn->WidgetId();
370 LOG(logDEBUG) <<
"ASLFDKHAPIUDF ";
374 string svalue = ((TGTextEntry*)(fParTextEntries[fParIds[
id]]))->GetText();
375 ((TGTextEntry*)(fParTextEntries[fParIds[
id]]))->SetBackgroundColor(fGui->fWhite);
377 LOG(logDEBUG) <<
"xxxPressed(): ID = " <<
id
378 <<
" -> " << fParIds[id]
379 <<
" to value " << svalue;
381 fTest->setParameter(fParIds[
id], svalue);
387 void PixTab::clearHistList() {
389 fTest->clearHistList();
393 void PixTab::clearCanvas() {
394 TCanvas *c = fEc1->GetCanvas();
400 void PixTab::nextHistogram() {
401 TH1 *h = fTest->nextHist();
403 string option = fTest->getHistOption(h);
404 if (string::npos == option.find(
"same")) clearCanvas();
405 if (h->InheritsFrom(TH2::Class())) {
406 h->Draw(option.c_str());
409 h->Draw(option.c_str());
413 LOG(logDEBUG) <<
"no previous histogram found ";
420 void PixTab::previousHistogram() {
421 TH1 *h = fTest->previousHist();
423 string option = fTest->getHistOption(h);
424 if (string::npos == option.find(
"same")) clearCanvas();
425 if (h->InheritsFrom(TH2::Class())) {
426 h->Draw(option.c_str());
429 h->Draw(option.c_str());
433 LOG(logDEBUG) <<
"no previous histogram found ";
439 void PixTab::update() {
440 TCanvas *c = fEc1->GetCanvas();
441 TList* l = c->GetListOfPrimitives();
443 while (TObject *h = next()) {
444 if (h->InheritsFrom(TH1::Class())) {
445 if (h->InheritsFrom(TH2::Class())) {
446 gStyle->SetOptStat(0);
449 gStyle->SetOptStat(1111111);
461 void PixTab::statusBarUpdate(Int_t event, Int_t px, Int_t py, TObject *selected) {
464 const char* text0 = selected->GetName();
465 fStatusBar->SetText(text0, 0);
467 if (event == kKeyPress) {
468 LOG(logDEBUG) <<
"key pressed?";
473 if (selected->InheritsFrom(TH1::Class())) {
474 string trafo = selected->GetObjectInfo(px,py);
475 string::size_type s1 = trafo.find(
"binx");
476 string trafo1 = trafo.substr(s1);
478 if (selected->InheritsFrom(TH2::Class())) {
479 sscanf(trafo1.c_str(),
"binx=%f, biny=%f, binc=%f", &x, &y, &val);
480 if (52 == ((TH2D*)selected)->GetNbinsX() && 80 == ((TH2D*)selected)->GetNbinsY()) {
481 text2 = Form(
"c=%.0f, r=%.0f, value=%4.3f", x-1, y-1, val);
482 }
else if (160 == ((TH2D*)selected)->GetNbinsX() && 416 == ((TH2D*)selected)->GetNbinsY()) {
483 text2 = Form(
"x=%.0f, y=%.0f, value=%4.3f", x-1, y-1, val);
489 sscanf(trafo1.c_str(),
"binx=%f, binc=%f", &x, &val);
490 text2 = Form(
"x=%.0f, value=%4.3f", x-1, val);
493 text2 = selected->GetObjectInfo(px,py);
495 fStatusBar->SetText(text2.c_str(), 1);
500 void PixTab::updateToolTips() {
501 string tooltip = string(Form(
"%s test algorithm (patience may be required)", fTest->getName().c_str()))
502 + string(
"\n") + fTest->getTestTip()
505 fbDoTest->SetToolTipText(tooltip.c_str());
507 tooltip = string(Form(
"summary plot for %s", fTest->getName().c_str()))
508 + string(
"\n") + fTest->getSummaryTip()
510 fbModMap->SetToolTipText(tooltip.c_str());