Re: TPave Text (fwd)

From: Rene Brun (Rene.Brun@cern.ch)
Date: Mon Dec 13 1999 - 18:07:46 MET


Hi marek,
I am not sure to pick correctly your problem.
TPaveText expects coordinates in the current pad coordinates system by
default.
You can also give give coordinates in the Normalized Device Coordinate
(NDC)
in the range [0,1] via options such as "brNDC"
The example below creates a pad with the default range [0,1], with a
TPaveText.

Rene Brun

{
 TCanvas *c1 = new TCanvas("c1");
 TPaveText *opis;
 TText *t1;
 opis = new TPaveText(.2,.3,.6,.8);
 opis->SetFillColor(42);
 char tmp[50];
 sprintf(tmp,"Peak energy %5.2f",67.89);
 t1 = opis->AddText(tmp);
 t1->SetTextSize(0.05);
 sprintf(tmp,"Gain %5.2f",56.2);
 opis->AddText(tmp);
 opis->Draw();   
}
Marek Idzik wrote:
> 
> Hi
> 
> I have simple problem ie to put a TPaveText with few lines of info
> into my TCanvas, summarizing the plot created with TGraph.
> I looked in the tutorials to get an example and then
> I included into my program a number of lines, the relevant ones are
> below:
> 
>  TPaveText *opis;
>  TText *t1;
>  opis = new TPaveText(x1,y1,x2,y2);
>  opis->SetFillColor(42);
>  sprintf(tmp,"Peak energy %f",plot0[i].e_peak);
>  t1 = opis->AddText(tmp);
>  t1->SetTextSize(0.05);
>  sprintf(tmp,"Gain %f",gain);
>  opis->AddText(tmp);
>  opis->Draw();
> 
> Depending what I set as x1,x2,y1,y2 the program does things which
> have nothing to do with my will(+segmentation fault and showing sometimes
> partially the info I wanted)
> Probably I set them in the wrong way but in the TPaveText class
> description there is nothing said about and so I'm a bit confused.
> Could sombody tell me how should I use TPaveText in order to get
> a box with few lines in my TCanvas in a predictible way ?
> 
> marek



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:43:44 MET