ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
pstable.C
Go to the documentation of this file.
1 /// \file
2 /// \ingroup tutorial_graphics
3 /// Display all possible types of ROOT/Postscript characters.
4 ///
5 /// \macro_code
6 ///
7 /// \author Olivier Couet
8 
9 void table(Float_t x1, Float_t x2, Float_t yrange, TText *t, const char **symbol, Bool_t octal);
10 
11 void pstable()
12 {
13  const char *symbol1[] =
14  {"A","B","C","D","E","F","G","H","I","J","K","L","M","N",
15  "O","P","Q","R","S","T","U","V","W","X","Y","Z",
16  "0","1","2","3","4","5","6","7","8","9",
17  ".",",","+","-","*","/","=","(",")","{","}","END"};
18 
19  const char *symbol2[] =
20  {"a","b","c","d","e","f","g","h","i","j","k","l","m","n",
21  "o","p","q","r","s","t","u","v","w","x","y","z",
22  ":",";","@","\\","_","|","%",
23  "@'","<",">","[","]","\42","@\43","@\136",
24  "@\77","@\41","@&","$","@\176"," ","END"};
25 
26  const char *symbol3[] =
27  {"\241","\242","\243","\244","\245","\246","\247","\250",
28  "\251","\252","\253","\254","\255","\256","\257","\260",
29  "\261","\262","\263","\264","\265","\266","\267","\270",
30  "\271","\272","\273","\274","\275","\276","\277","\300",
31  "\301","\302","\303","\304","\305","\306","\307","\310",
32  "\311","\312","\313","\314","\315","\316","\317","END"};
33 
34  const char *symbol4[] =
35  {"\321","\322","\323","\324","\325","\326","\327","\330",
36  "\331","\332","\333","\334","\335","\336","\337","\340",
37  "\341","\342","\343","\344","\345","\346","\347","\340",
38  "\351","\352","\353","\354","\355","\356","\357","\360",
39  "\361","\362","\363","\364","\365","\366","\367","\370",
40  "\371","\372","\373","\374","\375","\376","\377","END"};
41 
42  const char *symbol5[] =
43  {"\177","\200","\201","\202","\203","\204","\205","\206",
44  "\207","\210","\211","\212","\213","\214","\215","\216",
45  "\217","\220","\221","\222","\223","\224","\225","\226",
46  "\227","\230","\231","\232","\233","\234","\235","\236",
47  "\237","\240","END"};
48 
49  Float_t xrange = 18;
50  Float_t yrange = 25;
51  Int_t w = 650;
52  Int_t h = w*yrange/xrange;
53 
54  TCanvas *c1 = new TCanvas("c1","c1",200,10,w,h);
55  c1->Range(0,0,xrange,yrange);
56 
57  TText *t = new TText(0,0,"a");
58  t->SetTextSize(0.02);
59  t->SetTextFont(62);
60  t->SetTextAlign(22);
61 
62  table(0.5,0.5*xrange-0.5,yrange,t,symbol1,0);
63  table(0.5*xrange+0.5,xrange-0.5,yrange,t,symbol2,0);
64  TText *tlabel = new TText(0,0,"a");
65  tlabel->SetTextFont(72);
66  tlabel->SetTextSize(0.018);
67  tlabel->SetTextAlign(22);
68  tlabel->DrawText(0.5*xrange,1.3,
69  "Input characters are standard keyboard characters");
70  c1->Modified();
71  c1->Update();
72  c1->Print("pstable1.ps");
73 
74  TCanvas *c2 = new TCanvas("c2","c2",220,20,w,h);
75  c2->Range(0,0,xrange,yrange);
76 
77  table(0.5,0.5*xrange-0.5,yrange,t,symbol3,1);
78  table(0.5*xrange+0.5,xrange-0.5,yrange,t,symbol4,1);
79  tlabel->DrawText(0.5*xrange,1.3,
80  "Input characters using backslash and octal numbers");
81  c2->Modified();
82  c2->Update();
83  c2->Print("pstable2.ps");
84 
85  TCanvas *c3 = new TCanvas("c3","c3",240,20,w,h);
86  c3->Range(0,0,xrange,yrange);
87 
88  table(0.5,0.5*xrange-0.5,yrange,t,symbol5,1);
89  tlabel->DrawText(0.5*xrange,1.3,
90  "Input characters using backslash and octal numbers");
91  c3->Modified();
92  c3->Update();
93  c3->Print("pstable3.ps");
94 }
95 void table(Float_t x1, Float_t x2, Float_t yrange, TText *t,
96  const char **symbol, Bool_t octal)
97 {
98  Int_t i;
99  Int_t n = 0;
100  for (i=0;i<1000;i++) {
101  if (!strcmp(symbol[i],"END")) break;
102  n++;
103  }
104  Float_t y1 = 2.5;
105  Float_t y2 = yrange - 0.5;
106  Float_t dx = (x2-x1)/5;
107  Float_t dy = (y2 - 1 -y1)/(n+1);
108  Float_t y = y2 - 1 - 0.7*dy;
109  Float_t xc0 = x1 + 0.5*dx;
110  Float_t xc1 = xc0 + dx;
111  Float_t xc2 = xc1 + dx;
112  Float_t xc3 = xc2 + dx;
113  Float_t xc4 = xc3 + dx;
114  TLine *line = new TLine();
115  line->DrawLine(x1,y1,x1,y2);
116  line->DrawLine(x1,y1,x2,y1);
117  line->DrawLine(x1,y2,x2,y2);
118  line->DrawLine(x2,y1,x2,y2);
119  line->DrawLine(x1,y2-1,x2,y2-1);
120  line->DrawLine(x1+ dx,y1,x1+ dx,y2);
121  line->DrawLine(x1+2*dx,y1,x1+2*dx,y2);
122  line->DrawLine(x1+3*dx,y1,x1+3*dx,y2);
123  line->DrawLine(x1+4*dx,y1,x1+4*dx,y2);
124  TText *tit = new TText(0,0,"a");
125  tit->SetTextSize(0.015);
126  tit->SetTextFont(72);
127  tit->SetTextAlign(22);
128  tit->DrawText(xc0,y2-0.6,"Input");
129  tit->DrawText(xc1,y2-0.6,"Roman");
130  tit->DrawText(xc2,y2-0.6,"Greek");
131  tit->DrawText(xc3,y2-0.6,"Special");
132  tit->DrawText(xc4,y2-0.6,"Zapf");
133  char text[12];
134  for (i=0;i<n;i++) {
135  if (octal) {
136  unsigned char value = *symbol[i];
137  sprintf(text,"@\\ %3o",value);
138  } else {
139  strcpy(text,symbol[i]);
140  }
141  t->DrawText(xc0,y,text);
142  sprintf(text,"%s",symbol[i]);
143  t->DrawText(xc1,y,text);
144  sprintf(text,"`%s",symbol[i]);
145  t->DrawText(xc2,y,text);
146  sprintf(text,"'%s",symbol[i]);
147  t->DrawText(xc3,y,text);
148  sprintf(text,"~%s",symbol[i]);
149  t->DrawText(xc4,y,text);
150  y -= dy;
151  }
152 }
float Float_t
Definition: RtypesCore.h:53
virtual TLine * DrawLine(Double_t x1, Double_t y1, Double_t x2, Double_t y2)
Draw this line with new coordinates.
Definition: TLine.cxx:93
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
virtual void Print(const char *filename="") const
Save Pad contents in a file in one of various formats.
Definition: TPad.cxx:4134
virtual void SetTextFont(Font_t tfont=62)
Definition: TAttText.h:59
Base class for several text objects.
Definition: TText.h:42
virtual void SetTextAlign(Short_t align=11)
Definition: TAttText.h:55
virtual void Range(Double_t x1, Double_t y1, Double_t x2, Double_t y2)
Set world coordinate system for the pad.
Definition: TPad.cxx:4623
A simple line.
Definition: TLine.h:41
The Canvas class.
Definition: TCanvas.h:48
static const double x1[5]
virtual TText * DrawText(Double_t x, Double_t y, const char *text)
Draw this text with new coordinates.
Definition: TText.cxx:171
virtual void SetTextSize(Float_t tsize=1)
Definition: TAttText.h:60
virtual void Update()
Update canvas pad buffers.
Definition: TCanvas.cxx:2179
float value
Definition: math.cpp:443
const Int_t n
Definition: legend1.C:16
void Modified(Bool_t flag=1)
Definition: TPad.h:407