Ignore:
Timestamp:
10/20/03 17:59:15 (21 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mhist
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mhist/MH.cc

    r2296 r2412  
    700700// Also layout the two statistic boxes and a legend.
    701701//
    702 void MH::Draw(TH1 &hist1, TH1 &hist2, const TString title)
     702void MH::Draw(TH1 &hist1, TH1 &hist2, const TString title, TVirtualPad *pad)
    703703{
    704704    //
    705705    // Draw first histogram
    706706    //
    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();
    710713
    711714    if (hist1.GetEntries()>0 && hist2.GetEntries()>0)
     
    726729    }
    727730
    728     TPaveText *t = (TPaveText*)gPad->FindObject("title");
     731    TPaveText *t = (TPaveText*)pad->FindObject("title");
    729732    if (t)
    730733    {
     
    738741        // (see THistPainter::PaintTitle) title
    739742        //
    740         gPad->Modified();  // indicates a change
    741         gPad->Update();    // recreates the original title
     743        pad->Modified();  // indicates a change
     744        pad->Update();    // recreates the original title
    742745        t->Pop();          // bring our title on top
    743746    }
     
    747750    //
    748751    // Where to get the TPaveStats depends on the root version
    749     TPaveStats *s1 = (TPaveStats*)gPad->FindObject("stats");
     752    TPaveStats *s1 = (TPaveStats*)pad->FindObject("stats");
    750753    if (!s1)
    751754        s1 = (TPaveStats*)hist1.GetListOfFunctions()->FindObject("stats");
     
    763766    // Draw second histogram
    764767    //
    765     hist2.Draw("sames");
    766     gPad->Update();
     768    MParContainer::DrawTS(&hist2, pad, "sames");
     769    pad->Update();
    767770
    768771    //
     
    770773    //
    771774    // Where to get the TPaveStats depends on the root version
    772     TPaveStats *s2 = (TPaveStats*)gPad->FindObject("stats");
     775    TPaveStats *s2 = (TPaveStats*)pad->FindObject("stats");
    773776    if (!s2)
    774777        s2 = (TPaveStats*)hist2.GetListOfFunctions()->FindObject("stats");
     
    787790        l.SetBorderSize(s2->GetBorderSize());
    788791        l.SetBit(kCanDelete);
    789         l.Draw();
     792        MParContainer::DrawTS(&l, pad);
    790793    }
    791794}
     
    830833// to the present pad. The kCanDelete bit is set for the clone.
    831834//
     835TObject *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//
    832863TObject *MH::DrawClone(Option_t *opt, Int_t w, Int_t h) const
    833864{
    834865    TString option(opt);
    835866
    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;
    837871    if (!p)
    838872        p = MakeDefCanvas(this, w, h);
    839873    else
    840874        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);
    845878    o->SetBit(kCanDelete);
    846879    return o;
    847880}
    848 
     881*/
    849882// --------------------------------------------------------------------------
    850883//
    851884// Check whether a class inheriting from MH overwrites the Draw function
    852885//
    853 Bool_t MH::OverwritesDraw(TClass *cls) const
     886Bool_t MH::OverwritesDraw(TClass *cls, const char *ext) const
    854887{
    855888    if (!cls)
     
    865898    // Check whether the class cls overwrites Draw
    866899    //
    867     if (cls->GetMethodAny("Draw"))
     900    TString name("Draw");
     901    name += ext;
     902    if (cls->GetMethodAny(name))
    868903        return kTRUE;
    869904
     
    875910    while ((base=(TBaseClass*)NextBase()))
    876911    {
    877         if (OverwritesDraw(base->GetClassPointer()))
     912        if (OverwritesDraw(base->GetClassPointer(), ext))
    878913            return kTRUE;
    879914    }
  • trunk/MagicSoft/Mars/mhist/MH.h

    r2296 r2412  
    2222    MH(const char *name=NULL, const char *title=NULL);
    2323
    24     Bool_t OverwritesDraw(TClass *cls=NULL) const;
     24    Bool_t OverwritesDraw(TClass *cls=NULL, const char *ext="") const;
    2525
    2626    virtual Bool_t SetupFill(const MParList *pList) { return kTRUE; }
     
    6464
    6565    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);
    6767
    6868    TObject *Clone(const char *name="") const;
    6969
     70    // FIXME: Rename Draw-->Draw2 and remove this workaround...
    7071    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    }
    7277    TObject *DrawClone(Option_t *opt="") const
    7378    {
    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);
    7585    }
    7686
Note: See TracChangeset for help on using the changeset viewer.