ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
basic3d.C
Go to the documentation of this file.
1 /// \file
2 /// \ingroup tutorial_graphics
3 /// Show 3-D polylines and markers.
4 ///
5 /// \macro_image
6 /// \macro_code
7 ///
8 /// \author Rene Brun
9 
10 void basic3d(){
11  TCanvas *c1 = new TCanvas("c1","PolyLine3D & PolyMarker3D Window",200,10,700,500);
12 
13  // create a pad
14  TPad *p1 = new TPad("p1","p1",0.05,0.02,0.95,0.82,46,3,1);
15  p1->Draw();
16  p1->cd();
17 
18  // creating a view
19  TView *view = TView::CreateView(1);
20  view->SetRange(5,5,5,25,25,25);
21 
22  // create a first PolyLine3D
23  TPolyLine3D *pl3d1 = new TPolyLine3D(5);
24 
25  // set points
26  pl3d1->SetPoint(0, 10, 10, 10);
27  pl3d1->SetPoint(1, 15, 15, 10);
28  pl3d1->SetPoint(2, 20, 15, 15);
29  pl3d1->SetPoint(3, 20, 20, 20);
30  pl3d1->SetPoint(4, 10, 10, 20);
31  // set attributes
32  pl3d1->SetLineWidth(3);
33  pl3d1->SetLineColor(5);
34 
35  // create a second PolyLine3D
36  TPolyLine3D *pl3d2 = new TPolyLine3D(4);
37 
38  // set points
39  pl3d2->SetPoint(0, 5, 10, 5);
40  pl3d2->SetPoint(1, 10, 15, 8);
41  pl3d2->SetPoint(2, 15, 15, 18);
42  pl3d2->SetPoint(3, 5, 20, 20);
43  pl3d2->SetPoint(4, 10, 10, 5);
44 
45  // set attributes
46  pl3d2->SetLineWidth(5);
47  pl3d2->SetLineColor(2);
48 
49  // create a first PolyMarker3D
50  TPolyMarker3D *pm3d1 = new TPolyMarker3D(12);
51 
52  // set points
53  pm3d1->SetPoint(0, 10, 10, 10);
54  pm3d1->SetPoint(1, 11, 15, 11);
55  pm3d1->SetPoint(2, 12, 15, 9);
56  pm3d1->SetPoint(3, 13, 17, 20);
57  pm3d1->SetPoint(4, 14, 16, 15);
58  pm3d1->SetPoint(5, 15, 20, 15);
59  pm3d1->SetPoint(6, 16, 18, 10);
60  pm3d1->SetPoint(7, 17, 15, 10);
61  pm3d1->SetPoint(8, 18, 22, 15);
62  pm3d1->SetPoint(9, 19, 28, 25);
63  pm3d1->SetPoint(10, 20, 12, 15);
64  pm3d1->SetPoint(11, 21, 12, 15);
65 
66  // set marker size, color & style
67  pm3d1->SetMarkerSize(2);
68  pm3d1->SetMarkerColor(4);
69  pm3d1->SetMarkerStyle(2);
70 
71  // create a second PolyMarker3D
72  TPolyMarker3D *pm3d2 = new TPolyMarker3D(8);
73 
74  pm3d2->SetPoint(0, 22, 15, 15);
75  pm3d2->SetPoint(1, 23, 18, 21);
76  pm3d2->SetPoint(2, 24, 26, 13);
77  pm3d2->SetPoint(3, 25, 17, 15);
78  pm3d2->SetPoint(4, 26, 20, 15);
79  pm3d2->SetPoint(5, 27, 15, 18);
80  pm3d2->SetPoint(6, 28, 20, 10);
81  pm3d2->SetPoint(7, 29, 20, 20);
82 
83  // set marker size, color & style
84  pm3d2->SetMarkerSize(2);
85  pm3d2->SetMarkerColor(1);
86  pm3d2->SetMarkerStyle(8);
87 
88  // draw
89  pl3d1->Draw();
90  pl3d2->Draw();
91  pm3d1->Draw();
92  pm3d2->Draw();
93  //
94  // draw a title/explanation in the canvas pad
95  c1->cd();
96  TPaveText *title = new TPaveText(0.1,0.85,0.9,0.97);
97  title->SetFillColor(24);
98  title->AddText("Examples of 3-D primitives");
99  TText *click=title->AddText("Click anywhere on the picture to rotate");
100  click->SetTextColor(4);
101  title->Draw();
102 }
virtual void SetLineWidth(Width_t lwidth)
Definition: TAttLine.h:57
virtual void Draw(Option_t *option="")
Draw this pavetext with its current attributes.
Definition: TPaveText.cxx:211
TVirtualPad * cd(Int_t subpadnumber=0)
Set current canvas & pad.
Definition: TCanvas.cxx:659
See TView3D.
Definition: TView.h:36
virtual TText * AddText(Double_t x1, Double_t y1, const char *label)
Add a new Text line to this pavetext at given coordinates.
Definition: TPaveText.cxx:160
virtual void SetRange(const Double_t *min, const Double_t *max)=0
A 3-dimensional polyline.
Definition: TPolyLine3D.h:41
TVirtualPad * cd(Int_t subpadnumber=0)
Set Current pad.
Definition: TPad.cxx:514
virtual void SetMarkerColor(Color_t mcolor=1)
Definition: TAttMarker.h:51
Base class for several text objects.
Definition: TText.h:42
virtual void Draw(Option_t *option="")
Draw Pad in Current pad (re-parent pad if necessary).
Definition: TPad.cxx:1192
virtual void SetLineColor(Color_t lcolor)
Definition: TAttLine.h:54
virtual void SetFillColor(Color_t fcolor)
Definition: TAttFill.h:50
The most important graphics class in the ROOT system.
Definition: TPad.h:46
virtual void SetMarkerStyle(Style_t mstyle=1)
Definition: TAttMarker.h:53
virtual void Draw(Option_t *option="")
Draws 3-D polymarker with its current attributes.
virtual void SetMarkerSize(Size_t msize=1)
Definition: TAttMarker.h:54
virtual void Draw(Option_t *option="")
Draw this 3-D polyline with its current attributes.
void SetPoint(Int_t n, Double_t x, Double_t y, Double_t z)
Set point n to x, y, z.
The Canvas class.
Definition: TCanvas.h:48
virtual void SetPoint(Int_t point, Double_t x, Double_t y, Double_t z)
Set point n to x, y, z.
A Pave (see TPave) with text, lines or/and boxes inside.
Definition: TPaveText.h:35
static TView * CreateView(Int_t system=1, const Double_t *rmin=0, const Double_t *rmax=0)
Create a concrete default 3-d view via the plug-in manager.
Definition: TView.cxx:36
A 3D polymarker.
Definition: TPolyMarker3D.h:40
virtual void SetTextColor(Color_t tcolor=1)
Definition: TAttText.h:57