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/// \preview Show 3-D polylines and markers.
5///
6/// \macro_image
7/// \macro_code
8///
9/// \author Rene Brun
10
11void basic3d()
12{
13 TCanvas *c1 = new TCanvas("c1", "PolyLine3D & PolyMarker3D Window", 200, 10, 700, 500);
14
15 // create a pad
16 TPad *p1 = new TPad("p1", "p1", 0.05, 0.02, 0.95, 0.82, 46, 3, 1);
17 p1->Draw();
18 p1->cd();
19
20 // creating a view
21 TView *view = TView::CreateView(1);
22 view->SetRange(5, 5, 5, 25, 25, 25);
23
24 // create a first PolyLine3D
26
27 // set points
28 pl3d1->SetPoint(0, 10, 10, 10);
29 pl3d1->SetPoint(1, 15, 15, 10);
30 pl3d1->SetPoint(2, 20, 15, 15);
31 pl3d1->SetPoint(3, 20, 20, 20);
32 pl3d1->SetPoint(4, 10, 10, 20);
33 // set attributes
34 pl3d1->SetLineWidth(3);
35 pl3d1->SetLineColor(5);
36
37 // create a second PolyLine3D
39
40 // set points
41 pl3d2->SetPoint(0, 5, 10, 5);
42 pl3d2->SetPoint(1, 10, 15, 8);
43 pl3d2->SetPoint(2, 15, 15, 18);
44 pl3d2->SetPoint(3, 5, 20, 20);
45 pl3d2->SetPoint(4, 10, 10, 5);
46
47 // set attributes
48 pl3d2->SetLineWidth(5);
49 pl3d2->SetLineColor(2);
50
51 // create a first PolyMarker3D
53
54 // set points
55 pm3d1->SetPoint(0, 10, 10, 10);
56 pm3d1->SetPoint(1, 11, 15, 11);
57 pm3d1->SetPoint(2, 12, 15, 9);
58 pm3d1->SetPoint(3, 13, 17, 20);
59 pm3d1->SetPoint(4, 14, 16, 15);
60 pm3d1->SetPoint(5, 15, 20, 15);
61 pm3d1->SetPoint(6, 16, 18, 10);
62 pm3d1->SetPoint(7, 17, 15, 10);
63 pm3d1->SetPoint(8, 18, 22, 15);
64 pm3d1->SetPoint(9, 19, 28, 25);
65 pm3d1->SetPoint(10, 20, 12, 15);
66 pm3d1->SetPoint(11, 21, 12, 15);
67
68 // set marker size, color & style
69 pm3d1->SetMarkerSize(2);
70 pm3d1->SetMarkerColor(4);
71 pm3d1->SetMarkerStyle(2);
72
73 // create a second PolyMarker3D
75
76 pm3d2->SetPoint(0, 22, 15, 15);
77 pm3d2->SetPoint(1, 23, 18, 21);
78 pm3d2->SetPoint(2, 24, 26, 13);
79 pm3d2->SetPoint(3, 25, 17, 15);
80 pm3d2->SetPoint(4, 26, 20, 15);
81 pm3d2->SetPoint(5, 27, 15, 18);
82 pm3d2->SetPoint(6, 28, 20, 10);
83 pm3d2->SetPoint(7, 29, 20, 20);
84
85 // set marker size, color & style
86 pm3d2->SetMarkerSize(2);
87 pm3d2->SetMarkerColor(1);
88 pm3d2->SetMarkerStyle(8);
89
90 // draw
91 pl3d1->Draw();
92 pl3d2->Draw();
93 pm3d1->Draw();
94 pm3d2->Draw();
95 //
96 // draw a title/explanation in the canvas pad
97 c1->cd();
98 TPaveText *title = new TPaveText(0.1, 0.85, 0.9, 0.97);
99 title->SetFillColor(24);
100 title->AddText("Examples of 3-D primitives");
101 TText *click = title->AddText("Click anywhere on the picture to rotate");
102 click->SetTextColor(4);
103 title->Draw();
104}
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
Definition TAttFill.h:38
The Canvas class.
Definition TCanvas.h:23
The most important graphics class in the ROOT system.
Definition TPad.h:28
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.
void Draw(Option_t *option="") override
Draw this pavetext with its current attributes.
A 3-dimensional polyline.
Definition TPolyLine3D.h:33
A 3D polymarker.
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=nullptr, const Double_t *rmax=nullptr)
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