StRoot  1
basic3dPrimitives.C
1 //*CMZ : 10/06/99 16.26.07 by Valery Fine(fine@bnl.gov)
2 //*-- Author : Valery Fine 10/06/99
3 // Copyright (C) Valery Fine, Brookhaven National Laboratory, 1999. All right reserved
4 // \$Id: basic3dPrimitives.C,v 1.1 1999/06/10 19:02:53 fine Exp \$
5 // \$Log: basic3dPrimitives.C,v \$
6 // Revision 1.1 1999/06/10 19:02:53 fine
7 // New macro to show the basic fearture of new 3D classes
8 //
9 {
10
11 //
12 // To see the output of this macro, click begin_html <a href="gif/basic3dPrimitives.gif">here</a> end_html
13 //
14  gROOT->Reset();
15 //_____________________________
16 //
18 //_____________________________
20 //_____________________________
21 //
22 // create a canvas and a pad
23 //_____________________________
24  c1 = new TCanvas("c1","PolyLine3D & PolyMarker3D Window",200,10,700,500);
26  p1->Draw();
27  p1->cd();
28
29 //_____________________________
30 //
31 // create a first PolyLine3D
32 //_____________________________
33  St_PolyLine3D pl3d1(5);
34  Int_t i;
35
36  // set points
37  Float_t *pp = pl3d1.GetP();
38  pl3d1.SetPoint(0, 10, 10, 10);
39  for(i=0;i<=pl3d1.GetLastPosition();i++) printf(" %d: x=%f y=%f z=%f\n",i, pp[3*i], pp[3*i+1], pp[3*i+2]);
40  printf(" 1 -- \n");
41
42  pl3d1.SetPoint(1, 15.0, 15.0, 10.0);
43  for(i=0;i<=pl3d1.GetLastPosition();i++) printf(" %d: x=%f y=%f z=%f\n",i, pp[3*i], pp[3*i+1], pp[3*i+2]);
44  printf(" 2 -- \n");
45
46  pl3d1.SetPoint(2, 20, 15, 15);
47  for(i=0;i<=pl3d1.GetLastPosition();i++) printf(" %d: x=%f y=%f z=%f\n",i, pp[3*i], pp[3*i+1], pp[3*i+2]);
48  printf(" 3 -- \n");
49
50  pl3d1.SetPoint(3, 20, 20, 20);
51  for(i=0;i<=pl3d1.GetLastPosition();i++) printf(" %d: x=%f y=%f z=%f\n",i, pp[3*i], pp[3*i+1], pp[3*i+2]);
52  printf(" 4 -- \n");
53
54  pl3d1.SetPoint(4, 10, 10, 20);
55  for(i=0;i<=pl3d1.GetLastPosition();i++) printf(" %d: x=%f y=%f z=%f\n",i, pp[3*i], pp[3*i+1], pp[3*i+2]);
56  printf(" 5 -- \n");
57
58  // set attributes
59  pl3d1.SetVisibility(1);
60  pl3d1.SetSizeAttribute(3);
61  pl3d1.SetColorAttribute(5);
62
63
64 //_____________________________
65 //
66 // create a second PolyLine3D
67 //_____________________________
68  St_PolyLine3D pl3d2(4);
69
70  // set points
71  pl3d2.SetPoint(0, 5, 10, 5);
72  pl3d2.SetPoint(1, 10, 15, 8);
73  pl3d2.SetPoint(2, 15, 15, 18);
74  pl3d2.SetPoint(3, 5, 20, 20);
75  pl3d2.SetPoint(4, 10, 10, 5);
76
77  // set attributes
78  pl3d2.SetSizeAttribute(5);
79  pl3d2.SetColorAttribute(2);
80  pl3d2.SetVisibility(1);
81 //_____________________________
82 //
83 // create a first PolyMarker3D
84 //_____________________________
85  St_PolyLine3D pm3d1(12,"P");
86
87  // set points
88  pm3d1.SetPoint(0, 10, 10, 10);
89  pm3d1.SetPoint(1, 11, 15, 11);
90  pm3d1.SetPoint(2, 12, 15, 9);
91  pm3d1.SetPoint(3, 13, 17, 20);
92  pm3d1.SetPoint(4, 14, 16, 15);
93  pm3d1.SetPoint(5, 15, 20, 15);
94  pm3d1.SetPoint(6, 16, 18, 10);
95  pm3d1.SetPoint(7, 17, 15, 10);
96  pm3d1.SetPoint(8, 18, 22, 15);
97  pm3d1.SetPoint(9, 19, 28, 25);
98  pm3d1.SetPoint(10, 20, 12, 15);
99  pm3d1.SetPoint(11, 21, 12, 15);
100
101  // set marker size, color & style
102  pm3d1.SetSizeAttribute(2);
103  pm3d1.SetColorAttribute(4);
104  pm3d1.SetStyleAttribute(2);
105  pm3d1.SetVisibility(1);
106 //_____________________________
107 //
108 // create a second PolyMarker3D
109 //_____________________________
110  St_PolyLine3D pm3d2(8,"P");
111
112  pm3d2.SetPoint(0, 22, 15, 15);
113  pm3d2.SetPoint(1, 23, 18, 21);
114  pm3d2.SetPoint(2, 24, 26, 13);
115  pm3d2.SetPoint(3, 25, 17, 15);
116  pm3d2.SetPoint(4, 26, 20, 15);
117  pm3d2.SetPoint(5, 27, 15, 18);
118  pm3d2.SetPoint(6, 28, 20, 10);
119  pm3d2.SetPoint(7, 29, 20, 20);
120
121  // set marker size, color & style
122  pm3d2.SetSizeAttribute(2);
123  pm3d2.SetColorAttribute(1);
124  pm3d2.SetStyleAttribute(8);
125  pm3d2.SetVisibility(1);
126
127 //_____________________________
128 //
129 // creating a view
130 //_____________________________
131  view = new TView(1);
132  view->SetRange(5,5,5,25,25,25);
133 //_____________________________
134 //
135 // draw
136 //_____________________________
137  pl3d1.Draw("same");
138  pl3d2.Draw("same");
139  pm3d1.Draw("same");
140  pm3d2.Draw("same");
141 //_____________________________
142 //
143 // Draw axice
144 //_____________________________
145  St_PolyLine3D::Axis();
146  //
147  // draw a title/explanation in the canvas pad
148  c1->cd();
149  TPaveText title(0.1,0.85,0.9,0.97);
150  title.SetFillColor(24);