00001
00002
00003
00004
00005
00006
00007
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00046
00048
00049
00050
00051
00052
00054 TGButtonGroup *mainBar=0;
00055
00056 TVirtualPad *qPad(){ return TVirtualPad::Pad() ;}
00057
00058 class StPadControlPanel {
00059 private:
00060 TGButtonGroup *fBar;
00061 TGLayoutHints *fL1;
00062
00063 protected:
00064
00065
00066
00067 void AddButt(const Char_t *buttonName, const Char_t *command)
00068 {
00069 TGTextButton *tb = new TGTextButton(fBar,buttonName,command);
00070 fBar->AddFrame(tb,fL1);
00071 }
00072
00073 public:
00074
00075
00076 StPadControlPanel() { Build();}
00077
00078 void Build()
00079 {
00080 const char *fills[] = {
00081 "Black background", "StPadControlPanel::SetBackround(kBlack);"
00082 ,"White background", "StPadControlPanel::SetBackround (19);"
00083 ,"Adjust scales", "StPadControlPanel::AdjustScales ();"
00084 ,"Centered", "StPadControlPanel::Centered3DImages();"
00085 ,"Scale +", "StPadControlPanel::Inscrease3DScale();"
00086 ,"Scale -", "StPadControlPanel::Decrease3DScale ();"
00087 ,"Top View (X-Y)", "StPadControlPanel::TopView ();"
00088 ,"Side View (Y-Z)", "StPadControlPanel::SideView ();"
00089 ,"Front View (X-Z)", "StPadControlPanel::FrontView ();"
00090 ,"4 views", "StPadControlPanel::MakeFourView();"
00091 ,"Add Axes", "StPadControlPanel::AddAxes ();"
00092 ,"Rulers", "StPadControlPanel::ToggleRulers();"
00093 ,"Zoom", "StPadControlPanel::ToggleZoom ();"
00094 ,"ReDraw canvas", "StEventDisplayMaker::MakeLoop(1);"
00095 ,"Next event", "StEventDisplayMaker::MakeLoop(2);"
00096 ,"End of Chain", "StEventDisplayMaker::MakeLoop(3);"
00097 ,0};
00098
00099
00100 fBar = new TGButtonGroup(gClient->GetRoot(), "Pad Control Panel");
00101 mainBar=fBar;
00102 gVirtualX->SetWindowName(fBar->GetId(),"Pad");
00103 fL1 = new TGLayoutHints(kLHintsCenterY | kLHintsExpandX, 1, 1, 1, 1);
00104 for (int i=0;fills[i];i+=2) {AddButt(fills[i],fills[i+1]);}
00105
00106 fBar->Show();
00107 }
00108
00109 ~StPadControlPanel(){ delete fBar; delete fL1;}
00110
00111 TGButtonGroup *Bar() const { return fBar;}
00112
00113
00114 static void SetBackround(Color_t color, TVirtualPad *pad=0)
00115 {
00116 TVirtualPad *thisPad = pad;
00117 if (!thisPad) thisPad = qPad();
00118 if (thisPad) {
00119 thisPad->SetFillColor(color);
00120 thisPad->Modified();
00121 thisPad->Update();
00122 }
00123 }
00124
00125
00126 static void SetBackroundStyle(TVirtualPad *pad=0)
00127 {
00128 TVirtualPad *thisPad = pad;
00129 if (!thisPad) thisPad = qPad();
00130 if (thisPad) thisPad->SetFillAttributes();
00131 }
00132
00133
00134 static void RotateView(Float_t phi, Float_t theta, TVirtualPad *pad=0)
00135 {
00136 TVirtualPad *thisPad = pad;
00137 if (!thisPad) thisPad = qPad();
00138 if (thisPad) {
00139 TView *view = thisPad->GetView();
00140 if (view) {
00141 Int_t iret;
00142 Float_t p = phi;
00143 Float_t t = theta;
00144 view->SetView(p, t, 0, iret);
00145 thisPad->SetPhi(-90-p);
00146 thisPad->SetTheta(90-t);
00147 thisPad->Modified();
00148 thisPad->Update();
00149 }
00150 }
00151 }
00152
00153
00154 static void SideView(TVirtualPad *pad=0){
00155 RotateView(0,90.0,pad);
00156 }
00157
00158 static void FrontView(TVirtualPad *pad=0){
00159 RotateView(270.0,90.0,pad);
00160 }
00161
00162 static void TopView(TVirtualPad *pad=0){
00163 RotateView(270.0,0.0,pad);
00164 }
00165
00166 static void ToggleRulers(TVirtualPad *pad=0)
00167 {
00168 TAxis3D::ToggleRulers(pad);
00169 }
00170
00171
00172 static void ToggleZoom(TVirtualPad *pad=0)
00173 {
00174 TAxis3D::ToggleZoom(pad);
00175 }
00176
00177
00178 static void AddGrid()
00179 {
00180 TVirtualPad *thisPad = qPad();
00181
00182 if (thisPad) {
00183
00184 TView *view = thisPad->GetView();
00185 if (!view) return;
00186 Double_t min[3],max[3];
00187 view->GetRange(min,max);
00188
00189 TList *list = thisPad->GetListOfPrimitives();
00190 TString histName = thisPad->GetName();
00191 TH2F *m_DummyHist = 0;
00192 const Char_t *dummyName = "Axis3D";
00193 histName += dummyName;
00194 m_DummyHist = list->FindObject(histName.Data());
00195 if (!m_DummyHist) {
00196 m_DummyHist = new TH2F(histName.Data(),"",1,min[0],max[0],1,min[1],max[1]);
00197 m_DummyHist->SetDirectory(0);
00198 m_DummyHist->Draw("surf,same");
00199 }
00200 m_DummyHist->GetXaxis()->SetLimits(min[0],max[0]);
00201 m_DummyHist->GetYaxis()->SetLimits(min[1],max[1]);
00202 m_DummyHist->GetZaxis()->SetLimits(min[2],max[2]);
00203
00204 thisPad->Modified();
00205 thisPad->Update();
00206 }
00207 }
00208
00209 static void AdjustScales()
00210 {
00211 TVirtualPad *thisPad = qPad();
00212 if (thisPad) {
00213 TView *view = thisPad->GetView();
00214 if (!view) return;
00215 Double_t min[3],max[3];
00216 view->GetRange(min,max);
00217 int i;
00218 Double_t maxSide = 0;
00219
00220 for (i=0;i<3; i++) maxSide = TMath::Max(maxSide,max[i]-min[i]);
00221
00222 for (i=0;i<3; i++) max[i] += maxSide - (max[i]-min[i]);
00223 view->SetRange(min,max);
00224 thisPad->Modified();
00225 thisPad->Update();
00226 }
00227 }
00228
00229 static void Centered3DImages()
00230 {
00231
00232 TVirtualPad *thisPad = qPad();
00233 if (thisPad) {
00234 TView *view = thisPad->GetView();
00235 if (!view) return;
00236 Double_t min[3],max[3];
00237 view->GetRange(min,max);
00238 int i;
00239 for (i=0;i<3; i++) min[i]=-max[i];
00240 view->SetRange(min,max);
00241 thisPad->Modified();
00242 thisPad->Update();
00243 }
00244 }
00245
00246
00247 static void Decrease3DScale()
00248 {
00249 TVirtualPad *thisPad = qPad();
00250 if (thisPad) {
00251 TView *view = thisPad->GetView();
00252 if (!view) return;
00253 Double_t min[3],max[3];
00254 view->GetRange(min,max);
00255 int i;
00256 for (i=0;i<3; i++) {max[i] /= 0.8; min[i]=max[i]*0.1;}
00257 view->SetRange(min,max);
00258 thisPad->Modified();
00259 thisPad->Update();
00260 }
00261 }
00262
00263
00264 static void Inscrease3DScale()
00265 {
00266 TVirtualPad *thisPad = qPad();
00267 if (thisPad) {
00268 TView *view = thisPad->GetView();
00269 if (!view) return;
00270 Double_t min[3],max[3];
00271 view->GetRange(min,max);
00272 int i;
00273 for (i=0;i<3; i++) {max[i] *= 0.8; min[i]=max[i]*0.1;}
00274 view->SetRange(min,max);
00275 thisPad->Modified();
00276 thisPad->Update();
00277 }
00278 }
00279
00280 void MakeFourView(TVirtualPad *pad=0)
00281 {
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304 TVirtualPad *thisPad = pad;
00305 if (!thisPad) thisPad = qPad();
00306 TView *view = 0;
00307 TList *thisPrimitives = 0;
00308 if (thisPad && (thisPrimitives = thisPad->GetListOfPrimitives()) && (view = thisPad->GetView()) )
00309 {
00310 Double_t min[3],max[3];
00311 view->GetRange(min,max);
00312 Int_t system = view->GetSystem();
00313 TCanvas *c = new TCanvas(" 4 views", thisPad->GetTitle(),600,600);
00314 c->Divide(2,2);
00315 TIter *next= new TIter(thisPrimitives);
00316 for (int i =1; i <= 4; i++) {
00317 c->cd(i);
00318 TList *newPrimitives = qPad()->GetListOfPrimitives();
00319 TObject *obj = 0;
00320 while (obj = next->Next()) newPrimitives->Add(obj);
00321 TView *newView = new TView(system);
00322 newView->SetRange(min,max);
00323 next->Reset();
00324 }
00325 delete next;
00326
00327
00328 Int_t j = 1;
00329 c->cd(j++); FrontView();
00330 c->cd(j++); TopView();
00331 c->cd(j++); SideView();
00332 c->cd(j++); RotateView(-30.0,60.0,0);
00333 c->Modified();
00334 c->Update();
00335 }
00336 }
00337
00338 void AddAxes(TVirtualPad *pad=0)
00339 {
00340
00341 TVirtualPad *thisPad = pad;
00342 if (!thisPad) thisPad = qPad();
00343 if (thisPad) {
00344 if (!gROOT->GetClass("St_PolyLine3D")) gSystem->Load("St_base");
00345 if ( gROOT->GetClass("St_PolyLine3D")) gROOT->ProcessLineFast("St_PolyLine3D::Axis();");
00346 }
00347 }
00348 };
00349
00350 StPadControlPanel __StPadControlPanel__;
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390
00391
00392
00393
00394
00395
00396
00397
00398
00399
00400
00401
00402
00403
00404
00405
00406
00407
00408
00409
00410
00411
00412
00413
00414