ROOT logo

From $ROOTSYS/tutorials/graphics/basic3d.C

{
   // Show 3-D polylines and markers
   // To see the output of this macro, click begin_html <a href="gif/basic3d.gif">here</a> end_html
   //
   gROOT->Reset();
   c1 = new TCanvas("c1","PolyLine3D & PolyMarker3D Window",200,10,700,500);

   // create a pad
   p1 = new TPad("p1","p1",0.05,0.02,0.95,0.82,46,3,1);
   p1->Draw();
   p1->cd();

   // creating a view
   view = TView::CreateView(1);
   view->SetRange(5,5,5,25,25,25);

   // create a first PolyLine3D
   TPolyLine3D *pl3d1 = new TPolyLine3D(5);

   // set points
   pl3d1->SetPoint(0, 10, 10, 10);
   pl3d1->SetPoint(1, 15, 15, 10);
   pl3d1->SetPoint(2, 20, 15, 15);
   pl3d1->SetPoint(3, 20, 20, 20);
   pl3d1->SetPoint(4, 10, 10, 20);
   // set attributes
   pl3d1->SetLineWidth(3);
   pl3d1->SetLineColor(5);

   // create a second PolyLine3D
   TPolyLine3D *pl3d2 = new TPolyLine3D(4);

   // set points
   pl3d2->SetPoint(0, 5, 10, 5);
   pl3d2->SetPoint(1, 10, 15, 8);
   pl3d2->SetPoint(2, 15, 15, 18);
   pl3d2->SetPoint(3, 5, 20, 20);
   pl3d2->SetPoint(4, 10, 10, 5);

   // set attributes
   pl3d2->SetLineWidth(5);
   pl3d2->SetLineColor(2);

   // create a first PolyMarker3D
   TPolyMarker3D *pm3d1 = new TPolyMarker3D(12);

   // set points
   pm3d1->SetPoint(0, 10, 10, 10);
   pm3d1->SetPoint(1, 11, 15, 11);
   pm3d1->SetPoint(2, 12, 15, 9);
   pm3d1->SetPoint(3, 13, 17, 20);
   pm3d1->SetPoint(4, 14, 16, 15);
   pm3d1->SetPoint(5, 15, 20, 15);
   pm3d1->SetPoint(6, 16, 18, 10);
   pm3d1->SetPoint(7, 17, 15, 10);
   pm3d1->SetPoint(8, 18, 22, 15);
   pm3d1->SetPoint(9, 19, 28, 25);
   pm3d1->SetPoint(10, 20, 12, 15);
   pm3d1->SetPoint(11, 21, 12, 15);

   // set marker size, color & style
   pm3d1->SetMarkerSize(2);
   pm3d1->SetMarkerColor(4);
   pm3d1->SetMarkerStyle(2);

   // create a second PolyMarker3D
   TPolyMarker3D *pm3d2 = new TPolyMarker3D(8);

   pm3d2->SetPoint(0, 22, 15, 15);
   pm3d2->SetPoint(1, 23, 18, 21);
   pm3d2->SetPoint(2, 24, 26, 13);
   pm3d2->SetPoint(3, 25, 17, 15);
   pm3d2->SetPoint(4, 26, 20, 15);
   pm3d2->SetPoint(5, 27, 15, 18);
   pm3d2->SetPoint(6, 28, 20, 10);
   pm3d2->SetPoint(7, 29, 20, 20);

   // set marker size, color & style
   pm3d2->SetMarkerSize(2);
   pm3d2->SetMarkerColor(1);
   pm3d2->SetMarkerStyle(8);

   // draw
   pl3d1->Draw();
   pl3d2->Draw();
   pm3d1->Draw();
   pm3d2->Draw();
   //
   // draw a title/explanation in the canvas pad
   c1->cd();
   TPaveText *title = new TPaveText(0.1,0.85,0.9,0.97);
   title->SetFillColor(24);
   title->AddText("Examples of 3-D primitives");
   TText *click=title->AddText("Click anywhere on the picture to rotate");
   click->SetTextColor(4);
   title->Draw();
}
 basic3d.C:1
 basic3d.C:2
 basic3d.C:3
 basic3d.C:4
 basic3d.C:5
 basic3d.C:6
 basic3d.C:7
 basic3d.C:8
 basic3d.C:9
 basic3d.C:10
 basic3d.C:11
 basic3d.C:12
 basic3d.C:13
 basic3d.C:14
 basic3d.C:15
 basic3d.C:16
 basic3d.C:17
 basic3d.C:18
 basic3d.C:19
 basic3d.C:20
 basic3d.C:21
 basic3d.C:22
 basic3d.C:23
 basic3d.C:24
 basic3d.C:25
 basic3d.C:26
 basic3d.C:27
 basic3d.C:28
 basic3d.C:29
 basic3d.C:30
 basic3d.C:31
 basic3d.C:32
 basic3d.C:33
 basic3d.C:34
 basic3d.C:35
 basic3d.C:36
 basic3d.C:37
 basic3d.C:38
 basic3d.C:39
 basic3d.C:40
 basic3d.C:41
 basic3d.C:42
 basic3d.C:43
 basic3d.C:44
 basic3d.C:45
 basic3d.C:46
 basic3d.C:47
 basic3d.C:48
 basic3d.C:49
 basic3d.C:50
 basic3d.C:51
 basic3d.C:52
 basic3d.C:53
 basic3d.C:54
 basic3d.C:55
 basic3d.C:56
 basic3d.C:57
 basic3d.C:58
 basic3d.C:59
 basic3d.C:60
 basic3d.C:61
 basic3d.C:62
 basic3d.C:63
 basic3d.C:64
 basic3d.C:65
 basic3d.C:66
 basic3d.C:67
 basic3d.C:68
 basic3d.C:69
 basic3d.C:70
 basic3d.C:71
 basic3d.C:72
 basic3d.C:73
 basic3d.C:74
 basic3d.C:75
 basic3d.C:76
 basic3d.C:77
 basic3d.C:78
 basic3d.C:79
 basic3d.C:80
 basic3d.C:81
 basic3d.C:82
 basic3d.C:83
 basic3d.C:84
 basic3d.C:85
 basic3d.C:86
 basic3d.C:87
 basic3d.C:88
 basic3d.C:89
 basic3d.C:90
 basic3d.C:91
 basic3d.C:92
 basic3d.C:93
 basic3d.C:94
 basic3d.C:95
 basic3d.C:96
 basic3d.C:97
 basic3d.C:98
thumb