Changeset 6869 for trunk/MagicSoft/Mars/mhbase
- Timestamp:
- 03/21/05 10:39:58 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mhbase/MH3.cc
r6280 r6869 389 389 if (fHist) 390 390 { 391 if (gPad) 392 { 393 const TString pfx(Form("%sProfX", fHist->GetName())); 394 const TString pfy(Form("%sProfY", fHist->GetName())); 395 396 TProfile *p = 0; 397 if ((p=dynamic_cast<TProfile*>(gPad->FindObject(pfx)))) 398 p->SetName(Form("%sProfX", name)); 399 if ((p=dynamic_cast<TProfile*>(gPad->FindObject(pfy)))) 400 p->SetName(Form("%sProfY", name)); 401 } 402 391 403 fHist->SetName(name); 392 404 fHist->SetDirectory(0); 405 393 406 } 394 407 MParContainer::SetName(name); … … 505 518 void MH3::Paint(Option_t *o) 506 519 { 507 fHist->SetFillStyle(4000); 508 509 TString str(o); 510 str.ToLower(); 511 512 const Bool_t only = str.Contains("only") && fDimension==2; 513 const Bool_t same = str.Contains("same") && fDimension==2; 514 const Bool_t blue = str.Contains("blue") && fDimension==2; 515 const Bool_t profx = str.Contains("profx") && fDimension==2; 516 const Bool_t profy = str.Contains("profy") && fDimension==2; 517 // Do NOT replace 'same'-option 518 str.ReplaceAll("only", ""); 519 str.ReplaceAll("blue", ""); 520 str.ReplaceAll("profx", ""); 521 str.ReplaceAll("profy", ""); 522 523 // WARNING: Don't use FindObject directly always use GetListOfPrimitives!! 524 525 // FIXME: We may have to remove all our own options from str! 526 if (!only && !gPad->GetListOfPrimitives()->FindObject(fHist)) 527 fHist->Draw(str); 528 529 if (profx) 530 { 531 TProfile *p = ((TH2*)fHist)->ProfileX("ProfX", -1, 9999, "s"); 532 if (!gPad->GetListOfPrimitives()->FindObject(p)) 533 { 534 p->UseCurrentStyle(); 535 p->SetLineColor(blue ? kBlue : fHist->GetLineColor()); 536 p->SetBit(kCanDelete); 537 p->SetDirectory(NULL); 538 p->SetXTitle(fHist->GetXaxis()->GetTitle()); 539 p->SetYTitle(fHist->GetYaxis()->GetTitle()); 540 p->Draw(only&&!same?"":"same"); 541 } 542 } 543 if (profy) 544 { 545 TProfile *p = ((TH2*)fHist)->ProfileY("ProfY", -1, 9999, "s"); 546 if (!gPad->GetListOfPrimitives()->FindObject(p)) 547 { 548 p->UseCurrentStyle(); 549 p->SetLineColor(blue ? kBlue : fHist->GetLineColor()); 550 p->SetBit(kCanDelete); 551 p->SetDirectory(NULL); 552 p->SetYTitle(fHist->GetXaxis()->GetTitle()); 553 p->SetXTitle(fHist->GetYaxis()->GetTitle()); 554 p->Draw(only&&!same?"":"same"); 555 } 520 TProfile *p=0; 521 522 const TString pfx(Form("%sProfX", fHist->GetName())); 523 if ((p=dynamic_cast<TProfile*>(gPad->FindObject(pfx)))) 524 { 525 Int_t col = p->GetLineColor(); 526 p = ((TH2*)fHist)->ProfileX(pfx, -1, 9999, "s"); 527 p->SetLineColor(col); 528 } 529 530 const TString pfy(Form("%sProfY", fHist->GetName())); 531 if ((p=dynamic_cast<TProfile*>(gPad->FindObject(pfy)))) 532 { 533 Int_t col = p->GetLineColor(); 534 p = ((TH2*)fHist)->ProfileY(pfy, -1, 9999, "s"); 535 p->SetLineColor(col); 556 536 } 557 537 … … 581 561 TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(fHist); 582 562 pad->SetBorderMode(0); 583 AppendPad(opt); 584 585 return; 586 /* 563 587 564 fHist->SetFillStyle(4000); 588 565 … … 590 567 str = str.Strip(TString::kBoth); 591 568 592 Bool_t only = str.Contains("ONLY", TString::kIgnoreCase) && fDimension==2; 593 Bool_t same = str.Contains("SAME", TString::kIgnoreCase) && fDimension==2; 594 Bool_t blue = str.Contains("BLUE", TString::kIgnoreCase) && fDimension==2; 569 const Bool_t only = str.Contains("ONLY", TString::kIgnoreCase) && fDimension==2; 570 const Bool_t same = str.Contains("SAME", TString::kIgnoreCase) && fDimension==2; 571 const Bool_t blue = str.Contains("BLUE", TString::kIgnoreCase) && fDimension==2; 572 const Bool_t profx = str.Contains("PROFX", TString::kIgnoreCase) && fDimension==2; 573 const Bool_t profy = str.Contains("PROFY", TString::kIgnoreCase) && fDimension==2; 574 575 str.ReplaceAll("only", ""); 576 str.ReplaceAll("blue", ""); 577 str.ReplaceAll("profx", ""); 578 str.ReplaceAll("profy", ""); 579 595 580 // FIXME: We may have to remove all our own options from str! 596 581 if (!only) 597 582 fHist->Draw(str); 598 583 599 AppendPad("upd"); 600 601 if (str.Contains("PROFX", TString::kIgnoreCase) && fDimension==2) 602 { 603 TProfile *p = ((TH2*)fHist)->ProfileX(fNameProfX, -1, 9999, "s"); 584 AppendPad(); 585 586 TProfile *p=0; 587 if (profx) 588 { 589 const TString pfx(Form("%sProfX", fHist->GetName())); 590 591 if (same && (p=dynamic_cast<TProfile*>(gPad->FindObject(pfx)))) 592 *fLog << warn << "TProfile " << pfx << " already in pad." << endl; 593 594 p = ((TH2*)fHist)->ProfileX(pfx, -1, 9999, "s"); 604 595 p->UseCurrentStyle(); 605 596 p->SetLineColor(blue ? kBlue : fHist->GetLineColor()); 606 p->Draw(only&&!same?"":"same");607 597 p->SetBit(kCanDelete); 608 598 p->SetDirectory(NULL); 609 599 p->SetXTitle(fHist->GetXaxis()->GetTitle()); 610 600 p->SetYTitle(fHist->GetYaxis()->GetTitle()); 611 } 612 if (str.Contains("PROFY", TString::kIgnoreCase) && fDimension==2) 613 { 614 TProfile *p = ((TH2*)fHist)->ProfileY(fNameProfY, -1, 9999, "s"); 601 p->Draw(only&&!same?"":"same"); 602 } 603 if (profy) 604 { 605 const TString pfy(Form("%sProfY", fHist->GetName())); 606 607 if (same && (p=dynamic_cast<TProfile*>(gPad->FindObject(pfy)))) 608 *fLog << warn << "TProfile " << pfy << " already in pad." << endl; 609 610 p = ((TH2*)fHist)->ProfileY(pfy, -1, 9999, "s"); 615 611 p->UseCurrentStyle(); 616 612 p->SetLineColor(blue ? kBlue : fHist->GetLineColor()); 617 p->Draw(only&&!same?"":"same");618 613 p->SetBit(kCanDelete); 619 614 p->SetDirectory(NULL); 620 615 p->SetYTitle(fHist->GetXaxis()->GetTitle()); 621 616 p->SetXTitle(fHist->GetYaxis()->GetTitle()); 622 } 623 624 AppendPad("log");*/ 617 p->Draw(only&&!same?"":"same"); 618 } 619 620 //AppendPad("log"); 625 621 } 626 622
Note:
See TracChangeset
for help on using the changeset viewer.