void geom_alias() { TEveManager::Create(); gEve->RegisterGeometryAlias("ALICE", "http://root.cern.ch/files/alice.root"); gEve->RegisterGeometryAlias("ATLAS", "http://root.cern.ch/files/atlas.root"); gGeoManager = gEve->GetGeometryByAlias("ALICE"); TGeoNode* node1 = gGeoManager->GetTopVolume()->FindNode("ITSV_1"); TEveGeoTopNode* its = new TEveGeoTopNode(gGeoManager, node1); gEve->AddGlobalElement(its); gGeoManager = gEve->GetGeometryByAlias("ATLAS"); TGeoNode* node2 = gGeoManager->GetTopVolume()->FindNode("OUTE_1"); TEveGeoTopNode* atlas = new TEveGeoTopNode(gGeoManager, node2); gEve->AddGlobalElement(atlas); gEve->FullRedraw3D(kTRUE); // EClipType not exported to CINT (see TGLUtil.h): // 0 - no clip, 1 - clip plane, 2 - clip box TGLViewer *v = gEve->GetDefaultGLViewer(); v->GetClipSet()->SetClipType(2); v->RefreshPadEditor(v); v->CurrentCamera().RotateRad(-0.5, -2.4); v->DoDraw(); }
void its_module_stepper(Int_t det = 0) { AliRunLoader* rl = AliEveEventManager::AssertRunLoader(); rl->LoadDigits("ITS"); TTree* dt = rl->GetTreeD("ITS", false); AliEveITSDigitsInfo* di = new AliEveITSDigitsInfo(); di->SetTree(dt); di->Dump(); gEve->DisableRedraw(); AliEveITSModuleStepper* ms = new AliEveITSModuleStepper(di); ms->SetMainColor(8); gStyle->SetPalette(1, 0); ms->DisplayDet(det, -1); gEve->AddElement(ms); gEve->Redraw3D(kTRUE); // To enforce camera reset gEve->EnableRedraw(); TGLViewer* v = gEve->GetDefaultGLViewer(); v->SetCurrentCamera(TGLViewer::kCameraOrthoXOY); /* * Disabling obsolete code * */ //TGLCameraMarkupStyle* mup = v->GetCameraMarkup(); //if(mup) mup->SetShow(kFALSE); }
void geom_atlas() { TEveManager::Create(); TFile::SetCacheFileDir("."); gGeoManager = gEve->GetGeometry("http://root.cern.ch/files/atlas.root"); gGeoManager->DefaultColors(); TGeoNode* node1 = gGeoManager->GetTopVolume()->FindNode("INNE_1"); TEveGeoTopNode* inn = new TEveGeoTopNode(gGeoManager, node1); gEve->AddGlobalElement(inn); TGeoNode* node2 = gGeoManager->GetTopVolume()->FindNode("CENT_1"); TEveGeoTopNode* cnt = new TEveGeoTopNode(gGeoManager, node2); gEve->AddGlobalElement(cnt); TGeoNode* node3 = gGeoManager->GetTopVolume()->FindNode("OUTE_1"); TEveGeoTopNode* out = new TEveGeoTopNode(gGeoManager, node3); gEve->AddGlobalElement(out); gEve->FullRedraw3D(kTRUE); // EClipType not exported to CINT (see TGLUtil.h): // 0 - no clip, 1 - clip plane, 2 - clip box TGLViewer *v = gEve->GetDefaultGLViewer(); v->GetClipSet()->SetClipType(TGLClip::EType(1)); v->RefreshPadEditor(v); v->CurrentCamera().RotateRad(-.7, 0.5); v->DoDraw(); }
//__________________________________________________________________________ Bool_t Draw_Geom(const TGeoManager* geoManager) { // ------------------------------------- // -- Draw the vis-geometry in OpenGLViewer TCanvas* canvas = new TCanvas("GeomCanvas","Canvas for visualisation of EDM Geom",60,40,600,600); canvas->cd(); geoManager->GetTopVolume()->Draw("ogl"); geoManager->SetVisLevel(4); // Default draws 4 levels down volume heirarchy geoManager->SetVisOption(0); // Default is 1, but 0 draws all the intermediate volumes not just the final bottom layer geoManager->ViewLeaves(kTRUE); // -- Get the GLViewer so we can manipulate the camera TGLViewer * glViewer = dynamic_cast<TGLViewer*>(gPad->GetViewer3D()); // -- Select Draw style glViewer->SetStyle(TGLRnrCtx::kFill); // TGLRnrCtx::kFill, TGLRnrCtx::kOutline, TGLRnrCtx::kWireFrame // -- Set Background colour glViewer->SetClearColor(TColor::kWhite); // -- Set Lights - turn some off if you wish // TGLLightSet* lightSet = glViewer->GetLightSet(); // lightSet->SetLight(TGLLightSet::kLightLeft, kFALSE); // -- Set Camera type // kCameraPerspXOZ, kCameraPerspYOZ, kCameraPerspXOY, kCameraOrthoXOY // kCameraOrthoXOZ, kCameraOrthoZOY, kCameraOrthoXnOY, kCameraOrthoXnOZ, kCameraOrthoZnOY TGLViewer::ECameraType camera = 2; glViewer->SetCurrentCamera(camera); glViewer->CurrentCamera().SetExternalCenter(kTRUE); Double_t cameraCentre[3] = {0., 0., 0.}; glViewer->SetPerspectiveCamera(camera,4,100,&cameraCentre[0],0,0); // -- Draw Reference Point, Axes Double_t refPoint[3] = {0.,0.,0.}; // Int_t axesType = 0(Off), 1(EDGE), 2(ORIGIN), Bool_t axesDepthTest, Bool_t referenceOn, const Double_t referencePos[3] glViewer->SetGuideState(0, kFALSE, kFALSE, refPoint); glViewer->UpdateScene(); return kTRUE; }
void 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(TEveProjection::kPT_RPhi); 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); }
void auto_rotate_camera() { static Double_t hRotateStep = 0.005; static Double_t vRotateStep = 0.025; g_rotate_theta += hRotateStep * g_rotate_speed; if (g_rotate_theta >= 0.8 || g_rotate_theta <= -0.8) { hRotateStep = -hRotateStep; } TGLViewer *v = gEve->GetDefaultGLViewer(); TGLCamera &cam = v->CurrentCamera(); cam.RotateRad(hRotateStep * g_rotate_speed, vRotateStep * g_rotate_speed); v->RequestDraw(TGLRnrCtx::kLODHigh); }
void projection() { TFile::SetCacheFileDir("."); TEveManager::Create(); // camera TEveScene* s = gEve->SpawnNewScene("Projected Event"); gEve->GetDefaultViewer()->AddScene(s); TGLViewer* v = gEve->GetDefaultGLViewer(); v->SetCurrentCamera(TGLViewer::kCameraOrthoXOY); TGLOrthoCamera* cam = (TGLOrthoCamera*) v->CurrentCamera(); cam->SetZoomMinMax(0.2, 20); // projections TEveProjectionManager* mng = new TEveProjectionManager(TEveProjection::kPT_RPhi); s->AddElement(mng); TEveProjectionAxes* axes = new TEveProjectionAxes(mng); axes->SetTitle("TEveProjections demo"); s->AddElement(axes); gEve->AddToListTree(axes, kTRUE); gEve->AddToListTree(mng, kTRUE); // Simple geometry TFile* geom = TFile::Open(esd_geom_file_name, "CACHEREAD"); if (!geom) return; TEveGeoShapeExtract* gse = (TEveGeoShapeExtract*) geom->Get("Gentle"); TEveGeoShape* gsre = TEveGeoShape::ImportShapeExtract(gse, 0); geom->Close(); delete geom; gsre->SetPickableRecursively(kTRUE); gEve->AddGlobalElement(gsre); gEve->GetGlobalScene()->SetRnrState(kFALSE); mng->ImportElements(gsre); TEveLine* line = new TEveLine; line->SetMainColor(kGreen); for (Int_t i=0; i<160; ++i) line->SetNextPoint(120*sin(0.2*i), 120*cos(0.2*i), 80-i); gEve->AddElement(line); mng->ImportElements(line); line->SetRnrSelf(kFALSE); gEve->Redraw3D(kTRUE); }
void geom_cms() { TEveManager::Create(); TFile::SetCacheFileDir("."); gGeoManager = gEve->GetGeometry("http://root.cern.ch/files/cms.root"); gGeoManager->DefaultColors(); TGeoVolume* top = gGeoManager->GetTopVolume()->FindNode("CMSE_1")->GetVolume(); TEveGeoTopNode* trk = new TEveGeoTopNode(gGeoManager, top->FindNode("TRAK_1")); trk->SetVisLevel(6); gEve->AddGlobalElement(trk); TEveGeoTopNode* calo = new TEveGeoTopNode(gGeoManager, top->FindNode("CALO_1")); calo->SetVisLevel(3); gEve->AddGlobalElement(calo); TEveGeoTopNode* muon = new TEveGeoTopNode(gGeoManager, top->FindNode("MUON_1")); muon->SetVisLevel(4); gEve->AddGlobalElement(muon); gEve->FullRedraw3D(kTRUE); // EClipType not exported to CINT (see TGLUtil.h): // 0 - no clip, 1 - clip plane, 2 - clip box TGLViewer *v = gEve->GetDefaultGLViewer(); v->GetClipSet()->SetClipType(TGLClip::EType(1)); v->ColorSet().Background().SetColor(kMagenta+4); v->SetGuideState(TGLUtil::kAxesEdge, kTRUE, kFALSE, 0); v->RefreshPadEditor(v); v->CurrentCamera().RotateRad(-1.2, 0.5); v->DoDraw(); }
void geom_lhcb() { TEveManager::Create(); TFile::SetCacheFileDir("."); gGeoManager = gEve->GetGeometry("http://root.cern.ch/files/lhcbfull.root"); gGeoManager->DefaultColors(); TEveGeoTopNode* tn = new TEveGeoTopNode(gGeoManager, gGeoManager->GetTopNode()); tn->SetVisLevel(4); gEve->AddGlobalElement(tn); gEve->FullRedraw3D(kTRUE); // EClipType not exported to CINT (see TGLUtil.h): // 0 - no clip, 1 - clip plane, 2 - clip box TGLViewer *v = gEve->GetDefaultGLViewer(); v->GetClipSet()->SetClipType(TGLClip::EType(1)); v->ColorSet().Background().SetColor(kMagenta+4); v->SetGuideState(TGLUtil::kAxesEdge, kTRUE, kFALSE, 0); v->RefreshPadEditor(v); v->CurrentCamera().RotateRad(-1.2, 0.5); v->DoDraw(); }
//______________________________________________________________________________ TEveCaloLego* MakeCaloLego(TEveCaloData* data, TEveWindowSlot* slot) { // Eta-phi lego view. TEveViewer* v; TEveScene* s; if (slot) { TEveViewer* v; TEveScene* s; MakeViewerScene(slot, v, s); } else { v = gEve->GetDefaultViewer(); s = gEve->GetEventScene(); } v->SetElementName("Viewer - Lego"); s->SetElementName("Scene - Lego"); gStyle->SetPalette(1, 0); TEveCaloLego* lego = new TEveCaloLego(data); s->AddElement(lego); // By the default lego extends is (1x1x1). Resize it to put in 'natural' // coordinates, so that y extend in 2*Pi and set height of lego two times // smaller than y extend to have better view in 3D perspective. lego->InitMainTrans(); lego->RefMainTrans().SetScale(TMath::TwoPi(), TMath::TwoPi(), TMath::Pi()); // draws scales and axis on borders of window TGLViewer* glv = v->GetGLViewer(); TEveCaloLegoOverlay* overlay = new TEveCaloLegoOverlay(); glv->AddOverlayElement(overlay); overlay->SetCaloLego(lego); // set event handler to move from perspective to orthographic view. glv->SetCurrentCamera(TGLViewer::kCameraOrthoXOY); glv->SetEventHandler (new TEveLegoEventHandler(glv->GetGLWidget(), glv, lego)); gEve->AddToListTree(lego, kTRUE); return lego; }
void geom_cms_stereo() { TEveManager::Create(); TFile::SetCacheFileDir("."); gGeoManager = gEve->GetGeometry("http://root.cern.ch/files/cms.root"); gGeoManager->DefaultColors(); TGeoVolume* top = gGeoManager->GetTopVolume()->FindNode("CMSE_1")->GetVolume(); TEveGeoTopNode* trk = new TEveGeoTopNode(gGeoManager, top->FindNode("TRAK_1")); trk->SetVisLevel(6); gEve->AddGlobalElement(trk); TEveGeoTopNode* calo = new TEveGeoTopNode(gGeoManager, top->FindNode("CALO_1")); calo->SetVisLevel(3); gEve->AddGlobalElement(calo); TEveGeoTopNode* muon = new TEveGeoTopNode(gGeoManager, top->FindNode("MUON_1")); muon->SetVisLevel(4); gEve->AddGlobalElement(muon); // --- Stereo --- TEveWindowSlot* slot = 0; slot = TEveWindow::CreateWindowInTab(gEve->GetBrowser()->GetTabRight()); TEveViewer* sv = new TEveViewer("Stereo GL", "Stereoscopic view"); sv->SpawnGLViewer(gEve->GetEditor(), kTRUE); sv->AddScene(gEve->GetGlobalScene()); slot->ReplaceWindow(sv); gEve->GetViewers()->AddElement(sv); gEve->GetBrowser()->GetTabRight()->SetTab(1); // --- Redraw --- gEve->FullRedraw3D(kTRUE); gEve->EditElement(sv); // --- Fix editor --- // EClipType not exported to CINT (see TGLUtil.h): // 0 - no clip, 1 - clip plane, 2 - clip box TGLViewer *v = gEve->GetDefaultGLViewer(); v->GetClipSet()->SetClipType(TGLClip::EType(1)); v->ColorSet().Background().SetColor(kMagenta+4); v->SetGuideState(TGLUtil::kAxesEdge, kTRUE, kFALSE, 0); v->RefreshPadEditor(v); v->CurrentCamera().RotateRad(-1.2, 0.5); v->DoDraw(); }
void std_camera_clip() { // EClipType not exported to CINT (see TGLUtil.h): // 0 - no clip, 1 - clip plane, 2 - clip box TGLViewer *v = gEve->GetDefaultGLViewer(); v->GetClipSet()->SetClipType((EClipType) 1); v->SetGuideState(TGLUtil::kAxesEdge, kTRUE, kFALSE, 0); v->RefreshPadEditor(v); v->CurrentCamera().RotateRad(-1.2, 0.5); v->DoDraw(); }