Hi Sven,
the following is working for me (3.03/06)
void test1(){
TCanvas c1("c1","test canvas",400,400);
c1->Divide(2,2);
gPad->GetCanvas()->FeedbackMode(kTRUE);
TH1F* histo = new TH1F("histo","histo",1,1,2);
histo->SetBinContent(1,10);
for(Int_t i = 0; i < 4; i++){
c1.cd(i+1);
if(i==1)
gPad->SetLogx();
histo->Draw();
}
}
Regards,
Fabrizio
+=======================================================+
|| Fabrizio Pierella ||
|| E-mail: Fabrizio.Pierella@cern.ch ||
|| pierella@bo.infn.it ||
|| Tel. CERN (Bld.29-R-019) +41 (22) 7677767 ||
|| in Bologna (off.203) +39 051 2091103 ||
+=======================================================+
On Wed, 10 Jul 2002, Sven Schagen wrote:
> Dear Rooters,
>
> I came across a slight problem in accessing the gPad-pointer in one of my
> macros. The script below does not execute properly with my version of ROOT
> (3.01/06 on RedHat Linux 6.?). ROOT is unable to find or access the
> gPad-pointer:
>
> Error: non class,struct,union object $gPad used with . or -> FILE:tc.C
> LINE:15
>
> Any ideas on what is causing this effect ?
>
> Cheers,
> Sven Schagen
>
> // Failing Macro
> void test1(void)
> {
> gROOT->Reset();
> TCanvas c1("c1","test canvas",400,400);
> c1.Divide(2,2);
> TH1F* histo = new TH1F("histo","histo",1,1,2);
> histo->SetBinContent(1,10);
> for(Int_t i = 0; i < 4; i++){
> c1.cd(i+1);
> if(i == 1) // Remove this statement, and the script works
> gPad->SetLogx();
> histo->Draw();
> }
> }
>
> The problem can be solved by doing the following:
>
> // Successfull Macro
> void test2(void)
> {
> gROOT->Reset();
> TCanvas c1("c1","test canvas",400,400);
> c1.Divide(2,2);
> TH1F* histo = new TH1F("histo","histo",1,1,2);
> histo->SetBinContent(1,10);
> for(Int_t i = 0; i < 4; i++){
> c1.cd(i+1);
> TPad* paddy = gPad; // Store the gPad pointer in a temp var.
> if(i==1)
> paddy->SetLogx();
> histo->Draw();
> }
> }
>
>
>
This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:59 MET