Hello Olivier,
I think the nested event loop invocation is a good temporary solution. However, such nested "event loop" makes the application a pseudo-multi-threaded with the danger of the various "side effect".
I think what one really needs is the TCanvas-less TPad object to allow user
{
Double_t w = 600;
Double_t h = 600;
TPad* pad = new TPad("pad", "pad", w, h);
pad->SaveAs("pad.png");
// with the option: // pad->SaveAs("pad.png",UInt h=0,Uint w=0); // where the default h=0; w=0 means to preserve // the original object size
Such solution has several advantages:
TPad *TCanvas::TakePad(TPad *pad);
// TakePad removes the "pad" from the TCanvas list of the primitives making "pad" TCanvas-less.
Such TCanvas-less TPad class is a part of QtRoot framework.
http://root.bnl.gov/QtRoot/htmldoc/TEmbeddedPad.html
However, it has no Qt -dependency. It is "pure" TPad subclass and can be
moved from QtRoot to root/gpad.
On the other hand, I do not think there is any strong reason to add this
class to ROOT mainstream "as is".
It would be sufficient to add and extra option to the existing TPad ctor
instead.
Just my 2 cents.
Best Regards
Valeri Fine
> -----Original Message-----
> From: Olivier Couet [mailto:Olivier.Couet_at_cern.ch] > Sent: Thursday, April 02, 2009 4:49 AM > To: OKUMURA, Akira > Cc: Rene Brun; Fine, Valeri > Subject: RE: [ROOT] Changing canvas size > > Yes, the code in TASImage (which worked for you) is in fact: > > gSystem->ProcessEvents(); > gSystem->Sleep(10); > gSystem->ProcessEvents(); > > I am planning to use the same. >
> From: OKUMURA, Akira [mailto:oxon_at_ceres.phys.s.u-tokyo.ac.jp] > Sent: Thursday, April 02, 2009 10:45 AM > To: Olivier Couet > Cc: Rene Brun; Valeri Fayn > Subject: Re: [ROOT] Changing canvas size > > Hello Olivier, > > > As I said in my previous email I will not modify the TCanvas. I'll > > rather fix SetWindowSize. > > Sorry, I didn't read it carefully. > > FYI. I had to add three lines in my environment; > c->Modified(); > c->Update(); > gSystem->Sleep(50); > in addition to > gSystem->ProcessEvents(); > > Final macro (at least for my Mac) is as below. > > { > Double_t w = 600; > Double_t h = 600; > TCanvas* c = new TCanvas("c", "c", w, h); > c->Modified(); > c->Update(); > c->SetWindowSize(w + (w - c->GetWw()), h + (h - c->GetWh())); > gSystem->Sleep(50); > gSystem->ProcessEvents(); > > c->SaveAs("c1.png"); > c->SaveAs("c2.png"); > gSystem->Exec("file c1.png c2.png"); > } > > > Regards, > > OKUMURA, Akira oxon_at_ceres.phys.s.u-tokyo.ac.jp > Department of Physics, The University of Tokyo > 7-3-1 Hongo, Bunkyo-ku, Tokyo 113-0033 > TEL/FAX +81 3-5841-4173/4059 > Skype : okumura.akira > > On 2009/04/02, at 17:17, Olivier Couet wrote: > > > Hi Akira, > > > > As I said in my previous email I will not modify the TCanvas. I'll > > rather fix SetWindowSize. > > > > Regards. > > > > -----Original Message----- > > From: OKUMURA, Akira [mailto:oxon_at_ceres.phys.s.u-tokyo.ac.jp] > > Sent: Thursday, April 02, 2009 10:16 AM > > To: Olivier Couet > > Cc: Rene Brun; Valeri Fayn > > Subject: Re: [ROOT] Changing canvas size > > > > Hello all, > > > > Thank you so much. It's working now! > > > > It is good idea to add the line > > gSystem->ProcessEvents(); > > in the HTML document. > > http://root.cern.ch/root/html/TCanvas.html > > > > Regards, > > > > OKUMURA, Akira oxon_at_ceres.phys.s.u-tokyo.ac.jp > > Department of Physics, The University of Tokyo > > 7-3-1 Hongo, Bunkyo-ku, Tokyo 113-0033 > > TEL/FAX +81 3-5841-4173/4059 > > Skype : okumura.akira > > > > On 2009/04/02, at 17:03, Olivier Couet wrote: > > > >> 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 todo
> >> 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 - 17:21:27 CEST
This archive was generated by hypermail 2.2.0 : Fri Apr 03 2009 - 17:50:02 CEST