ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
shapes.C
Go to the documentation of this file.
1 #include "TGeometry.h"
2 #include "TGeoManager.h"
3 
4 void shapes() {
5 //The old geometry shapes (see script geodemo.C)
6 //To see the output of this macro, click begin_html <a href="gif/shapes.gif" >here</a> end_html
7 //Author: Rene Brun
8 
9  TCanvas *c1 = new TCanvas("glc1","Geometry Shapes",200,10,700,500);
10 
11  gSystem->Load("libGeom");
12  //delete previous geometry objects in case this script is reexecuted
13  if (gGeoManager) {
16  }
17 
18  // Define some volumes
19  TBRIK *brik = new TBRIK("BRIK","BRIK","void",200,150,150);
20  TTRD1 *trd1 = new TTRD1("TRD1","TRD1","void",200,50,100,100);
21  TTRD2 *trd2 = new TTRD2("TRD2","TRD2","void",200,50,200,50,100);
22  TTRAP *trap = new TTRAP("TRAP","TRAP","void",190,0,0,60,40,90,15,120,80,180,15);
23  TPARA *para = new TPARA("PARA","PARA","void",100,200,200,15,30,30);
24  TGTRA *gtra = new TGTRA("GTRA","GTRA","void",390,0,0,20,60,40,90,15,120,80,180,15);
25  TTUBE *tube = new TTUBE("TUBE","TUBE","void",150,200,400);
26  TTUBS *tubs = new TTUBS("TUBS","TUBS","void",80,100,100,90,235);
27  TCONE *cone = new TCONE("CONE","CONE","void",100,50,70,120,150);
28  TCONS *cons = new TCONS("CONS","CONS","void",50,100,100,200,300,90,270);
29  TSPHE *sphe = new TSPHE("SPHE","SPHE","void",25,340, 45,135, 0,270);
30  TSPHE *sphe1 = new TSPHE("SPHE1","SPHE1","void",0,140, 0,180, 0,360);
31  TSPHE *sphe2 = new TSPHE("SPHE2","SPHE2","void",0,200, 10,120, 45,145);
32 
33  TPCON *pcon = new TPCON("PCON","PCON","void",180,270,4);
34  pcon->DefineSection(0,-200,50,100);
35  pcon->DefineSection(1,-50,50,80);
36  pcon->DefineSection(2,50,50,80);
37  pcon->DefineSection(3,200,50,100);
38 
39  TPGON *pgon = new TPGON("PGON","PGON","void",180,270,8,4);
40  pgon->DefineSection(0,-200,50,100);
41  pgon->DefineSection(1,-50,50,80);
42  pgon->DefineSection(2,50,50,80);
43  pgon->DefineSection(3,200,50,100);
44 
45  // Set shapes attributes
46  brik->SetLineColor(1);
47  trd1->SetLineColor(2);
48  trd2->SetLineColor(3);
49  trap->SetLineColor(4);
50  para->SetLineColor(5);
51  gtra->SetLineColor(7);
52  tube->SetLineColor(6);
53  tubs->SetLineColor(7);
54  cone->SetLineColor(2);
55  cons->SetLineColor(3);
56  pcon->SetLineColor(6);
57  pgon->SetLineColor(2);
58  sphe->SetLineColor(kRed);
59  sphe1->SetLineColor(kBlack);
60  sphe2->SetLineColor(kBlue);
61 
62 
63  // Build the geometry hierarchy
64  TNode *node1 = new TNode("NODE1","NODE1","BRIK");
65  node1->cd();
66 
67  TNode *node2 = new TNode("NODE2","NODE2","TRD1",0,0,-1000);
68  TNode *node3 = new TNode("NODE3","NODE3","TRD2",0,0,1000);
69  TNode *node4 = new TNode("NODE4","NODE4","TRAP",0,-1000,0);
70  TNode *node5 = new TNode("NODE5","NODE5","PARA",0,1000,0);
71  TNode *node6 = new TNode("NODE6","NODE6","TUBE",-1000,0,0);
72  TNode *node7 = new TNode("NODE7","NODE7","TUBS",1000,0,0);
73  TNode *node8 = new TNode("NODE8","NODE8","CONE",-300,-300,0);
74  TNode *node9 = new TNode("NODE9","NODE9","CONS",300,300,0);
75  TNode *node10 = new TNode("NODE10","NODE10","PCON",0,-1000,-1000);
76  TNode *node11 = new TNode("NODE11","NODE11","PGON",0,1000,1000);
77  TNode *node12 = new TNode("NODE12","NODE12","GTRA",0,-400,700);
78  TNode *node13 = new TNode("NODE13","NODE13","SPHE",10,-400,500);
79  TNode *node14 = new TNode("NODE14","NODE14","SPHE1",10, 250,300);
80  TNode *node15 = new TNode("NODE15","NODE15","SPHE2",10,-100,-200);
81 
82 
83  // Draw this geometry in the current canvas
84  node1->cd();
85  node1->Draw("gl");
86  c1->Update();
87  //
88  // Draw the geometry using the OpenGL viewver.
89  // Note that this viewver may also be invoked from the "View" menu in
90  // the canvas tool bar
91  //
92  // once in the viewer, select the Help button
93  // For example typing r will show a solid model of this geometry.
94 }
tuple tubs
Definition: shapes.py:22
virtual void Draw(Option_t *option="")
Draw Referenced node with current parameters.
Definition: TNode.cxx:323
void para(Int_t iaxis=0, Int_t ndiv=8, Double_t start=0, Double_t step=0)
Definition: geodemo.C:362
A segment of a conical tube.
Definition: TCONS.h:29
tuple node6
Definition: shapes.py:66
tuple node15
Definition: shapes.py:75
virtual void DefineSection(Int_t secNum, Float_t z, Float_t rmin, Float_t rmax)
Defines section secNum of the polycone.
Definition: TPCON.cxx:176
virtual void Delete(Option_t *option="")
Remove all objects from the array AND delete all heap based objects.
Definition: TObjArray.cxx:329
TCanvas * c1
Definition: legend1.C:2
Definition: Rtypes.h:61
A parallelepiped.
Definition: TPARA.h:32
Definition: Rtypes.h:60
virtual void cd(const char *path=0)
Change Current Reference node to this.
Definition: TNode.cxx:250
tuple node2
Definition: shapes.py:62
TNode description.
Definition: TNode.h:43
tuple sphe1
Definition: shapes.py:26
void shapes()
Definition: shapes.C:4
virtual int Load(const char *module, const char *entry="", Bool_t system=kFALSE)
Load a shared library.
Definition: TSystem.cxx:1766
TObjArray * GetListOfShapes() const
Definition: TGeoManager.h:467
void gtra(Int_t iaxis=0, Int_t ndiv=8, Double_t start=0, Double_t step=0)
Definition: geodemo.C:1488
tuple node8
Definition: shapes.py:68
void trap(Int_t iaxis=0, Int_t ndiv=8, Double_t start=0, Double_t step=0)
Definition: geodemo.C:1416
tuple brik
Definition: shapes.py:15
tuple node3
Definition: shapes.py:63
tuple node14
Definition: shapes.py:74
A Sphere.
Definition: TSPHE.h:30
TObjArray * GetListOfNodes()
Definition: TGeoManager.h:459
tuple node9
Definition: shapes.py:69
tuple node12
Definition: shapes.py:72
virtual void SetLineColor(Color_t lcolor)
Definition: TAttLine.h:54
tuple node4
Definition: shapes.py:64
void pcon(Int_t iaxis=0, Int_t ndiv=8, Double_t start=0, Double_t step=0)
Definition: geodemo.C:1109
R__EXTERN TSystem * gSystem
Definition: TSystem.h:545
tuple node7
Definition: shapes.py:67
void tube(Int_t iaxis=0, Int_t ndiv=8, Double_t start=0, Double_t step=0)
Definition: geodemo.C:425
void pgon(Int_t iaxis=0, Int_t ndiv=8, Double_t start=0, Double_t step=0)
Definition: geodemo.C:1189
A trapezoid with both x and y dimensions varying along z.
Definition: TTRD2.h:31
tuple node1
Definition: shapes.py:59
A general trapezoid.
Definition: TTRAP.h:35
void cone(Int_t iaxis=0, Int_t ndiv=8, Double_t start=0, Double_t step=0)
Definition: geodemo.C:626
A box with faces perpendicular to the axes.
Definition: TBRIK.h:28
The Canvas class.
Definition: TCanvas.h:48
void trd2(Int_t iaxis=0, Int_t ndiv=8, Double_t start=0, Double_t step=0)
Definition: geodemo.C:1350
A polycone.
Definition: TPCON.h:35
A polygon.
Definition: TPGON.h:32
R__EXTERN TGeoManager * gGeoManager
Definition: TGeoManager.h:556
tuple node10
Definition: shapes.py:70
A general twisted trapezoid.
Definition: TGTRA.h:29
void trd1(Int_t iaxis=0, Int_t ndiv=8, Double_t start=0, Double_t step=0)
Definition: geodemo.C:933
A trapezoid with the x dimension varying along z.
Definition: TTRD1.h:30
tuple node13
Definition: shapes.py:73
A tube.
Definition: TTUBE.h:34
Definition: Rtypes.h:61
tuple node11
Definition: shapes.py:71
virtual void Update()
Update canvas pad buffers.
Definition: TCanvas.cxx:2179
tuple node5
Definition: shapes.py:65
tuple sphe
Definition: shapes.py:25
A conical tube.
Definition: TCONE.h:30
tuple cons
Definition: shapes.py:24
A segment of a tube.
Definition: TTUBS.h:31
tuple sphe2
Definition: shapes.py:27