54 TGButtonGroup *mainBar=0;
56 TVirtualPad *qPad(){
return TVirtualPad::Pad() ;}
67 void AddButt(
const Char_t *buttonName,
const Char_t *command)
69 TGTextButton *tb =
new TGTextButton(fBar,buttonName,command);
70 fBar->AddFrame(tb,fL1);
80 const char *fills[] = {
81 "Black background",
"StPadControlPanel::SetBackround(kBlack);"
82 ,
"White background",
"StPadControlPanel::SetBackround (19);"
83 ,
"Adjust scales",
"StPadControlPanel::AdjustScales ();"
84 ,
"Centered",
"StPadControlPanel::Centered3DImages();"
85 ,
"Scale +",
"StPadControlPanel::Inscrease3DScale();"
86 ,
"Scale -",
"StPadControlPanel::Decrease3DScale ();"
87 ,
"Top View (X-Y)",
"StPadControlPanel::TopView ();"
88 ,
"Side View (Y-Z)",
"StPadControlPanel::SideView ();"
89 ,
"Front View (X-Z)",
"StPadControlPanel::FrontView ();"
90 ,
"4 views",
"StPadControlPanel::MakeFourView();"
91 ,
"Add Axes",
"StPadControlPanel::AddAxes ();"
92 ,
"Rulers",
"StPadControlPanel::ToggleRulers();"
93 ,
"Zoom",
"StPadControlPanel::ToggleZoom ();"
94 ,
"ReDraw canvas",
"StEventDisplayMaker::MakeLoop(1);"
95 ,
"Next event",
"StEventDisplayMaker::MakeLoop(2);"
96 ,
"End of Chain",
"StEventDisplayMaker::MakeLoop(3);"
100 fBar =
new TGButtonGroup(gClient->GetRoot(),
"Pad Control Panel");
102 gVirtualX->SetWindowName(fBar->GetId(),
"Pad");
103 fL1 =
new TGLayoutHints(kLHintsCenterY | kLHintsExpandX, 1, 1, 1, 1);
104 for (
int i=0;fills[i];i+=2) {AddButt(fills[i],fills[i+1]);}
111 TGButtonGroup *Bar()
const {
return fBar;}
114 static void SetBackround(Color_t color, TVirtualPad *pad=0)
116 TVirtualPad *thisPad = pad;
117 if (!thisPad) thisPad = qPad();
119 thisPad->SetFillColor(color);
126 static void SetBackroundStyle(TVirtualPad *pad=0)
128 TVirtualPad *thisPad = pad;
129 if (!thisPad) thisPad = qPad();
130 if (thisPad) thisPad->SetFillAttributes();
134 static void RotateView(Float_t phi, Float_t theta, TVirtualPad *pad=0)
136 TVirtualPad *thisPad = pad;
137 if (!thisPad) thisPad = qPad();
139 TView *view = thisPad->GetView();
144 view->SetView(p, t, 0, iret);
145 thisPad->SetPhi(-90-p);
146 thisPad->SetTheta(90-t);
154 static void SideView(TVirtualPad *pad=0){
155 RotateView(0,90.0,pad);
158 static void FrontView(TVirtualPad *pad=0){
159 RotateView(270.0,90.0,pad);
162 static void TopView(TVirtualPad *pad=0){
163 RotateView(270.0,0.0,pad);
166 static void ToggleRulers(TVirtualPad *pad=0)
168 TAxis3D::ToggleRulers(pad);
172 static void ToggleZoom(TVirtualPad *pad=0)
174 TAxis3D::ToggleZoom(pad);
178 static void AddGrid()
180 TVirtualPad *thisPad = qPad();
184 TView *view = thisPad->GetView();
186 Double_t min[3],max[3];
187 view->GetRange(min,max);
189 TList *list = thisPad->GetListOfPrimitives();
190 TString histName = thisPad->GetName();
191 TH2F *m_DummyHist = 0;
192 const Char_t *dummyName =
"Axis3D";
193 histName += dummyName;
194 m_DummyHist = list->FindObject(histName.Data());
196 m_DummyHist =
new TH2F(histName.Data(),
"",1,min[0],max[0],1,min[1],max[1]);
197 m_DummyHist->SetDirectory(0);
198 m_DummyHist->Draw(
"surf,same");
200 m_DummyHist->GetXaxis()->SetLimits(min[0],max[0]);
201 m_DummyHist->GetYaxis()->SetLimits(min[1],max[1]);
202 m_DummyHist->GetZaxis()->SetLimits(min[2],max[2]);
209 static void AdjustScales()
211 TVirtualPad *thisPad = qPad();
213 TView *view = thisPad->GetView();
215 Double_t min[3],max[3];
216 view->GetRange(min,max);
218 Double_t maxSide = 0;
220 for (i=0;i<3; i++) maxSide = TMath::Max(maxSide,max[i]-min[i]);
222 for (i=0;i<3; i++) max[i] += maxSide - (max[i]-min[i]);
223 view->SetRange(min,max);
229 static void Centered3DImages()
232 TVirtualPad *thisPad = qPad();
234 TView *view = thisPad->GetView();
236 Double_t min[3],max[3];
237 view->GetRange(min,max);
239 for (i=0;i<3; i++) min[i]=-max[i];
240 view->SetRange(min,max);
247 static void Decrease3DScale()
249 TVirtualPad *thisPad = qPad();
251 TView *view = thisPad->GetView();
253 Double_t min[3],max[3];
254 view->GetRange(min,max);
256 for (i=0;i<3; i++) {max[i] /= 0.8; min[i]=max[i]*0.1;}
257 view->SetRange(min,max);
264 static void Inscrease3DScale()
266 TVirtualPad *thisPad = qPad();
268 TView *view = thisPad->GetView();
270 Double_t min[3],max[3];
271 view->GetRange(min,max);
273 for (i=0;i<3; i++) {max[i] *= 0.8; min[i]=max[i]*0.1;}
274 view->SetRange(min,max);
280 void MakeFourView(TVirtualPad *pad=0)
304 TVirtualPad *thisPad = pad;
305 if (!thisPad) thisPad = qPad();
307 TList *thisPrimitives = 0;
308 if (thisPad && (thisPrimitives = thisPad->GetListOfPrimitives()) && (view = thisPad->GetView()) )
310 Double_t min[3],max[3];
311 view->GetRange(min,max);
312 Int_t system = view->GetSystem();
313 TCanvas *c =
new TCanvas(
" 4 views", thisPad->GetTitle(),600,600);
315 TIter *next=
new TIter(thisPrimitives);
316 for (
int i =1; i <= 4; i++) {
318 TList *newPrimitives = qPad()->GetListOfPrimitives();
320 while (obj = next->Next()) newPrimitives->Add(obj);
321 TView *newView =
new TView(system);
322 newView->SetRange(min,max);
329 c->cd(j++); FrontView();
330 c->cd(j++); TopView();
331 c->cd(j++); SideView();
332 c->cd(j++); RotateView(-30.0,60.0,0);
338 void AddAxes(TVirtualPad *pad=0)
341 TVirtualPad *thisPad = pad;
342 if (!thisPad) thisPad = qPad();
344 if (!gROOT->GetClass(
"St_PolyLine3D")) gSystem->Load(
"St_base");
345 if ( gROOT->GetClass(
"St_PolyLine3D")) gROOT->ProcessLineFast(
"St_PolyLine3D::Axis();");