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