ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
shapesAnim.C
Go to the documentation of this file.
1 //macro illustrating how to animate a geometry picture using a Timer
2 //Author: Rene Brun
3 
6 Float_t phi = 30;
7 void shapesAnim() {
8  TCanvas *c1 = new TCanvas("c1","Geometry Shapes",10,10,500,500);
9 
10  // Define some volumes
11  TBRIK *brik = new TBRIK("BRIK","BRIK","void",200,150,150);
12  TTRD1 *trd1 = new TTRD1("TRD1","TRD1","void",200,50,100,100);
13  TTRD2 *trd2 = new TTRD2("TRD2","TRD2","void",200,50,200,50,100);
14  TTRAP *trap = new TTRAP("TRAP","TRAP","void",190,0,0,60,40,90,15,120,80,180,15);
15  TPARA *para = new TPARA("PARA","PARA","void",100,200,200,15,30,30);
16  TGTRA *gtra = new TGTRA("GTRA","GTRA","void",390,0,0,20,60,40,90,15,120,80,180,15);
17  TTUBE *tube = new TTUBE("TUBE","TUBE","void",150,200,400);
18  TTUBS *tubs = new TTUBS("TUBS","TUBS","void",80,100,100,90,235);
19  TCONE *cone = new TCONE("CONE","CONE","void",100,50,70,120,150);
20  TCONS *cons = new TCONS("CONS","CONS","void",50,100,100,200,300,90,270);
21  TSPHE *sphe = new TSPHE("SPHE","SPHE","void",25,340, 45,135, 0,270);
22  TSPHE *sphe1 = new TSPHE("SPHE1","SPHE1","void",0,140, 0,180, 0,360);
23  TSPHE *sphe2 = new TSPHE("SPHE2","SPHE2","void",0,200, 10,120, 45,145);
24 
25  TPCON *pcon = new TPCON("PCON","PCON","void",180,270,4);
26  pcon->DefineSection(0,-200,50,100);
27  pcon->DefineSection(1,-50,50,80);
28  pcon->DefineSection(2,50,50,80);
29  pcon->DefineSection(3,200,50,100);
30 
31  TPGON *pgon = new TPGON("PGON","PGON","void",180,270,8,4);
32  pgon->DefineSection(0,-200,50,100);
33  pgon->DefineSection(1,-50,50,80);
34  pgon->DefineSection(2,50,50,80);
35  pgon->DefineSection(3,200,50,100);
36 
37  // Set shapes attributes
38  brik->SetLineColor(1);
39  trd1->SetLineColor(2);
40  trd2->SetLineColor(3);
41  trap->SetLineColor(4);
42  para->SetLineColor(5);
43  gtra->SetLineColor(7);
44  tube->SetLineColor(6);
45  tubs->SetLineColor(7);
46  cone->SetLineColor(2);
47  cons->SetLineColor(3);
48  pcon->SetLineColor(6);
49  pgon->SetLineColor(2);
50  sphe->SetLineColor(kRed);
51  sphe1->SetLineColor(kBlack);
52  sphe2->SetLineColor(kBlue);
53 
54 
55  // Build the geometry hierarchy
56  TNode *node1 = new TNode("NODE1","NODE1","BRIK");
57  node1->cd();
58 
59  TNode *node2 = new TNode("NODE2","NODE2","TRD1",0,0,-1000);
60  TNode *node3 = new TNode("NODE3","NODE3","TRD2",0,0,1000);
61  TNode *node4 = new TNode("NODE4","NODE4","TRAP",0,-1000,0);
62  TNode *node5 = new TNode("NODE5","NODE5","PARA",0,1000,0);
63  TNode *node6 = new TNode("NODE6","NODE6","TUBE",-1000,0,0);
64  TNode *node7 = new TNode("NODE7","NODE7","TUBS",1000,0,0);
65  TNode *node8 = new TNode("NODE8","NODE8","CONE",-300,-300,0);
66  TNode *node9 = new TNode("NODE9","NODE9","CONS",300,300,0);
67  TNode *node10 = new TNode("NODE10","NODE10","PCON",0,-1000,-1000);
68  TNode *node11 = new TNode("NODE11","NODE11","PGON",0,1000,1000);
69  TNode *node12 = new TNode("NODE12","NODE12","GTRA",0,-400,700);
70  TNode *node13 = new TNode("NODE13","NODE13","SPHE",10,-400,500);
71  TNode *node14 = new TNode("NODE14","NODE14","SPHE1",10, 250,300);
72  TNode *node15 = new TNode("NODE15","NODE15","SPHE2",10,-100,-200);
73 
74 
75  // Draw this geometry in the current canvas
76  node1->cd();
77  node1->Draw();
78  c1->Update();
79 
80  //start a Timer
81  TTimer *timer = new TTimer(20);
82  timer->SetCommand("Animate()");
83  timer->TurnOn();
84 }
85 void Animate()
86 {
87  theta += 2;
88  phi += 2;
89  gPad->GetView()->RotateView(theta,phi);
90  gPad->Modified();
91  gPad->Update();
92 }
tuple tubs
Definition: shapes.py:22
void shapesAnim()
Definition: shapesAnim.C:7
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
float Float_t
Definition: RtypesCore.h:53
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
Float_t theta
Definition: shapesAnim.C:5
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 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
TStopwatch timer
Definition: pirndm.C:37
tuple node14
Definition: shapes.py:74
A Sphere.
Definition: TSPHE.h:30
tuple node9
Definition: shapes.py:69
tuple node12
Definition: shapes.py:72
void Animate()
Definition: shapesAnim.C:85
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
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
Handles synchronous and a-synchronous timer events.
Definition: TTimer.h:57
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
void SetCommand(const char *command)
Set the interpreter command to be executed at time out.
Definition: TTimer.cxx:172
Float_t phi
Definition: shapesAnim.C:6
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
double Double_t
Definition: RtypesCore.h:55
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
#define gPad
Definition: TVirtualPad.h:288
Double_t pi
Definition: shapesAnim.C:4
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
virtual void TurnOn()
Add the timer to the system timer list.
Definition: TTimer.cxx:239
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