DD4hep - The AIDA detector description toolkit for high energy physics experiments
DD4hep  Rev:Unversioneddirectory
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ViewMenu.cpp
Go to the documentation of this file.
1 // $Id: $
2 //==========================================================================
3 // AIDA Detector description implementation for LCD
4 //--------------------------------------------------------------------------
5 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
6 // All rights reserved.
7 //
8 // For the licensing terms see $DD4hepINSTALL/LICENSE.
9 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
10 //
11 // Author : M.Frank
12 //
13 //==========================================================================
14 
15 // Framework include files
16 #include "DD4hep/Plugins.h"
17 #include "DD4hep/Printout.h"
18 #include "DD4hep/InstanceCount.h"
19 
20 #include "DDEve/View.h"
21 #include "DDEve/ViewMenu.h"
22 #include "DDEve/PopupMenu.h"
23 
24 // ROOT include files
25 #include "TEveBrowser.h"
26 #include "TEveManager.h"
27 #include "TEveElement.h"
28 #include "TEveWindow.h"
29 #include "TEveViewer.h"
30 #include "TGLViewer.h"
31 #include "TGClient.h"
32 #include "TGTab.h"
33 
34 // Forward declarations
35 class TEveWindowSlot;
36 
37 using namespace std;
38 using namespace DD4hep;
39 
41 
42 ViewMenu::ViewMenu(Display* display, const std::string& title)
44 : PopupMenu(display->client().GetRoot()), m_display(display), m_title(title)
45 {
46  InstanceCount::increment(this);
47 }
48 
50 ViewMenu::~ViewMenu() {
51  InstanceCount::decrement(this);
52 }
53 
55 void ViewMenu::Build(TGMenuBar* bar, int hints) {
56  pair<string,string>* p = 0;
57  PopupMenu* view_menu = this;
58  view_menu->AddEntry("3&D View", this, &ViewMenu::CreateView, p=new pair<string,string>("DD4hep_DDEve_View3D","3D"));
59  view_menu->AddEntry("Rho-&Z Projection", this, &ViewMenu::CreateView, p=new pair<string,string>("DD4hep_DDEve_RhoZProjection","Rho-Z"));
60  view_menu->AddEntry("Rho-&Phi Projection",this, &ViewMenu::CreateView, p=new pair<string,string>("DD4hep_DDEve_RhoPhiProjection","Rho-Phi"));
61  const Display::ViewConfigurations& vc = m_display->viewConfigurations();
62  for(Display::ViewConfigurations::const_iterator i=vc.begin(); i!=vc.end(); ++i) {
63  const Display::ViewConfig& v = (*i).second;
64  view_menu->AddEntry(v.name.c_str(), this, &ViewMenu::CreateView,p=new pair<string,string>("DD4hep_DDEve_"+v.type,v.name));
65  }
66  bar->AddPopup(m_title.c_str(),*view_menu, new TGLayoutHints(hints, 0, 4, 0, 0));
67 }
68 
70 void ViewMenu::CreateView(TGMenuEntry*, void* ud) {
71  pair<string,string>* args = (pair<string,string>*)ud;
72  CreateView(args->first,args->second);
73 }
74 
75 View* ViewMenu::CreateView(const std::string& type, const std::string& title) {
76  pair<string,string> args("DD4hep_DDEve_"+type,title);
77  View* v = PluginService::Create<View*>(type.c_str(),m_display,title.c_str());
78  BuildView(v);
79  return v;
80 }
81 
83 View* ViewMenu::CreateView3D(const std::string& title) {
84  return CreateView("DD4hep_DDEve_View3D",title.c_str());
85 }
86 
88 View* ViewMenu::CreateRhoZProjection(const std::string& title ) {
89  return CreateView("DD4hep_DDEve_RhoZProjection",title.c_str());
90 }
91 
93 View* ViewMenu::CreateRhoPhiProjection(const std::string& title ) {
94  return CreateView("DD4hep_DDEve_RhoPhiProjection",title.c_str());
95 }
96 
98 void ViewMenu::BuildView(View* v) const {
99  TEveManager& m = m_display->manager();
100  TEveBrowser *browser = m.GetBrowser();
101  TGTab *right = browser->GetTabRight();
102  TEveWindowSlot *slot = TEveWindow::CreateWindowInTab(right);
103  v->Build(slot);
104  m_display->RegisterEvents(v);
107  v->Initialize();
108  right->SetTab(right->GetNumberOfTabs()-1);
109 }
ClassImp(ViewMenu) ViewMenu
Initializing constructor.
Definition: ViewMenu.cpp:40
virtual void ConfigureEventFromInfo()
Configure a view with event info. Used configuration if present.
Definition: View.cpp:231
virtual void ConfigureGeometryFromInfo()
Configure a view with geo info. Used configuration if present.
Definition: View.cpp:140
View TEveWindowSlot * slot
Definition: MultiView.cpp:30
class View View.h DDEve/View.h
Definition: View.h:46
virtual int AddEntry(const char *name, Callback cb, void *ud=0, const TGPicture *p=0, TGMenuEntry *before=0)
Add a new popup menu entry with a callback.
Definition: PopupMenu.cpp:61
std::map< std::string, ViewConfig > ViewConfigurations
Definition: Display.h:65
class PopupMenu PopupMenu.h DDEve/PopupMenu.h
Definition: PopupMenu.h:37
virtual View & Build(TEveWindow *slot)
Build the view view and map it to the given slot.
Definition: View.cpp:60
virtual void Initialize()
Initialize the view port.
Definition: View.cpp:65
static const double bar
Definition: DD4hepUnits.h:180
View * v
Definition: MultiView.cpp:30
class ViewMenu ViewMenu.h DDEve/ViewMenu.h
Definition: ViewMenu.h:37
The main class of the DDEve display.
Definition: Display.h:57
TGeoShape TGeoMedium * m
Definition: Volumes.cpp:294