Hi Leon, Thanks for sending your example. The current logic in TPostScript does not allow printing in the same file canvases with different sizes. However, there is a very simple solution to this problem that also simplifies a fit the script. See your modified script below. Rene Brun { gROOT->SetStyle("Plain"); TCanvas *c1 = new TCanvas("c1","c1",500,500); TPostScript psout("outfile.ps",112); psout->NewPage(); Float_t x[5],y[5]; for (Int_t iter=1;iter<=5;iter++) { x[iter-1]=iter; y[iter-1]=sqrt(iter); } TGraph square(5,x,y); square->Draw("A*"); c1->SetCanvasSize(500,250); psout->NewPage(); square->Draw("A*"); psout->Close(); delete c1; // portrait TCanvas *c3 = new TCanvas("c3","c3",500,500); TPostScript psoutP("outfileP.ps",111); psoutP->NewPage(); square->Draw("A*"); c3->SetCanvasSize(500,250); psoutP->NewPage(); square->Draw("A*"); psoutP->Close(); delete c3; // What about US paper? gStyle->SetPaperSize(TStyle::kUSLetter); TCanvas *c5 = new TCanvas("c5","c5",500,500); TPostScript *psoutUS = new TPostScript("outfilePus.ps",111); psoutUS->NewPage(); square->Draw("A*"); c5->SetCanvasSize(500,250); psoutUS->NewPage(); square->Draw("A*"); psoutUS->Close(); } On Fri, 22 Feb 2002, Leon Mualem wrote: > Hi, > Here is a short script that shows the main difficulties I see. The > first, is the inability to open a TPostScript object without a gPad, and > the second is the dependence of the output on the initial gPad > dimensions. These are of course related. It just seems that it would > be better to initialize with the PaperSize currently defined, and to > allow the output to take the aspect ratio of the current canvas. This > second part is probably much more complicated. > > Leon > > Rene Brun wrote: > > > Hi Leon, > > > > Could you send me a short script illustrating the case that does not work? > > Do not try to use the formats >1000, like 100111,etc. > > > > Rene Brun > > > > On Wed, 20 Feb 2002, Leon Mualem wrote: > > > > > >>Hi, > >>I seem to be able to get this error in a CVS version dated 2002/02/14. > >>I discovered this while investigating a different problem, which I will > >>describe here. > >> > >>I have two very similar versions of a macro, and one make reasonable > >>landscape US letter output, while the other doesn't. The problem would > >>manifest itself by the picture being sized too large in the x direction, > >>or the short side of a landscape page. While investigating why, I > >>discovered that the TPostScript constructor has a couple of features > >>which may be inconvenient, and I think easily corrected. > >> > >>The first problem is that there are tests on the variable "fType", for > >>selecting landscape, portrait, or eps. The problem is that the actual > >>selection of these types are only in the first digit, which is > >>calculated as fMode, but then not used in the tests. This make a > >>problem if you want to select a paper type of US letter, by changing > >>your fType from the stated types of 111,112,or 113, to 100111,100112, > >>and 100113. The tests for fType will fail, as they are like fType==112, > >>while a test like fMode==2 is what is required. > >> > >>The second, and probably more complicated issue is the coupling to gPad. > >> This is the root of the problem I had. There may be issues that I > >>don't know about not being a postscript expert, or even novice, but I > >>did take some time to try to understand what was going on. If you do > >>not have a current gPad, you effectively choose a layout defined by > >>gStyle->GetPaperSize(fXsize,fYsize), but apparently get the segfault > >>described below, for reasons that are not obvious to me. It seems the > >>only reason for requiring this gPad test is so that you can get the > >>scale of the drawing you have done, or are going to do in this gPad > >>correct. However, I don't think this quite works as intended, since it > >>only gets the scaling correct for the current Canvas, if you open > >>another, it will rescale the drawings to the dimensions of the pad you > >>have open at the time. (if I understand correctly.) > >> > >>It seems like a sensible thing to do, is to have it first grab the > >>dimensions of the current paper size, and then, if there is a gPad, > >>reset to the size of the current gPad. Something along the lines of: > >> > >>gStyle->GetPaperSize(fXsize,fYsize); > >>Float_t ww=fXsize; > >>Float_t wh=fYsize; > >>if(gPad) { > >> ww = gPad->GetWw(); > >> wh = gPad->GetWh(); > >>} > >> > >>This would then scale a drawing to the page, if there was no gPad > >>defined, and if one was defined, it would keep the aspect ratio of the > >>current pad. It probably doesn't handle the .eps case well, but I > >>haven't been bitten by this yet, so there may be an elegant solution to > >>that, or a better solution than I proposed here. The experts are free > >>to do as they wish, of course. > >> > >>Leon > >> > >> > >>>Hi Thomas, > >>> > >>>This happens when you create a TPostScript object before creating a TCanvas. > >>>Simply create a Tcanvas before this statement. > >>>The fix is already in the CVS source. > >>> > >>>Rene Brun > >>> > >>>Thomas Kluge wrote: > >>> > >>>>>Hi, > >>>>>since ROOT 3.02/06 I suffer from this: > >>>>>--------------------- > >>>>> > >>>>[h1aac02] ~ $ root > >>>>******************************************* > >>>>* * > >>>>* W E L C O M E to R O O T * > >>>>* * > >>>>* Version 3.02/06 14 December 2001 * > >>>>* * > >>>>* You are welcome to visit our Web site * > >>>>* http://root.cern.ch * > >>>>* * > >>>>******************************************* > >>>> > >>>>>FreeType Engine v1.x used to render TrueType fonts. > >>>>> > >>>>Compiled for linuxsuse6. > >>>> > >>>>>CINT/ROOT C/C++ Interpreter version 5.15.21, Dec 8 2001 > >>>>> > >>>>Type ? for help. Commands must be C++ statements. > >>>>Enclose multiple statements between { }. > >>>>root [0] TPostScript *ps = new TPostScript("test.ps"); > >>>> > >>>>>*** Break *** segmentation violation > >>>>> > >>>>Root > > >>>>--------------------- > >>>> > >>>>>What's wrong? > >>>>>Best regards, > >>>>>Thomas > >>>>> > >
This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:42 MET