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