Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:15:00

0001 //==========================================================================
0002 //  AIDA Detector description implementation 
0003 //--------------------------------------------------------------------------
0004 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
0005 // All rights reserved.
0006 //
0007 // For the licensing terms see $DD4hepINSTALL/LICENSE.
0008 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
0009 //
0010 //==========================================================================
0011 
0012 #ifndef UTILITYAPPS_SRC_MULTIVIEW_H
0013 #define UTILITYAPPS_SRC_MULTIVIEW_H
0014 
0015 #include <TEveManager.h>
0016 #include <TEveViewer.h>
0017 #include <TGLViewer.h>
0018 
0019 #include <TEveScene.h>
0020 
0021 #include <TEveProjectionManager.h>
0022 #include <TEveProjectionAxes.h>
0023 
0024 #include <TEveBrowser.h>
0025 #include <TEveWindow.h>
0026 
0027 /** Multi-view (3d, rphi, rhoz) service class using EVE Window Manager.
0028  * Author: Matevz Tadel 2009
0029  * MultiView
0030  *
0031  * Structure encapsulating standard views: 3D, r-phi and rho-z.
0032  * Includes scenes and projection managers.
0033  *
0034  * Should be used in compiled mode.
0035  * 
0036  * @author F.Gaede, DESY (modified original version from Matevz Tadel)
0037  * @version "$Id: $"
0038  */
0039 
0040 class MultiView {
0041 public:
0042 
0043   TEveProjectionManager *fRPhiMgr;
0044   TEveProjectionManager *fRhoZMgr;
0045 
0046   TEveViewer            *f3DView;
0047   TEveViewer            *fRPhiView;
0048   TEveViewer            *fRhoZView;
0049 
0050   TEveScene             *fRPhiGeomScene;
0051   TEveScene             *fRhoZGeomScene;
0052   TEveScene             *fRPhiEventScene;
0053   TEveScene             *fRhoZEventScene;
0054 
0055   //---------------------------------------------------------------------------
0056 
0057   static MultiView* instance() {
0058     static MultiView mw ;
0059     return &mw ;
0060   }
0061 
0062   MultiView() {
0063 
0064     // Constructor --- creates required scenes, projection managers
0065     // and GL viewers.
0066 
0067     // Scenes
0068     //========
0069 
0070     fRPhiGeomScene  = gEve->SpawnNewScene("RPhi Geometry",
0071                                           "Scene holding projected geometry for the RPhi view.");
0072     fRhoZGeomScene  = gEve->SpawnNewScene("RhoZ Geometry",
0073                                           "Scene holding projected geometry for the RhoZ view.");
0074     fRPhiEventScene = gEve->SpawnNewScene("RPhi Event Data",
0075                                           "Scene holding projected event-data for the RPhi view.");
0076     fRhoZEventScene = gEve->SpawnNewScene("RhoZ Event Data",
0077                                           "Scene holding projected event-data for the RhoZ view.");
0078 
0079 
0080     // Projection managers
0081     //=====================
0082 
0083     fRPhiMgr = new TEveProjectionManager(TEveProjection::kPT_RPhi);
0084     gEve->AddToListTree(fRPhiMgr, kFALSE);
0085     {
0086       TEveProjectionAxes* a = new TEveProjectionAxes(fRPhiMgr);
0087       a->SetMainColor(kWhite);
0088       a->SetTitle("R-Phi");
0089       a->SetTitleSize(0.05);
0090       a->SetTitleFont(102);
0091       a->SetLabelSize(0.025);
0092       a->SetLabelFont(102);
0093       fRPhiGeomScene->AddElement(a);
0094     }
0095 
0096     fRhoZMgr = new TEveProjectionManager(TEveProjection::kPT_RhoZ);
0097     gEve->AddToListTree(fRhoZMgr, kFALSE);
0098     {
0099       TEveProjectionAxes* a = new TEveProjectionAxes(fRhoZMgr);
0100       a->SetMainColor(kWhite);
0101       a->SetTitle("Rho-Z");
0102       a->SetTitleSize(0.05);
0103       a->SetTitleFont(102);
0104       a->SetLabelSize(0.025);
0105       a->SetLabelFont(102);
0106       fRhoZGeomScene->AddElement(a);
0107     }
0108 
0109 
0110     // Viewers
0111     //=========
0112 
0113     TEveWindowSlot *slot = 0;
0114     TEveWindowPack *pack = 0;
0115 
0116     slot = TEveWindow::CreateWindowInTab(gEve->GetBrowser()->GetTabRight());
0117     pack = slot->MakePack();
0118     pack->SetElementName("Multi View");
0119     pack->SetHorizontal();
0120     pack->SetShowTitleBar(kFALSE);
0121     pack->NewSlot()->MakeCurrent();
0122     f3DView = gEve->SpawnNewViewer("3D View", "");
0123     f3DView->AddScene(gEve->GetGlobalScene());
0124     f3DView->AddScene(gEve->GetEventScene());
0125 
0126     pack = pack->NewSlot()->MakePack();
0127     pack->SetShowTitleBar(kFALSE);
0128     pack->NewSlot()->MakeCurrent();
0129     fRPhiView = gEve->SpawnNewViewer("RPhi View", "");
0130     fRPhiView->GetGLViewer()->SetCurrentCamera(TGLViewer::kCameraOrthoXOY);
0131     fRPhiView->AddScene(fRPhiGeomScene);
0132     fRPhiView->AddScene(fRPhiEventScene);
0133 
0134     pack->NewSlot()->MakeCurrent();
0135     fRhoZView = gEve->SpawnNewViewer("RhoZ View", "");
0136     fRhoZView->GetGLViewer()->SetCurrentCamera(TGLViewer::kCameraOrthoXOY);
0137     fRhoZView->AddScene(fRhoZGeomScene);
0138     fRhoZView->AddScene(fRhoZEventScene);
0139  
0140 
0141     //fg: set white background:
0142     f3DView->GetGLViewer()->ColorSet().Background().SetColor(kWhite);
0143     fRPhiView->GetGLViewer()->ColorSet().Background().SetColor(kWhite);
0144     fRhoZView->GetGLViewer()->ColorSet().Background().SetColor(kWhite);
0145   }
0146 
0147   //---------------------------------------------------------------------------
0148 
0149   void SetDepth(Float_t d)
0150   {
0151     // Set current depth on all projection managers.
0152 
0153     fRPhiMgr->SetCurrentDepth(d);
0154     fRhoZMgr->SetCurrentDepth(d);
0155   }
0156 
0157   //---------------------------------------------------------------------------
0158 
0159   void ImportGeomRPhi(TEveElement* el)
0160   { 
0161     fRPhiMgr->ImportElements(el, fRPhiGeomScene);
0162   }
0163 
0164   void ImportGeomRhoZ(TEveElement* el)
0165   { 
0166     fRhoZMgr->ImportElements(el, fRhoZGeomScene);
0167   }
0168 
0169   void ImportEventRPhi(TEveElement* el)
0170   { 
0171     fRPhiMgr->ImportElements(el, fRPhiEventScene);
0172   }
0173 
0174   void ImportEventRhoZ(TEveElement* el)
0175   { 
0176     fRhoZMgr->ImportElements(el, fRhoZEventScene);
0177   }
0178 
0179 
0180   void ImportEvent(TEveElement* el)
0181   { 
0182     gEve->AddElement( el ) ;
0183     fRPhiMgr->ImportElements(el, fRPhiEventScene);
0184     fRhoZMgr->ImportElements(el, fRhoZEventScene);
0185   }
0186 
0187   //---------------------------------------------------------------------------
0188 
0189   void DestroyEventRPhi()
0190   {
0191     fRPhiEventScene->DestroyElements();
0192   }
0193 
0194   void DestroyEventRhoZ()
0195   {
0196     fRhoZEventScene->DestroyElements();
0197   }
0198 
0199 private:
0200   MultiView(const MultiView& /* x */)
0201     : fRPhiMgr(0), fRhoZMgr(0), f3DView(0), fRPhiView(0), fRhoZView(0),
0202       fRPhiGeomScene(0), fRhoZGeomScene(0), fRPhiEventScene(0), fRhoZEventScene(0)  
0203   {
0204   }
0205   MultiView& operator=(const MultiView& /* x */)  {
0206     fRPhiMgr = 0;
0207     fRhoZMgr = 0;
0208     f3DView = 0;
0209     fRPhiView = 0;
0210     fRhoZView = 0;
0211     fRPhiGeomScene = 0;
0212     fRhoZGeomScene = 0;
0213     fRPhiEventScene = 0;
0214     fRhoZEventScene = 0;
0215     return *this;
0216   }
0217 };
0218 
0219 //=====================================================================================
0220 
0221 
0222 
0223 #endif
0224 
0225