Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
xtruDraw.C
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_geom
3/// Draw a "representative" TXTRU shape
4///
5/// \macro_image
6/// \macro_code
7///
8/// \author Robert Hatcher (rhatcher@fnal.gov) 2000.09.06
9
10void xtruDraw()
11{
12 TCanvas *canvas = new TCanvas("xtru", "Example XTRU object", 200, 10, 640, 640);
13
14 // Create a new geometry
15 TGeometry *geometry = new TGeometry("geometry", "geometry");
16 geometry->cd();
17
18 TXTRU *atxtru = new TXTRU("atxtru", "atxtru", "void", 5, 2);
19
20 // outline and z segment specifications
21
22 Float_t x[] = {-177.292, -308.432, -308.432, -305.435, -292.456, -280.01, -241.91, -241.91,
23 -177.292, -177.292, 177.292, 177.292, 241.91, 241.91, 280.06, 297.942,
24 305.435, 308.432, 308.432, 177.292, 177.292, -177.292};
25 Float_t y[] = {154.711, 23.5712, 1.1938, 1.1938, 8.6868, 8.6868, -3.7592, -90.0938, -154.711, -190.602, -190.602,
26 -154.711, -90.0938, -3.7592, 8.6868, 8.6868, 1.1938, 1.1938, 23.5712, 154.711, 190.602, 190.602};
27 Float_t z[] = {0.00, 500.0};
28 Float_t scale[] = {1.00, 1.00};
29 Float_t x0[] = {0, 0};
30 Float_t y0[] = {0, 0};
31
32 Int_t i;
33
34 Int_t nxy = sizeof(x) / sizeof(Float_t);
35 for (i = 0; i < nxy; i++) {
36 atxtru->DefineVertex(i, x[i], y[i]);
37 }
38
39 Int_t nz = sizeof(z) / sizeof(Float_t);
40 for (i = 0; i < nz; i++) {
41 atxtru->DefineSection(i, z[i], scale[i], x0[i], y0[i]);
42 }
43
44 // Define a TNode where this example resides in the TGeometry
45 // Draw the TGeometry
46
47 TNode *anode = new TNode("anode", "anode", atxtru);
48 anode->SetLineColor(1);
49
50 geometry->Draw();
51
52 // Tweak the pad scales so as not to distort the shape
53
54 TVirtualPad *thisPad = gPad;
55 if (thisPad) {
56 TView *view = thisPad->GetView();
57 if (!view)
58 return;
59 Double_t min[3], max[3], center[3];
60 view->GetRange(min, max);
61 int i;
62 // Find the boxed center
63 for (i = 0; i < 3; i++)
64 center[i] = 0.5 * (max[i] + min[i]);
65 Double_t maxSide = 0;
66 // Find the largest side
67 for (i = 0; i < 3; i++)
68 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}
int Int_t
Definition RtypesCore.h:45
float Float_t
Definition RtypesCore.h:57
double Double_t
Definition RtypesCore.h:59
#define gPad
virtual void SetLineColor(Color_t lcolor)
Set the line color.
Definition TAttLine.h:40
The Canvas class.
Definition TCanvas.h:23
TGeometry description.
Definition TGeometry.h:39
TNode description.
Definition TNode.h:33
See TView3D.
Definition TView.h:25
virtual void GetRange(Float_t *min, Float_t *max)=0
virtual void SetRange(const Double_t *min, const Double_t *max)=0
TVirtualPad is an abstract base class for the Pad and Canvas classes.
Definition TVirtualPad.h:51
virtual void Modified(Bool_t flag=1)=0
virtual void Update()=0
virtual TView * GetView() const =0
A poly-extrusion.
Definition TXTRU.h:22
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:274
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:220
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
__device__ AFloat max(AFloat x, AFloat y)
Definition Kernels.cuh:207
Short_t Max(Short_t a, Short_t b)
Returns the largest of a and b.
Definition TMathBase.h:250