ROOT logo
// @(#)root/eve:$Id: text_test.C 26717 2008-12-07 22:07:55Z matevz $
// Author: Matevz Tadel

// Demonstates usage of EVE compound objects - class TEveCompound.

TEveLine* random_line(TRandom& rnd, Int_t n, Float_t delta)
{
   TEveLine* line = new TEveLine;
   line->SetMainColor(kGreen);

   Float_t x = 0, y = 0, z = 0;
   for (Int_t i=0; i<n; ++i)
   {
      line->SetNextPoint(x, y, z);
      x += rnd.Uniform(0, delta);
      y += rnd.Uniform(0, delta);
      z += rnd.Uniform(0, delta);
   }

   return line;
}

void test_compound()
{
   TEveManager::Create();

   TEveLine* ml = new TEveLine;
   ml->SetMainColor(kRed);
   ml->SetLineStyle(2);
   ml->SetLineWidth(3);
   gEve->InsertVizDBEntry("BigLine", ml);

   TEveCompound* cmp = new TEveCompound;
   cmp->SetMainColor(kGreen);
   gEve->AddElement(cmp);

   TRandom rnd(0);

   cmp->OpenCompound();

   cmp->AddElement(random_line(rnd, 20, 10));
   cmp->AddElement(random_line(rnd, 20, 10));

   TEveLine* line = random_line(rnd, 20, 12);
   line->ApplyVizTag("BigLine");
   cmp->AddElement(line);

   cmp->CloseCompound();

   // Projected view
   TEveViewer *viewer = gEve->SpawnNewViewer("Projected");
   TEveScene  *scene  = gEve->SpawnNewScene("Projected Event");
   viewer->AddScene(scene);
   {
      TGLViewer* v = viewer->GetGLViewer();
      v->SetCurrentCamera(TGLViewer::kCameraOrthoXOY);
   }

   // projections
   TEveProjectionManager* mng = new TEveProjectionManager();
   scene->AddElement(mng);
   TEveProjectionAxes* axes = new TEveProjectionAxes(mng);
   scene->AddElement(axes);
   gEve->AddToListTree(axes, kTRUE);
   gEve->AddToListTree(mng, kTRUE);

   mng->ImportElements(cmp);

   gEve->Redraw3D(kTRUE);
}
 test_compound.C:1
 test_compound.C:2
 test_compound.C:3
 test_compound.C:4
 test_compound.C:5
 test_compound.C:6
 test_compound.C:7
 test_compound.C:8
 test_compound.C:9
 test_compound.C:10
 test_compound.C:11
 test_compound.C:12
 test_compound.C:13
 test_compound.C:14
 test_compound.C:15
 test_compound.C:16
 test_compound.C:17
 test_compound.C:18
 test_compound.C:19
 test_compound.C:20
 test_compound.C:21
 test_compound.C:22
 test_compound.C:23
 test_compound.C:24
 test_compound.C:25
 test_compound.C:26
 test_compound.C:27
 test_compound.C:28
 test_compound.C:29
 test_compound.C:30
 test_compound.C:31
 test_compound.C:32
 test_compound.C:33
 test_compound.C:34
 test_compound.C:35
 test_compound.C:36
 test_compound.C:37
 test_compound.C:38
 test_compound.C:39
 test_compound.C:40
 test_compound.C:41
 test_compound.C:42
 test_compound.C:43
 test_compound.C:44
 test_compound.C:45
 test_compound.C:46
 test_compound.C:47
 test_compound.C:48
 test_compound.C:49
 test_compound.C:50
 test_compound.C:51
 test_compound.C:52
 test_compound.C:53
 test_compound.C:54
 test_compound.C:55
 test_compound.C:56
 test_compound.C:57
 test_compound.C:58
 test_compound.C:59
 test_compound.C:60
 test_compound.C:61
 test_compound.C:62
 test_compound.C:63
 test_compound.C:64
 test_compound.C:65
 test_compound.C:66
 test_compound.C:67
 test_compound.C:68
 test_compound.C:69
 test_compound.C:70
 test_compound.C:71
thumb