00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "TGo4PreviewPanelStatus.h"
00017
00018 #include <iostream.h>
00019
00020 #include "TPad.h"
00021 #include "TCanvas.h"
00022 #include "TRefArray.h"
00023 #include "TList.h"
00024
00025 #include "TGo4PreviewPanelSlots.h"
00026 #include "TGo4PadOptions.h"
00027
00028 TGo4PreviewPanelStatus::TGo4PreviewPanelStatus(const char* name, const char* title)
00029 :TGo4Status(name, title), fxSlots(0)
00030 {
00031 PadOptionList= new TList;
00032 listiter = PadOptionList->MakeIterator();
00033 ListOfPads= new TRefArray();
00034 }
00035
00036 TGo4PreviewPanelStatus::~TGo4PreviewPanelStatus()
00037 {
00038
00039
00040 PadOptionList->Delete();
00041 delete PadOptionList;
00042 delete listiter;
00043
00044 delete ListOfPads;
00045 }
00046
00047 void TGo4PreviewPanelStatus::SetPadDrawOption(TPad * SelectedPad, const char *Option, bool DragAddOption)
00048 {
00049 TObject *entry;
00050 bool IntheList=kFALSE;
00051
00052 listiter->Reset();
00053 while((entry=listiter->Next()) !=0) {
00054 if(((TGo4PadOptions *)entry)->fxPad==SelectedPad){
00055 IntheList=kTRUE;
00056
00057 (dynamic_cast<TGo4PadOptions *>(entry))->fxDragAddOption=DragAddOption;
00058 (dynamic_cast<TGo4PadOptions *>(entry))->setHisDrawStyle(Option);
00059
00060 }
00061 }
00062 if(!IntheList){
00063
00064
00065
00066 fxTGo4PadOptions= new TGo4PadOptions(SelectedPad,Option, DragAddOption);
00067 PadOptionList->Add(fxTGo4PadOptions);
00068 ListOfPads->AddLast(SelectedPad);
00069 }
00070 }
00071
00072 void TGo4PreviewPanelStatus::SetPadDrawOption(TPad * SelectedPad, const char *Option)
00073 {
00074 TObject *entry;
00075 bool IntheList=kFALSE;
00076
00077 listiter->Reset();
00078 while((entry=listiter->Next()) !=0) {
00079 if(((TGo4PadOptions *)entry)->fxPad==SelectedPad){
00080 IntheList=kTRUE;
00081 (dynamic_cast<TGo4PadOptions *>(entry))->setHisDrawStyle(Option);
00082 }
00083 }
00084 if(!IntheList){
00085
00086 fxTGo4PadOptions= new TGo4PadOptions(SelectedPad,Option);
00087 PadOptionList->Add(fxTGo4PadOptions);
00088 ListOfPads->AddLast(SelectedPad);
00089 }
00090 }
00091
00092
00093
00094 void TGo4PreviewPanelStatus::SetPadDrawOption(TPad * SelectedPad, Int_t Xmin, Int_t Xmax, Int_t Ymin, Int_t Ymax)
00095 {
00096 if(SelectedPad==0) return;
00097 TObject *entry=0;
00098 TGo4PadOptions* pop=0;
00099 bool IntheList=kFALSE;
00100 listiter->Reset();
00101 while((entry=listiter->Next()) !=0)
00102 {
00103 pop=dynamic_cast<TGo4PadOptions*>(entry);
00104 if(pop && pop->fxPad==SelectedPad)
00105 {
00106 IntheList=kTRUE;
00107 break;
00108 }
00109 }
00110 if(!IntheList){
00111 pop= new TGo4PadOptions(SelectedPad,"");
00112 PadOptionList->Add(pop);
00113 ListOfPads->AddLast(SelectedPad);
00114 }
00115 pop->SetHistogramFullRange(Xmin,Xmax,Ymin,Ymax);
00116 Int_t xlog=SelectedPad->GetLogx();
00117 Int_t ylog=SelectedPad->GetLogy();
00118 Int_t zlog=SelectedPad->GetLogz();
00119 pop->SetHisXStyle(xlog);
00120 pop->SetHisYStyle(ylog);
00121 pop->SetHisZStyle(zlog);
00122
00123 }
00124
00125 void TGo4PreviewPanelStatus::SetPadHistogramStats(TPad * SelectedPad, Bool_t showstatistics)
00126 {
00127 TObject *entry;
00128 bool IntheList=kFALSE;
00129
00130 listiter->Reset();
00131 while((entry=listiter->Next()) !=0) {
00132 if(((TGo4PadOptions *)entry)->fxPad==SelectedPad){
00133 IntheList=kTRUE;
00134 (dynamic_cast<TGo4PadOptions *>(entry))->SetHisStats(showstatistics);
00135 }
00136 }
00137 if(!IntheList){
00138 fxTGo4PadOptions= new TGo4PadOptions(SelectedPad,"");
00139 fxTGo4PadOptions->SetHisStats(showstatistics);
00140 PadOptionList->Add(fxTGo4PadOptions);
00141 ListOfPads->AddLast(SelectedPad);
00142
00143 }
00144
00145 }
00146
00147
00148 Bool_t TGo4PreviewPanelStatus::GetPadHistogramStats(TPad * SelectedPad)
00149 {
00150 TObject *entry;
00151
00152 Bool_t showstatistics=kTRUE;
00153 listiter->Reset();
00154 while((entry=listiter->Next()) !=0) {
00155 if(((TGo4PadOptions *)entry)->fxPad==SelectedPad){
00156 showstatistics =(dynamic_cast <TGo4PadOptions *> (entry))->IsHisStats();
00157 }
00158 }
00159 return showstatistics;
00160
00161 }
00162
00163 void TGo4PreviewPanelStatus::SetPadHistogramTitle(TPad * SelectedPad, Bool_t showtitle)
00164 {
00165 TObject *entry;
00166 bool IntheList=kFALSE;
00167
00168 listiter->Reset();
00169 while((entry=listiter->Next()) !=0) {
00170 if(((TGo4PadOptions *)entry)->fxPad==SelectedPad){
00171 IntheList=kTRUE;
00172 (dynamic_cast<TGo4PadOptions *>(entry))->SetHisTitle(showtitle);
00173 }
00174 }
00175 if(!IntheList){
00176 fxTGo4PadOptions= new TGo4PadOptions(SelectedPad,"");
00177 fxTGo4PadOptions->SetHisTitle(showtitle);
00178 PadOptionList->Add(fxTGo4PadOptions);
00179 ListOfPads->AddLast(SelectedPad);
00180 }
00181 }
00182
00183
00184 Bool_t TGo4PreviewPanelStatus::GetPadHistogramTitle(TPad * SelectedPad)
00185 {
00186 TObject *entry;
00187
00188 Bool_t showtitle=kTRUE;
00189 listiter->Reset();
00190 while((entry=listiter->Next()) !=0) {
00191 if(((TGo4PadOptions *)entry)->fxPad==SelectedPad){
00192 showtitle =(dynamic_cast <TGo4PadOptions *> (entry))->IsHisTitle();
00193 }
00194 }
00195 return showtitle;
00196
00197 }
00198
00200 void TGo4PreviewPanelStatus::SetPadLegend(TPad * SelectedPad, Bool_t drawlegend)
00201 {
00202 TObject *entry;
00203 bool IntheList=kFALSE;
00204
00205 listiter->Reset();
00206 while((entry=listiter->Next()) !=0) {
00207 if(((TGo4PadOptions *)entry)->fxPad==SelectedPad){
00208 IntheList=kTRUE;
00209 (dynamic_cast<TGo4PadOptions *>(entry))->SetLegendDraw(drawlegend);
00210 }
00211 }
00212 if(!IntheList){
00213 fxTGo4PadOptions= new TGo4PadOptions(SelectedPad,"");
00214 fxTGo4PadOptions->SetLegendDraw(drawlegend);
00215 PadOptionList->Add(fxTGo4PadOptions);
00216 ListOfPads->AddLast(SelectedPad);
00217
00218 }
00219 }
00220
00221
00222 Bool_t TGo4PreviewPanelStatus::GetPadLegend(TPad * SelectedPad)
00223 {
00224 TObject *entry;
00225
00226 Bool_t showstatistics=kTRUE;
00227 listiter->Reset();
00228 while((entry=listiter->Next()) !=0) {
00229 if(((TGo4PadOptions *)entry)->fxPad==SelectedPad){
00230 showstatistics =(dynamic_cast <TGo4PadOptions *> (entry))->IsLegendDraw();
00231 }
00232 }
00233 return showstatistics;
00234
00235 }
00236
00237
00238
00239
00240
00241
00242
00243
00244 void TGo4PreviewPanelStatus::SetPadCrosshair(TPad * SelectedPad, Bool_t showcross)
00245 {
00246
00247
00248
00249 TObject *entry;
00250 bool IntheList=kFALSE;
00251
00252 listiter->Reset();
00253 while((entry=listiter->Next()) !=0) {
00254 TGo4PadOptions* popt=dynamic_cast<TGo4PadOptions *>(entry);
00255 if(popt->fxPad==SelectedPad)
00256 {
00257 IntheList=kTRUE;
00258 popt->SetCrosshair(showcross);
00259 }
00260 #if __GO4ROOTVERSION__ >= 40008
00261 else
00262 {
00263 popt->SetCrosshair(showcross);
00264 }
00265
00266 #endif
00267 }
00268 if(!IntheList){
00269 fxTGo4PadOptions= new TGo4PadOptions(SelectedPad,"");
00270 fxTGo4PadOptions->SetCrosshair(showcross);
00271 PadOptionList->Add(fxTGo4PadOptions);
00272 ListOfPads->AddLast(SelectedPad);
00273
00274 }
00275 SelectedPad->SetCrosshair(showcross);
00276 #if __GO4ROOTVERSION__ >= 40008
00277
00278
00279
00280 #endif
00281 SelectedPad->Modified();
00282 SelectedPad->Update();
00283
00284
00285 #if __GO4ROOTVERSION__ < 40008
00286
00287
00288
00289 TObject* obj=0;
00290 TIter next(SelectedPad->GetListOfPrimitives());
00291 while ((obj = next()))
00292 {
00293 if (obj->InheritsFrom(TPad::Class()))
00294 {
00295 TPad *pad = dynamic_cast<TPad*>(obj);
00296 pad->SetCrosshair(showcross);
00297 pad->Modified();
00298 pad->Update();
00299 SetPadCrosshair(pad,showcross);
00300 }
00301 }
00302 #endif
00303
00304 }
00305
00306
00307 Bool_t TGo4PreviewPanelStatus::GetPadCrosshair(TPad * SelectedPad)
00308 {
00309 TObject *entry;
00310
00311 Bool_t showstatistics=kTRUE;
00312 listiter->Reset();
00313 while((entry=listiter->Next()) !=0) {
00314 if(((TGo4PadOptions *)entry)->fxPad==SelectedPad){
00315 showstatistics =(dynamic_cast <TGo4PadOptions *> (entry))->IsCrosshair();
00316 }
00317 }
00318 return showstatistics;
00319
00320 }
00321
00322
00323
00324 Bool_t TGo4PreviewPanelStatus::GetPadDragOption(TPad *SelectedPad)
00325 {
00326 TObject *entry;
00327
00328 bool Option=kFALSE;
00329 listiter->Reset();
00330 while((entry=listiter->Next()) !=0) {
00331 if(((TGo4PadOptions *)entry)->fxPad==SelectedPad){
00332 Option =((TGo4PadOptions *)entry)->fxDragAddOption;
00333 }
00334 }
00335
00336 return Option;
00337 }
00338
00339 TGo4PadOptions * TGo4PreviewPanelStatus::GetPadOptions(TPad * Pad)
00340 {
00341 TObject *entry;
00342
00343 TGo4PadOptions *DrawOption=0;
00344 listiter->Reset();
00345 while((entry=listiter->Next()) !=0) {
00346 if(((TGo4PadOptions *)entry)->fxPad==Pad){
00347 DrawOption =dynamic_cast <TGo4PadOptions *> (entry);
00348 break;
00349 }
00350 }
00351 return DrawOption;
00352 }
00353
00354 const char * TGo4PreviewPanelStatus::GetPadStringDrawOption(TPad *SelectedPad)
00355 {
00356 TObject *entry;
00357
00358
00359 const char *Option = 0;
00360 listiter->Reset();
00361 while((entry=listiter->Next()) !=0) {
00362 if(((TGo4PadOptions *)entry)->fxPad==SelectedPad){
00363 Option =(dynamic_cast <TGo4PadOptions *> (entry))->GetStringDrawOption()->Data();
00364 }
00365 }
00366 return Option;
00367 }
00368
00369 TRefArray* TGo4PreviewPanelStatus::GetListOfPads()
00370 {
00371
00372 return ListOfPads;
00373 }
00374
00375 void TGo4PreviewPanelStatus::ResetPadOptionsList()
00376 {
00377 PadOptionList->Delete();
00378 listiter->Reset();
00379 ListOfPads->Clear("nodelete");
00380 }
00381
00382 void TGo4PreviewPanelStatus::UpdateSubPads(TPad* pad)
00383 {
00384 if(pad==0) return;
00385 TList* primlist=pad->GetListOfPrimitives();
00386 if(primlist==0) return;
00387
00388 TIterator* liter=primlist->MakeIterator();
00389 TObject* next=0;
00390 while((next=liter->Next())!=0)
00391 {
00392 if(next->InheritsFrom("TPad"))
00393 {
00394 TPad* sub=dynamic_cast<TPad*>(next);
00395 if(!ListOfPads->FindObject(next))
00396 {
00397 SetPadDrawOption(sub,"hist",kFALSE );
00398
00399 }
00400 UpdateSubPads(sub);
00401 }
00402 }
00403 delete liter;
00404 }
00405
00406
00407 void TGo4PreviewPanelStatus::RemoveSubPads(TPad* pad)
00408 {
00409 if(pad==0) return;
00410 TList* primlist=pad->GetListOfPrimitives();
00411 if(primlist==0) return;
00412
00413 TIterator* liter=primlist->MakeIterator();
00414 TObject* next=0;
00415 while((next=liter->Next())!=0)
00416 {
00417 if(next->InheritsFrom("TPad"))
00418 {
00419 TPad* subpad=dynamic_cast<TPad*>(next);
00420 RemovePad(subpad);
00421 }
00422 else{ }
00423 }
00424 delete liter;
00425 }
00426
00427 void TGo4PreviewPanelStatus::RemovePad(TPad* pad)
00428 {
00429 fxSlots->ClearAllLabels(pad);
00430 fxSlots->ClearLegend(pad,true);
00431 ListOfPads->Remove(pad);
00432
00433 listiter->Reset();
00434 TObject* entry=0;
00435 while((entry=listiter->Next()) !=0)
00436 {
00437 if(((TGo4PadOptions *)entry)->fxPad==pad)
00438 {
00439 PadOptionList->Remove(entry);
00440 delete entry;
00441
00442 break;
00443 }
00444 }
00445 RemoveSubPads(pad);
00446 }
00447
00448 Int_t TGo4PreviewPanelStatus::GetNoOfPads()
00449 {
00450
00451 Int_t num=ListOfPads->GetEntries();
00452
00453 return num;
00454 }
00455
00456
00457 void TGo4PreviewPanelStatus::CleanupPadLists(TCanvas* can)
00458 {
00459
00460
00461
00462
00463
00464
00465 return;
00466 if(can==0) return;
00467 cout <<"CleanupPadLists() for canvas "<<can << endl;
00468 TPad* pad=0;
00469 TRefArray* padlistcopy= new TRefArray;
00470 padlistcopy->AddAll(ListOfPads);
00471 TIter piter(padlistcopy);
00472 while((pad=dynamic_cast<TPad*>(piter.Next())) !=0)
00473 {
00474 if(!CheckSubPads(can,pad))
00475 RemovePad(pad);
00476 }
00477 padlistcopy->Clear("nodelete");
00478 delete padlistcopy;
00479 }
00480
00481 Bool_t TGo4PreviewPanelStatus::CheckSubPads(TPad* container, TPad* test)
00482 {
00483 if(container==0 || test==0) return kFALSE;
00484 if(container==test)
00485 {
00486
00487
00488 return kTRUE;
00489 }
00490 TObject* entry=0;
00491 TList* primlist=container->GetListOfPrimitives();
00492 TIter priter(primlist);
00493 while((entry=priter.Next()) !=0)
00494 {
00495
00496 TPad* sub=dynamic_cast<TPad*>(entry);
00497 if(sub==0)
00498 {
00499 continue;
00500 }
00501 else
00502 {
00503 if(CheckSubPads(sub,test))
00504 return kTRUE;
00505 else
00506 continue;
00507 }
00508 }
00509
00510 return kFALSE;
00511 }
00512
00513
00514 void TGo4PreviewPanelStatus::RefreshListOfPads()
00515 {
00517
00518
00519
00520
00521
00522
00523 TList* padlistcopy= new TList;
00524 padlistcopy->SetOwner(kFALSE);
00525 padlistcopy->AddAll(ListOfPads);
00526 ListOfPads->Clear("nodelete");
00527 TObject* ob=0;
00528 TIter paditer(padlistcopy);
00529 while((ob=paditer.Next())!=0)
00530 {
00531 AssignUID(ob);
00532 ListOfPads->AddLast(ob);
00533
00534 }
00535 padlistcopy->Clear("nodelete");
00536 delete padlistcopy;
00537
00538 }
00539
00540 void TGo4PreviewPanelStatus::AssignUID(TObject* obj)
00541 {
00542
00543 if(obj==0) return;
00544 if(ListOfPads->FindObject(obj))
00545 {
00546
00547 return;
00548 }
00549
00550
00551 TProcessID* spi=TProcessID::GetSessionProcessID();
00552 UInt_t objcount=spi->GetObjectCount();
00553 while(spi->GetObjectWithID(objcount))
00554 {
00555
00556
00557 objcount++;
00558 }
00559 obj->SetUniqueID(objcount);
00560 obj->SetBit(kIsReferenced);
00561
00562 TProcessID::SetObjectCount(objcount);
00563
00564 TProcessID::AssignID(obj);
00565
00566
00567
00568 }
00569
00570
00571
00572