compound.C

Go to the documentation of this file.
00001 // @(#)root/eve:$Id: text_test.C 26717 2008-12-07 22:07:55Z matevz $
00002 // Author: Matevz Tadel
00003 
00004 // Demonstates usage of EVE compound objects - class TEveCompound.
00005 
00006 TEveLine* random_line(TRandom& rnd, Int_t n, Float_t delta)
00007 {
00008    TEveLine* line = new TEveLine;
00009    line->SetMainColor(kGreen);
00010 
00011    Float_t x = 0, y = 0, z = 0;
00012    for (Int_t i=0; i<n; ++i)
00013    {
00014       line->SetNextPoint(x, y, z);
00015       x += rnd.Uniform(0, delta);
00016       y += rnd.Uniform(0, delta);
00017       z += rnd.Uniform(0, delta);
00018    }
00019 
00020    return line;
00021 }
00022 
00023 void compound()
00024 {
00025    TEveManager::Create();
00026 
00027    TEveLine* ml = new TEveLine;
00028    ml->SetMainColor(kRed);
00029    ml->SetLineStyle(2);
00030    ml->SetLineWidth(3);
00031    gEve->InsertVizDBEntry("BigLine", ml);
00032 
00033    TEveCompound* cmp = new TEveCompound;
00034    cmp->SetMainColor(kGreen);
00035    gEve->AddElement(cmp);
00036 
00037    TRandom rnd(0);
00038 
00039    cmp->OpenCompound();
00040 
00041    cmp->AddElement(random_line(rnd, 20, 10));
00042    cmp->AddElement(random_line(rnd, 20, 10));
00043 
00044    TEveLine* line = random_line(rnd, 20, 12);
00045    line->ApplyVizTag("BigLine");
00046    cmp->AddElement(line);
00047 
00048    cmp->CloseCompound();
00049 
00050    // Projected view
00051    TEveViewer *viewer = gEve->SpawnNewViewer("Projected");
00052    TEveScene  *scene  = gEve->SpawnNewScene("Projected Event");
00053    viewer->AddScene(scene);
00054    {
00055       TGLViewer* v = viewer->GetGLViewer();
00056       v->SetCurrentCamera(TGLViewer::kCameraOrthoXOY);
00057    }
00058 
00059    // projections
00060    TEveProjectionManager* mng = new TEveProjectionManager(TEveProjection::kPT_RPhi);
00061    scene->AddElement(mng);
00062    TEveProjectionAxes* axes = new TEveProjectionAxes(mng);
00063    scene->AddElement(axes);
00064    gEve->AddToListTree(axes, kTRUE);
00065    gEve->AddToListTree(mng, kTRUE);
00066 
00067    mng->ImportElements(cmp);
00068 
00069    gEve->Redraw3D(kTRUE);
00070 }

Generated on Tue Jul 5 15:43:50 2011 for ROOT_528-00b_version by  doxygen 1.5.1