Re: [ROOT] Redrawing a closed canvas

From: Fons Rademakers (Fons.Rademakers@cern.ch)
Date: Mon Aug 13 2001 - 15:00:05 MEST


Hi Chris,

  what kind of button TButton or TGButton? Please, try to provide runable
axample.

Cheers, Fons.




Chris Milne wrote:
> 
> Hi there,
> 
> I have a button on screen which, when clicked, displays a canvas with four
> graphs. However, if I close the canvas and click the button again I get:
> 
>  *** Break *** bus error
> Root > Function display_blue_blea() busy flag cleared
> 
> The function called by the button is below:
> 
> void display_blue_blea() {
>    TCanvas *blue_blea;
>    if(blue_blea) delete blue_blea;
>    blue_blea = new TCanvas ("blue_blea", "Blueshift and
> Bleaching",20,20,710,710);
>    blue_blea->Divide(2,2);
>    blue_blea->cd(1);
>    pad2->Draw();
>    blue_blea->cd(2);
>    pad3->Draw();
>    blue_blea->cd(3);
>    pad4->Draw();
>    blue_blea->cd(4);
>    pad5->Draw();
>    blue_blea->cd(1);
>    TSlider *xslider = new TSlider("xslider","x",0.1,0.02,0.9,0.1);
>    xslider->AddExec("fit",".x fit.C");                          //run on mouse
> over pad
>    blue_blea->cd(2);
>    TSlider *xslider2 = new TSlider("xslider2","x",0.1,0.02,0.9,0.1);
>    xslider2->AddExec("fit",".x fit.C");                 //run on mouse over pad
>    blue_blea->cd(3);
>    TSlider *xslider3 = new TSlider("xslider3","x",0.1,0.02,0.9,0.1);
>    xslider3->AddExec("fit",".x fit.C");
>    blue_blea->cd(4);
>    TSlider *xslider4 = new TSlider("xslider4","x",0.1,0.02,0.9,0.1);
>    xslider4->AddExec("fit",".x fit.C");
>      pad2->cd();
>   TH2F * bleaaxisHH= new TH2F("bleaaxisHH","Bleaching Heavy
> Hole",y,time[0],time[y-1],x,HH_bleach_min,HH_bleach_max);
>   bleaaxisHH->SetStats(kFALSE);
>   bleaaxisHH->GetYaxis()->SetLimits(0,HH_bleach_max);
>   bleaaxisHH->Draw("A");
>   bleaaxisHH->GetYaxis()->SetTitleOffset(1.2);
>   Bleach_HH_SCP->Draw("P");
>   Bleach_HH_SCP->SetMarkerColor(kBlue);
>   Bleach_HH_SCP->SetMarkerStyle(8);
>   Bleach_HH_SCP->SetMarkerSize(0.5);
>   Bleach_HH_SCP->SetLineColor(kBlue);
>   Bleach_HH_OCP->Draw("P");
>   Bleach_HH_OCP->SetMarkerColor(kGreen);
>   Bleach_HH_OCP->SetMarkerStyle(8);
>   Bleach_HH_OCP->SetMarkerSize(0.5);
>   Bleach_HH_OCP->SetLineColor(kGreen);
> 
>   pad3->cd();
>   TH2F * bleaaxisLH= new TH2F("bleaaxisLH","Bleaching Light
> Hole",y,time[0],time[y-1],x,LH_bleach_min,LH_bleach_max);
>   bleaaxisLH->SetStats(kFALSE);
>   bleaaxisLH->Draw("A");
>   pad3->Update();
>   bleaaxisLH->GetYaxis()->SetTitleOffset(1.2);
>   Bleach_LH_SCP->Draw("P");
>   Bleach_LH_SCP->SetMarkerColor(kBlue);
>   Bleach_LH_SCP->SetMarkerStyle(8);
>   Bleach_LH_SCP->SetMarkerSize(0.5);
>   Bleach_LH_SCP->SetLineColor(kBlue);
>   Bleach_LH_OCP->Draw("P");
>   Bleach_LH_OCP->SetMarkerColor(kGreen);
>   Bleach_LH_OCP->SetMarkerStyle(8);
>   Bleach_LH_OCP->SetMarkerSize(0.5);
>   Bleach_LH_OCP->SetLineColor(kGreen);
> 
>   pad4->cd();
>   TH2F * blueaxisHH= new TH2F("blueaxisHH","Blueshift Heavy
> Hole",y,time[0],time[y-1],x,HH_blueshift_min,HH_blueshift_max);
>   blueaxisHH->SetStats(kFALSE);
>   blueaxisHH->Draw("A");
>   blueaxisHH->GetYaxis()->SetTitleOffset(1.2);
>   Blueshift_HH_SCP->Draw("P");
>   Blueshift_HH_SCP->SetMarkerColor(kBlue);
>   Blueshift_HH_SCP->SetMarkerStyle(8);
>   Blueshift_HH_SCP->SetMarkerSize(0.5);
>   Blueshift_HH_SCP->SetLineColor(kBlue);
>   Blueshift_HH_OCP->Draw("P");
>   Blueshift_HH_OCP->SetMarkerColor(kGreen);
>   Blueshift_HH_OCP->SetMarkerStyle(8);
>   Blueshift_HH_OCP->SetMarkerSize(0.5);
>   Blueshift_HH_OCP->SetLineColor(kGreen);
> 
>   pad5->cd();
>   TH2F * blueaxisLH= new TH2F("blueaxisLH","Blueshift Light
> Hole",y,time[0],time[y-1],x,LH_blueshift_min,LH_blueshift_max);
>   blueaxisLH->SetStats(kFALSE);
>   blueaxisLH->GetYaxis()->SetLimits(0,LH_blueshift_max);
>   blueaxisLH->Draw("A");
>   blueaxisLH->GetYaxis()->SetTitleOffset(1.2);
>   Blueshift_LH_SCP->Draw("P");
>   Blueshift_LH_SCP->SetMarkerColor(kBlue);
>   Blueshift_LH_SCP->SetMarkerStyle(8);
>   Blueshift_LH_SCP->SetMarkerSize(0.5);
>   Blueshift_LH_SCP->SetLineColor(kBlue);
>   Blueshift_LH_OCP->Draw("P");
>   Blueshift_LH_OCP->SetMarkerColor(kGreen);
>   Blueshift_LH_OCP->SetMarkerStyle(8);
>   Blueshift_LH_OCP->SetMarkerSize(0.5);
>   Blueshift_LH_OCP->SetLineColor(kGreen);
> 
>   bleaaxisLH->GetYaxis()->SetTitle("Bleaching (a.u.)");
>   bleaaxisHH->GetYaxis()->SetTitle("Bleaching (a.u.)");
>   blueaxisLH->GetYaxis()->SetTitle("Blueshift (meV)");
>   blueaxisHH->GetYaxis()->SetTitle("Blueshift (meV)");
>   bleaaxisLH->GetXaxis()->SetTitle("Time (ps)");
>   bleaaxisHH->GetXaxis()->SetTitle("Time (ps)");
>   blueaxisLH->GetXaxis()->SetTitle("Time (ps)");
>   blueaxisHH->GetXaxis()->SetTitle("Time (ps)");
>   pad2->cd();
>   TPaveText *legend = new TPaveText(.82,.82,.97,.97,"NDC");
>   TText *OCP = new TText(0.85,0.85,"OCP");
>   TText *SCP = new TText(0.85,0.9,"SCP");
>   legend->Draw();
>   OCP->SetTextColor(kGreen);
>   SCP->SetTextColor(kBlue);
>   SCP->DrawTextNDC(0.85,0.84,"OCP");
>   OCP->DrawTextNDC(0.85,0.91,"SCP");
>   blue_blea->cd(2);
>   legend->Draw();
>   SCP->DrawTextNDC(0.85,0.84,"OCP");
>   OCP->DrawTextNDC(0.85,0.91,"SCP");
>   blue_blea->cd(3);
>   legend->Draw();
>   SCP->DrawTextNDC(0.85,0.84,"OCP");
>   OCP->DrawTextNDC(0.85,0.91,"SCP");
>   blue_blea->cd(4);
>   legend->Draw();
>   SCP->DrawTextNDC(0.85,0.84,"OCP");
>   OCP->DrawTextNDC(0.85,0.91,"SCP");
> }

-- 
Org:    CERN, European Laboratory for Particle Physics.
Mail:   1211 Geneve 23, Switzerland
E-Mail: Fons.Rademakers@cern.ch              Phone: +41 22 7679248
WWW:    http://root.cern.ch/~rdm/            Fax:   +41 22 7677910



This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:57 MET