00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #include "TEveCaloVizEditor.h"
00013 #include "TEveCalo.h"
00014 #include "TEveGValuators.h"
00015 #include "TEveRGBAPaletteEditor.h"
00016 #include "TEveCaloData.h"
00017
00018 #include "TGClient.h"
00019 #include "TGFont.h"
00020 #include "TGedEditor.h"
00021
00022 #include "TGLabel.h"
00023 #include "TGNumberEntry.h"
00024 #include "TGDoubleSlider.h"
00025 #include "TGNumberEntry.h"
00026 #include "TG3DLine.h"
00027 #include "TGButtonGroup.h"
00028 #include "TColor.h"
00029 #include "TGColorSelect.h"
00030
00031 #include "TMathBase.h"
00032 #include "TMath.h"
00033
00034
00035
00036
00037
00038 ClassImp(TEveCaloVizEditor);
00039
00040
00041 TEveCaloVizEditor::TEveCaloVizEditor(const TGWindow *p, Int_t width, Int_t height,
00042 UInt_t options, Pixel_t back) :
00043 TGedFrame(p, width, height, options | kVerticalFrame, back),
00044 fM(0),
00045
00046 fPlotE(0),
00047 fPlotEt(0),
00048
00049 fScaleAbs(0),
00050 fMaxValAbs(0),
00051 fMaxTowerH(0),
00052
00053 fEtaRng(0),
00054 fPhi(0),
00055 fPhiOffset(0),
00056 fDataFrame(0),
00057 fSliceFrame(0)
00058 {
00059
00060
00061 MakeTitle("TEveCaloViz");
00062
00063 TGLabel* label = 0;
00064 Int_t labelW = 45;
00065
00066
00067 TGHorizontalFrame* scf = new TGHorizontalFrame(this);
00068
00069 label = new TGLabel(scf, "ScaleAbsolute:");
00070 scf->AddFrame(label, new TGLayoutHints(kLHintsLeft | kLHintsBottom));
00071
00072 fScaleAbs = new TGCheckButton(scf);
00073 scf->AddFrame(fScaleAbs, new TGLayoutHints(kLHintsLeft, 3, 5, 3, 0));
00074 fScaleAbs->Connect("Toggled(Bool_t)", "TEveCaloVizEditor", this, "DoScaleAbs()");
00075
00076
00077 fMaxValAbs = new TEveGValuator(scf, "MaxEVal:", 70, 0);
00078 fMaxValAbs->SetLabelWidth(56);
00079 fMaxValAbs->SetNELength(5);
00080 fMaxValAbs->SetShowSlider(kFALSE);
00081 fMaxValAbs->Build();
00082 fMaxValAbs->SetLimits(0, 1000);
00083 fMaxValAbs->Connect("ValueSet(Double_t)", "TEveCaloVizEditor", this, "DoMaxValAbs()");
00084 scf->AddFrame(fMaxValAbs, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
00085
00086 AddFrame(scf, new TGLayoutHints(kLHintsTop, 4, 1, 1, 0));
00087
00088
00089
00090 fMaxTowerH = new TEveGValuator(this, "MaxTowerH:", 96, 0);
00091 fMaxTowerH->SetLabelWidth(71);
00092 fMaxTowerH->SetNELength(5);
00093 fMaxTowerH->SetShowSlider(kFALSE);
00094 fMaxTowerH->Build();
00095 fMaxTowerH->SetLimits(0.1, 500, 501, TGNumberFormat::kNESRealOne);
00096 fMaxTowerH->Connect("ValueSet(Double_t)", "TEveCaloVizEditor", this, "DoMaxTowerH()");
00097 AddFrame(fMaxTowerH, new TGLayoutHints(kLHintsTop, 4, 1, 1, 1));
00098
00099
00100
00101
00102 fDataFrame = CreateEditorTabSubFrame("Data");
00103
00104
00105 {
00106 TGHorizontalFrame *group = new TGHorizontalFrame(fDataFrame);
00107 TGCompositeFrame *labfr = new TGHorizontalFrame(group, 28, 20, kFixedSize);
00108
00109 TGFont *myfont = gClient->GetFont("-adobe-times-bold-r-*-*-12-*-*-*-*-*-iso8859-1");
00110 label = new TGLabel(labfr, "Plot:");
00111 label->SetTextFont(myfont);
00112 labfr->AddFrame(label, new TGLayoutHints(kLHintsLeft | kLHintsBottom));
00113 group->AddFrame(labfr, new TGLayoutHints(kLHintsLeft));
00114
00115 fPlotE = new TGRadioButton(group, new TGHotString("E"), 11);
00116 fPlotE->Connect("Clicked()", "TEveCaloVizEditor", this, "DoPlot()");
00117 group->AddFrame(fPlotE, new TGLayoutHints(kLHintsLeft | kLHintsBottom, 2, 2, 0, 0));
00118
00119 fPlotEt = new TGRadioButton(group, new TGHotString("Et"), 22);
00120 fPlotEt->Connect("Clicked()", "TEveCaloVizEditor", this, "DoPlot()");
00121 group->AddFrame(fPlotEt, new TGLayoutHints(kLHintsLeft | kLHintsBottom, 2, 2, 0, 0));
00122
00123 fDataFrame->AddFrame(group, new TGLayoutHints(kLHintsTop, 4, 1, 1, 0));
00124 }
00125
00126
00127 fEtaRng = new TEveGDoubleValuator(fDataFrame,"Eta rng:", 40, 0);
00128 fEtaRng->SetNELength(6);
00129 fEtaRng->SetLabelWidth(labelW);
00130 fEtaRng->Build();
00131 fEtaRng->GetSlider()->SetWidth(195);
00132 fEtaRng->SetLimits(-5.5, 5.5, TGNumberFormat::kNESRealTwo);
00133 fEtaRng->Connect("ValueSet()", "TEveCaloVizEditor", this, "DoEtaRange()");
00134 fDataFrame->AddFrame(fEtaRng, new TGLayoutHints(kLHintsTop, 1, 1, 4, 5));
00135
00136
00137 fPhi = new TEveGValuator(fDataFrame, "Phi:", 90, 0);
00138 fPhi->SetLabelWidth(labelW);
00139 fPhi->SetNELength(6);
00140 fPhi->Build();
00141 fPhi->SetLimits(-TMath::Pi(), TMath::Pi(), TGNumberFormat::kNESRealTwo);
00142 fPhi->Connect("ValueSet(Double_t)", "TEveCaloVizEditor", this, "DoPhi()");
00143 fDataFrame->AddFrame(fPhi, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
00144
00145 fPhiOffset = new TEveGValuator(fDataFrame, "PhiOff:", 90, 0);
00146 fPhiOffset->SetLabelWidth(labelW);
00147 fPhiOffset->SetNELength(6);
00148 fPhiOffset->Build();
00149 fPhiOffset->SetLimits(0, TMath::Pi(), TGNumberFormat::kNESRealTwo);
00150 fPhiOffset->Connect("ValueSet(Double_t)", "TEveCaloVizEditor", this, "DoPhi()");
00151 fDataFrame->AddFrame(fPhiOffset, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
00152
00153 fSliceFrame = new TGVerticalFrame(fDataFrame);
00154 fDataFrame->AddFrame(fSliceFrame);
00155 }
00156
00157
00158 void TEveCaloVizEditor::MakeSliceInfo()
00159 {
00160
00161
00162
00163 Int_t ns = fM->GetData()->GetNSlices();
00164 Int_t nf = fSliceFrame->GetList()->GetSize();
00165
00166 if (ns > nf)
00167 {
00168 for (Int_t i=nf; i<ns; ++i)
00169 {
00170 TGHorizontalFrame* f = new TGHorizontalFrame(fSliceFrame);
00171
00172 TEveGValuator* threshold = new TEveGValuator(f,"", 90, 0, i);
00173 threshold->SetLabelWidth(50);
00174 threshold->SetNELength(6);
00175 threshold->SetShowSlider(kFALSE);
00176 threshold->Build();
00177 threshold->SetLimits(0, 1000, TGNumberFormat::kNESRealTwo);
00178 threshold->Connect("ValueSet(Double_t)", "TEveCaloVizEditor", this, "DoSliceThreshold()");
00179 f->AddFrame(threshold, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
00180
00181 TGColorSelect* color = new TGColorSelect(f, 0, i);
00182 f->AddFrame(color, new TGLayoutHints(kLHintsLeft|kLHintsTop, 3, 1, 0, 1));
00183 color->Connect("ColorSelected(Pixel_t)", "TEveCaloVizEditor", this, "DoSliceColor(Pixel_t)");
00184
00185 TGNumberEntry* transparency = new TGNumberEntry(f, 0., 2, i,
00186 TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative,
00187 TGNumberFormat::kNELLimitMinMax, 0, 100);
00188 transparency->SetHeight(18);
00189 transparency->GetNumberEntry()->SetToolTipText("Transparency: 0 is opaque, 100 fully transparent.");
00190 f->AddFrame(transparency, new TGLayoutHints(kLHintsLeft, 0, 0, 0, 0));
00191 transparency->Connect("ValueSet(Long_t)", "TEveCaloVizEditor", this, "DoSliceTransparency(Long_t)");
00192
00193
00194 fSliceFrame->AddFrame(f, new TGLayoutHints(kLHintsTop, 1, 1, 1, 0));
00195 }
00196 nf = ns;
00197 }
00198
00199 TIter frame_iterator(fSliceFrame->GetList());
00200 for (Int_t i=0; i<nf; ++i)
00201 {
00202 TGFrameElement *el = (TGFrameElement*) frame_iterator();
00203 TGHorizontalFrame *fr = (TGHorizontalFrame*) el->fFrame;
00204 if (i < ns)
00205 {
00206 TEveCaloData::SliceInfo_t &si = fM->GetData()->RefSliceInfo(i);
00207
00208 TEveGValuator *threshold = (TEveGValuator*) ((TGFrameElement*) fr->GetList()->At(0))->fFrame;
00209 TGColorSelect *color = (TGColorSelect*) ((TGFrameElement*) fr->GetList()->At(1) )->fFrame;
00210 TGNumberEntry *transp = (TGNumberEntry*) ((TGFrameElement*) fr->GetList()->At(2))->fFrame;
00211
00212 threshold->GetLabel()->SetText(si.fName);
00213 threshold->SetValue(si.fThreshold);
00214 color->SetColor(TColor::Number2Pixel(si.fColor), kFALSE);
00215 transp->SetNumber(si.fTransparency);
00216
00217 if (! fr->IsMapped()) {
00218 fr->MapSubwindows();
00219 fr->MapWindow();
00220 }
00221 }
00222 else
00223 {
00224 if (fr->IsMapped()) {
00225 fr->UnmapWindow();
00226 }
00227 }
00228 }
00229 }
00230
00231
00232 void TEveCaloVizEditor::SetModel(TObject* obj)
00233 {
00234
00235
00236 fM = dynamic_cast<TEveCaloViz*>(obj);
00237 if (fM->GetPlotEt())
00238 {
00239 fPlotEt->SetState(kButtonDown, kFALSE);
00240 fPlotE->SetState(kButtonUp, kFALSE);
00241 }
00242 else
00243 {
00244 fPlotE->SetState(kButtonDown, kFALSE);
00245 fPlotEt->SetState(kButtonUp, kFALSE);
00246 }
00247
00248 if (fM->fData)
00249 {
00250 TGCompositeFrame* p = GetGedEditor()->GetEditorTab("Data");
00251 if (p->GetList()->IsEmpty())
00252 {
00253 p->MapWindow();
00254 p->MapSubwindows();
00255 }
00256
00257 fScaleAbs->SetState(fM->GetScaleAbs() ? kButtonDown : kButtonUp);
00258 fMaxValAbs->SetValue(fM->GetMaxValAbs());
00259 fMaxTowerH->SetValue(fM->GetMaxTowerH());
00260
00261 Double_t min, max;
00262 fM->GetData()->GetEtaLimits(min, max);
00263 fEtaRng->SetLimits((Float_t)min, (Float_t)max);
00264 fEtaRng->SetValues(fM->fEtaMin, fM->fEtaMax);
00265
00266 fM->GetData()->GetPhiLimits(min, max);
00267 fPhi->SetLimits(min, max, 101, TGNumberFormat::kNESRealTwo);
00268 fPhi->SetValue(fM->fPhi);
00269 if ( fM->GetData()->GetWrapTwoPi())
00270 {
00271 fPhi->SetToolTip("Center angle in radians");
00272 fPhiOffset->SetLimits(1e-3, TMath::Pi(), 101, TGNumberFormat::kNESRealTwo);
00273 }
00274 else
00275 {
00276 Float_t d = (max-min)*0.5;
00277 fPhiOffset->SetLimits(1e-3, d, 101, TGNumberFormat::kNESRealTwo);
00278 }
00279 fPhiOffset->SetValue(fM->fPhiOffset);
00280 fPhiOffset->SetToolTip("Phi range in radians");
00281
00282 MakeSliceInfo();
00283 }
00284 else
00285 {
00286
00287 fDataFrame->UnmapWindow();
00288 }
00289 }
00290
00291
00292 void TEveCaloVizEditor::DoMaxTowerH()
00293 {
00294
00295
00296 fM->SetMaxTowerH(fMaxTowerH->GetValue());
00297 Update();
00298 }
00299
00300
00301 void TEveCaloVizEditor::DoScaleAbs()
00302 {
00303
00304
00305 fM->SetScaleAbs(fScaleAbs->IsOn());
00306 Update();
00307 }
00308
00309
00310 void TEveCaloVizEditor::DoMaxValAbs()
00311 {
00312
00313
00314 fM->SetMaxValAbs(fMaxValAbs->GetValue());
00315 Update();
00316 }
00317
00318
00319 void TEveCaloVizEditor::DoPlot()
00320 {
00321
00322
00323 TGButton *btn = (TGButton *) gTQSender;
00324 Int_t id = btn->WidgetId();
00325
00326 if (id == fPlotE->WidgetId())
00327 fPlotEt->SetState(kButtonUp);
00328 else
00329 fPlotE->SetState(kButtonUp);
00330
00331 fM->SetPlotEt(fPlotEt->IsDown());
00332 Update();
00333 }
00334
00335
00336 void TEveCaloVizEditor::DoEtaRange()
00337 {
00338
00339
00340 fM->SetEta(fEtaRng->GetMin(), fEtaRng->GetMax());
00341 Update();
00342 }
00343
00344
00345 void TEveCaloVizEditor::DoPhi()
00346 {
00347
00348
00349 fM->SetPhiWithRng(fPhi->GetValue(), fPhiOffset->GetValue());
00350 Update();
00351 }
00352
00353
00354 void TEveCaloVizEditor::DoSliceThreshold()
00355 {
00356
00357
00358 TEveGValuator *st = (TEveGValuator *) gTQSender;
00359 fM->SetDataSliceThreshold(st->WidgetId(), st->GetValue());
00360 Update();
00361 }
00362
00363
00364 void TEveCaloVizEditor::DoSliceColor(Pixel_t pixel)
00365 {
00366
00367
00368 TGColorSelect *cs = (TGColorSelect *) gTQSender;
00369 fM->SetDataSliceColor(cs->WidgetId(), Color_t(TColor::GetColor(pixel)));
00370 Update();
00371 }
00372
00373
00374 void TEveCaloVizEditor::DoSliceTransparency(Long_t t)
00375 {
00376
00377
00378 TGNumberEntry *cs = (TGNumberEntry*) gTQSender;
00379 fM->GetData()->SetSliceTransparency(cs->WidgetId(), t);
00380 Update();
00381 }
00382
00383
00384
00385
00386
00387
00388
00389
00390 ClassImp(TEveCalo3DEditor);
00391
00392
00393 TEveCalo3DEditor::TEveCalo3DEditor(const TGWindow *p, Int_t width, Int_t height,
00394 UInt_t options, Pixel_t back) :
00395 TGedFrame(p, width, height, options | kVerticalFrame, back),
00396 fM(0),
00397 fFrameTransparency(0)
00398 {
00399
00400
00401 MakeTitle("TEveCalo3D");
00402
00403 TGHorizontalFrame* f = new TGHorizontalFrame(this);
00404 TGLabel* lab = new TGLabel(f, "Frame transparency: ");
00405 f->AddFrame(lab, new TGLayoutHints(kLHintsLeft|kLHintsBottom, 1, 1, 1, 1));
00406
00407 fFrameTransparency = new TGNumberEntry(f, 0., 2, -1,
00408 TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative,
00409 TGNumberFormat::kNELLimitMinMax, 0, 100);
00410
00411 fFrameTransparency->SetHeight(18);
00412 fFrameTransparency->GetNumberEntry()->SetToolTipText("Transparency: 0 is opaque, 100 fully transparent.");
00413 f->AddFrame(fFrameTransparency, new TGLayoutHints(kLHintsLeft, 0, 0, 0, 0));
00414 fFrameTransparency->Connect("ValueSet(Long_t)","TEveCalo3DEditor", this, "DoFrameTransparency()");
00415
00416 AddFrame(f, new TGLayoutHints(kLHintsTop, 1, 1, 1, 0));
00417 }
00418
00419
00420 void TEveCalo3DEditor::SetModel(TObject* obj)
00421 {
00422
00423
00424 fM = dynamic_cast<TEveCalo3D*>(obj);
00425 fFrameTransparency->SetNumber(fM->GetFrameTransparency());
00426 }
00427
00428
00429 void TEveCalo3DEditor::DoFrameTransparency()
00430 {
00431
00432
00433 fM->SetFrameTransparency((Char_t)(fFrameTransparency->GetNumber()));
00434 Update();
00435 }