RE: Changing canvas size

From: Olivier Couet <Olivier.Couet_at_cern.ch>
Date: Thu, 2 Apr 2009 10:03:08 +0200


Hi Akira,

SetWindowSize changes the window size but the action is kept in a queue and not performed immediately. To flush the queue it is enough to do gSystem->ProcessEvents(); . That's what SaveAs is doing and that's why your 2nd png file has the correct size. So to make your macro working it is enough to modify it as shown in the following example. On my side I will add a gSystem->ProcessEvents(); in SetWindowSize (like in SaveAs), so it will not be necessary to add it in users' macros, and the example given in the help of TPad will be correct.

{

   Double_t w = 600;
   Double_t h = 600;
   TCanvas * c1 = new TCanvas("c", "c", w, h);    c->SetWindowSize(w + (w - c->GetWw()), h + (h - c->GetWh()));    gSystem->ProcessEvents();
   c->SaveAs("c1.png");
   c->SaveAs("c2.png");
}

Cheers, Olivier

--
Org:    CERN - European Laboratory for Particle Physics.
Mail:   1211 Geneve 23 - Switzerland                     Mailbox: J25910
E-Mail: Olivier.Couet_at_cern.ch                            Phone:   +41 22 7676522
WWW:    http://cern.ch/Olivier.Couet/                    Fax:     +41 22 7670300
Received on Thu Apr 02 2009 - 10:03:17 CEST

This archive was generated by hypermail 2.2.0 : Thu Apr 02 2009 - 17:50:02 CEST