Changeset 2412 for trunk/MagicSoft/Mars/mhist
- Timestamp:
- 10/20/03 17:59:15 (21 years ago)
- Location:
- trunk/MagicSoft/Mars/mhist
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mhist/MH.cc
r2296 r2412 700 700 // Also layout the two statistic boxes and a legend. 701 701 // 702 void MH::Draw(TH1 &hist1, TH1 &hist2, const TString title )702 void MH::Draw(TH1 &hist1, TH1 &hist2, const TString title, TVirtualPad *pad) 703 703 { 704 704 // 705 705 // Draw first histogram 706 706 // 707 hist1.Draw(); 708 gPad->SetBorderMode(0); 709 gPad->Update(); 707 if (!pad) 708 pad = gPad; 709 710 MParContainer::DrawTS(&hist1, pad); 711 pad->SetBorderMode(0); 712 pad->Update(); 710 713 711 714 if (hist1.GetEntries()>0 && hist2.GetEntries()>0) … … 726 729 } 727 730 728 TPaveText *t = (TPaveText*) gPad->FindObject("title");731 TPaveText *t = (TPaveText*)pad->FindObject("title"); 729 732 if (t) 730 733 { … … 738 741 // (see THistPainter::PaintTitle) title 739 742 // 740 gPad->Modified(); // indicates a change741 gPad->Update(); // recreates the original title743 pad->Modified(); // indicates a change 744 pad->Update(); // recreates the original title 742 745 t->Pop(); // bring our title on top 743 746 } … … 747 750 // 748 751 // Where to get the TPaveStats depends on the root version 749 TPaveStats *s1 = (TPaveStats*) gPad->FindObject("stats");752 TPaveStats *s1 = (TPaveStats*)pad->FindObject("stats"); 750 753 if (!s1) 751 754 s1 = (TPaveStats*)hist1.GetListOfFunctions()->FindObject("stats"); … … 763 766 // Draw second histogram 764 767 // 765 hist2.Draw("sames");766 gPad->Update();768 MParContainer::DrawTS(&hist2, pad, "sames"); 769 pad->Update(); 767 770 768 771 // … … 770 773 // 771 774 // Where to get the TPaveStats depends on the root version 772 TPaveStats *s2 = (TPaveStats*) gPad->FindObject("stats");775 TPaveStats *s2 = (TPaveStats*)pad->FindObject("stats"); 773 776 if (!s2) 774 777 s2 = (TPaveStats*)hist2.GetListOfFunctions()->FindObject("stats"); … … 787 790 l.SetBorderSize(s2->GetBorderSize()); 788 791 l.SetBit(kCanDelete); 789 l.Draw();792 MParContainer::DrawTS(&l, pad); 790 793 } 791 794 } … … 830 833 // to the present pad. The kCanDelete bit is set for the clone. 831 834 // 835 TObject *MH::DrawCloneTS(TVirtualPad *pad, Option_t *opt, Int_t w, Int_t h) const 836 { 837 TString option(opt); 838 839 //gLog << dbg << "DrawCloneTS: Arg=" << pad << " " << gPad << endl; 840 841 TVirtualPad *p = GetNewPad(option) || pad ? pad : NULL; 842 //gLog << dbg << "DrawCloneTS: nonew&&gpad=" << p << " " << opt << endl; 843 if (!p) 844 p = MakeDefCanvas(this, w, h); 845 else 846 /*{ 847 gLog << dbg << "--> Clear" << endl;*/ 848 p->Clear(); 849 //} 850 //gLog << dbg << "DrawCloneTS: " << p << endl; 851 852 TObject *o = MParContainer::DrawCloneTS(pad, option); 853 o->SetBit(kCanDelete); 854 return o; 855 } 856 /* 857 // -------------------------------------------------------------------------- 858 // 859 // If the opt string contains 'nonew' or gPad is not given a new canvas 860 // with size w/h is created. Otherwise the object is cloned and drawn 861 // to the present pad. The kCanDelete bit is set for the clone. 862 // 832 863 TObject *MH::DrawClone(Option_t *opt, Int_t w, Int_t h) const 833 864 { 834 865 TString option(opt); 835 866 836 TVirtualPad *p = GetNewPad(option); 867 gLog << dbg << "DrawCloneTS: Arg=" << gPad << endl; 868 869 TVirtualPad *p = GetNewPad(option) ? gPad : NULL; 870 gLog << dbg << "DrawCloneTS: nonew&&gpad=" << p << " " << opt << endl; 837 871 if (!p) 838 872 p = MakeDefCanvas(this, w, h); 839 873 else 840 874 p->Clear(); 841 842 gROOT->SetSelectedPad(NULL); 843 844 TObject *o = MParContainer::DrawClone(option); 875 gLog << dbg << "DrawCloneTS: " << p << endl; 876 877 TObject *o = Clone(option); 845 878 o->SetBit(kCanDelete); 846 879 return o; 847 880 } 848 881 */ 849 882 // -------------------------------------------------------------------------- 850 883 // 851 884 // Check whether a class inheriting from MH overwrites the Draw function 852 885 // 853 Bool_t MH::OverwritesDraw(TClass *cls ) const886 Bool_t MH::OverwritesDraw(TClass *cls, const char *ext) const 854 887 { 855 888 if (!cls) … … 865 898 // Check whether the class cls overwrites Draw 866 899 // 867 if (cls->GetMethodAny("Draw")) 900 TString name("Draw"); 901 name += ext; 902 if (cls->GetMethodAny(name)) 868 903 return kTRUE; 869 904 … … 875 910 while ((base=(TBaseClass*)NextBase())) 876 911 { 877 if (OverwritesDraw(base->GetClassPointer() ))912 if (OverwritesDraw(base->GetClassPointer(), ext)) 878 913 return kTRUE; 879 914 } -
trunk/MagicSoft/Mars/mhist/MH.h
r2296 r2412 22 22 MH(const char *name=NULL, const char *title=NULL); 23 23 24 Bool_t OverwritesDraw(TClass *cls=NULL ) const;24 Bool_t OverwritesDraw(TClass *cls=NULL, const char *ext="") const; 25 25 26 26 virtual Bool_t SetupFill(const MParList *pList) { return kTRUE; } … … 64 64 65 65 static void DrawCopy(const TH1 &hist1, const TH1 &hist2, const TString title); 66 static void Draw(TH1 &hist1, TH1 &hist2, const TString title );66 static void Draw(TH1 &hist1, TH1 &hist2, const TString title, TVirtualPad *pad=NULL); 67 67 68 68 TObject *Clone(const char *name="") const; 69 69 70 // FIXME: Rename Draw-->Draw2 and remove this workaround... 70 71 void Draw(Option_t *o="") { MParContainer::Draw(o); } 71 TObject *DrawClone(Option_t *opt, Int_t w, Int_t h) const; 72 73 TObject *DrawClone(Option_t *opt, Int_t w, Int_t h) const 74 { 75 return MH::DrawCloneTS(NULL, opt, 625, 440); 76 } 72 77 TObject *DrawClone(Option_t *opt="") const 73 78 { 74 return MH::DrawClone(opt, 625, 440); 79 return MH::DrawCloneTS(NULL, opt, 625, 440); 80 } 81 TObject *DrawCloneTS(TVirtualPad *pad, Option_t *opt, Int_t w, Int_t h) const; 82 TObject *DrawCloneTS(TVirtualPad *pad=NULL, Option_t *opt="") const 83 { 84 return MH::DrawCloneTS(pad, opt, 625, 440); 75 85 } 76 86
Note:
See TracChangeset
for help on using the changeset viewer.