ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
xtruDraw.C
Go to the documentation of this file.
1 void xtruDraw() {
2 // Draw a "representative" TXTRU shape
3 // Canvas saved as xtru.gif can be used for TXTRU THtml output
4 // Author: Robert Hatcher (rhatcher@fnal.gov) 2000.09.06
5 
6  TCanvas *canvas = new TCanvas("xtru","Example XTRU object",200,10,640,640);
7 
8 // Create a new geometry
9  TGeometry* geometry = new TGeometry("geometry","geometry");
10  geometry->cd();
11 
12  TXTRU* atxtru = new TXTRU("atxtru","atxtru","void",5,2);
13 
14 // outline and z segment specifications
15 
16  Float_t x[] =
17  { -177.292, -308.432, -308.432, -305.435, -292.456, -280.01
18  , -241.91, -241.91, -177.292, -177.292, 177.292, 177.292
19  , 241.91, 241.91, 280.06, 297.942, 305.435, 308.432
20  , 308.432, 177.292, 177.292, -177.292 };
21  Float_t y[] =
22  { 154.711, 23.5712, 1.1938, 1.1938, 8.6868, 8.6868
23  , -3.7592, -90.0938, -154.711, -190.602, -190.602, -154.711
24  , -90.0938, -3.7592, 8.6868, 8.6868, 1.1938, 1.1938
25  , 23.5712, 154.711, 190.602, 190.602 };
26  Float_t z[] =
27  { 0.00, 500.0 };
28  Float_t scale[] =
29  { 1.00, 1.00 };
30  Float_t x0[] =
31  { 0, 0 };
32  Float_t y0[] =
33  { 0, 0 };
34 
35  Int_t i;
36 
37  Int_t nxy = sizeof(x)/sizeof(Float_t);
38  for (i=0; i<nxy; i++) {
39  atxtru->DefineVertex(i,x[i],y[i]);
40  }
41 
42  Int_t nz = sizeof(z)/sizeof(Float_t);
43  for (i=0; i<nz; i++) {
44  atxtru->DefineSection(i,z[i],scale[i],x0[i],y0[i]);
45  }
46 
47 // Define a TNode where this example resides in the TGeometry
48 // Draw the TGeometry
49 
50  TNode* anode = new TNode("anode","anode",atxtru);
51  anode->SetLineColor(1);
52 
53  geometry->Draw();
54 
55 // Tweak the pad scales so as not to distort the shape
56 
57  TVirtualPad *thisPad = gPad;
58  if (thisPad) {
59  TView *view = thisPad->GetView();
60  if (!view) return;
61  Double_t min[3],max[3],center[3];
62  view->GetRange(min,max);
63  int i;
64  // Find the boxed center
65  for (i=0;i<3; i++) center[i] = 0.5*(max[i]+min[i]);
66  Double_t maxSide = 0;
67  // Find the largest side
68  for (i=0;i<3; i++) maxSide = TMath::Max(maxSide,max[i]-center[i]);
69  file://Adjust scales:
70  for (i=0;i<3; i++) {
71  max[i] = center[i] + maxSide;
72  min[i] = center[i] - maxSide;
73  }
74  view->SetRange(min,max);
75  Int_t ireply;
76  thisPad->Modified();
77  thisPad->Update();
78  }
79 
80 }
static Vc_ALWAYS_INLINE int_v min(const int_v &x, const int_v &y)
Definition: vector.h:433
float Float_t
Definition: RtypesCore.h:53
virtual void Update()=0
void geometry()
Definition: geometry.C:4
See TView3D.
Definition: TView.h:36
TNode description.
Definition: TNode.h:43
virtual void SetRange(const Double_t *min, const Double_t *max)=0
int Int_t
Definition: RtypesCore.h:41
Double_t x[n]
Definition: legend1.C:17
Float_t z[5]
Definition: Ifit.C:16
TVirtualPad is an abstract base class for the Pad and Canvas classes.
Definition: TVirtualPad.h:59
virtual TView * GetView() const =0
TGeometry description.
Definition: TGeometry.h:43
virtual void DefineSection(Int_t secNum, Float_t z, Float_t scale=1., Float_t x0=0., Float_t y0=0.)
Set z section iz information expand size of array if necessary.
Definition: TXTRU.cxx:250
virtual void SetLineColor(Color_t lcolor)
Definition: TAttLine.h:54
A poly-extrusion.
Definition: TXTRU.h:24
virtual void Draw(Option_t *option="")
Draw this Geometry.
Definition: TGeometry.cxx:254
virtual void Modified(Bool_t flag=1)=0
The Canvas class.
Definition: TCanvas.h:48
tuple file
Definition: fildir.py:20
double Double_t
Definition: RtypesCore.h:55
Double_t y[n]
Definition: legend1.C:17
tuple view
Definition: tornado.py:20
void xtruDraw()
Definition: xtruDraw.C:1
static Vc_ALWAYS_INLINE int_v max(const int_v &x, const int_v &y)
Definition: vector.h:440
virtual void DefineVertex(Int_t pointNum, Float_t x, Float_t y)
Set vertex point ipt to (x,y) expand size of array if necessary.
Definition: TXTRU.cxx:304
virtual void cd(const char *path=0)
Change Current Geometry to this.
Definition: TGeometry.cxx:246
Short_t Max(Short_t a, Short_t b)
Definition: TMathBase.h:202
virtual void GetRange(Float_t *min, Float_t *max)=0
#define gPad
Definition: TVirtualPad.h:288