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