DD4hep  1.30.0
Detector Description Toolkit for High Energy Physics
ViewMenu.cpp
Go to the documentation of this file.
1 //==========================================================================
2 // AIDA Detector description implementation
3 //--------------------------------------------------------------------------
4 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
5 // All rights reserved.
6 //
7 // For the licensing terms see $DD4hepINSTALL/LICENSE.
8 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
9 //
10 // Author : M.Frank
11 //
12 //==========================================================================
13 
14 // Framework include files
15 #include <DD4hep/Plugins.h>
16 #include <DD4hep/Printout.h>
17 #include <DD4hep/InstanceCount.h>
18 
19 #include <DDEve/View.h>
20 #include <DDEve/ViewMenu.h>
21 #include <DDEve/PopupMenu.h>
22 
23 // ROOT include files
24 #include <TEveBrowser.h>
25 #include <TEveManager.h>
26 #include <TEveElement.h>
27 #include <TEveWindow.h>
28 #include <TEveViewer.h>
29 #include <TGLViewer.h>
30 #include <TGClient.h>
31 #include <TGTab.h>
32 
33 // Forward declarations
34 class TEveWindowSlot;
35 
36 using namespace dd4hep;
37 using pair_t = std::pair<std::string, std::string>;
38 
40 
41 ViewMenu::ViewMenu(Display* display, const std::string& title)
43 : PopupMenu(display->client().GetRoot()), m_display(display), m_title(title)
44 {
45  InstanceCount::increment(this);
46 }
47 
49 ViewMenu::~ViewMenu() {
51 }
52 
54 void ViewMenu::Build(TGMenuBar* menubar, int hints) {
55  pair_t* p = 0;
56  PopupMenu* view_menu = this;
57  view_menu->AddEntry("3&D View", this, &ViewMenu::CreateView, p=new pair_t("DD4hep_DDEve_View3D","3D"));
58  view_menu->AddEntry("Rho-&Z Projection", this, &ViewMenu::CreateView, p=new pair_t("DD4hep_DDEve_RhoZProjection","Rho-Z"));
59  view_menu->AddEntry("Rho-&Phi Projection",this, &ViewMenu::CreateView, p=new pair_t("DD4hep_DDEve_RhoPhiProjection","Rho-Phi"));
61  for(Display::ViewConfigurations::const_iterator i=vc.begin(); i!=vc.end(); ++i) {
62  const Display::ViewConfig& v = (*i).second;
63  view_menu->AddEntry(v.name.c_str(), this, &ViewMenu::CreateView,p=new pair_t("DD4hep_DDEve_"+v.type,v.name));
64  }
65  menubar->AddPopup(m_title.c_str(),*view_menu, new TGLayoutHints(hints, 0, 4, 0, 0));
66 }
67 
69 void ViewMenu::CreateView(TGMenuEntry*, void* ud) {
70  pair_t* args = (pair_t*)ud;
71  CreateView(args->first,args->second);
72 }
73 
74 View* ViewMenu::CreateView(const std::string& type, const std::string& title) {
75  pair_t args("DD4hep_DDEve_"+type,title);
76  View* v = PluginService::Create<View*>(type.c_str(),m_display,title.c_str());
77  BuildView(v);
78  return v;
79 }
80 
82 View* ViewMenu::CreateView3D(const std::string& title) {
83  return CreateView("DD4hep_DDEve_View3D",title.c_str());
84 }
85 
87 View* ViewMenu::CreateRhoZProjection(const std::string& title ) {
88  return CreateView("DD4hep_DDEve_RhoZProjection",title.c_str());
89 }
90 
92 View* ViewMenu::CreateRhoPhiProjection(const std::string& title ) {
93  return CreateView("DD4hep_DDEve_RhoPhiProjection",title.c_str());
94 }
95 
97 void ViewMenu::BuildView(View* v) const {
98  TEveManager& mgr = m_display->manager();
99  TEveBrowser *browser = mgr.GetBrowser();
100  TGTab *right = browser->GetTabRight();
101  TEveWindowSlot *slot = TEveWindow::CreateWindowInTab(right);
102  v->Build(slot);
106  v->Initialize();
107  right->SetTab(right->GetNumberOfTabs()-1);
108 }
ViewMenu.h
dd4hep::Display
The main class of the DDEve display.
Definition: Display.h:56
dd4hep::ViewMenu::m_title
std::string m_title
Menu title.
Definition: ViewMenu.h:43
ClassImp
ClassImp(ViewMenu) ViewMenu
Initializing constructor.
Definition: ViewMenu.cpp:39
dd4hep::ViewMenu::m_display
Display * m_display
Reference to display manager.
Definition: ViewMenu.h:41
v
View * v
Definition: MultiView.cpp:28
dd4hep::ViewMenu::Build
virtual void Build(TGMenuBar *menuBar, int hints=kLHintsNormal) override
Add the menu to the menu bar.
Definition: ViewMenu.cpp:54
dd4hep::ViewMenu::CreateView3D
View * CreateView3D(const std::string &title)
Specialization: Create a new 3D view.
Definition: ViewMenu.cpp:82
dd4hep::ViewMenu
class ViewMenu ViewMenu.h DDEve/ViewMenu.h
Definition: ViewMenu.h:36
dd4hep::View::Build
virtual View & Build(TEveWindow *slot)
Build the view view and map it to the given slot.
Definition: View.cpp:58
dd4hep::View::ConfigureGeometryFromInfo
virtual void ConfigureGeometryFromInfo()
Configure a view with geo info. Used configuration if present.
Definition: View.cpp:138
dd4hep::ViewMenu::CreateRhoZProjection
View * CreateRhoZProjection(const std::string &title)
Specialization: Create a new R-Z view.
Definition: ViewMenu.cpp:87
pair_t
std::pair< std::string, std::string > pair_t
Definition: ViewMenu.cpp:37
dd4hep::View::name
const std::string & name() const
Access to the view name/title.
Definition: View.h:81
dd4hep::ViewMenu::CreateRhoPhiProjection
View * CreateRhoPhiProjection(const std::string &title)
Specialization: Create a new R-Phi view.
Definition: ViewMenu.cpp:92
dd4hep::Display::ViewConfigurations
std::map< std::string, ViewConfig > ViewConfigurations
Definition: Display.h:64
dd4hep::ViewMenu::CreateView
void CreateView(TGMenuEntry *e, void *ud)
Menu callback: Create a generic view using the user data.
Definition: ViewMenu.cpp:69
dd4hep::Display::viewConfigurations
const ViewConfigurations & viewConfigurations() const
Access View configurations.
Definition: Display.h:133
slot
View TEveWindowSlot * slot
Definition: MultiView.cpp:28
dd4hep::InstanceCount::decrement
static void decrement(T *)
Decrement count according to type information.
Definition: InstanceCount.h:102
Plugins.h
dd4hep::View::ConfigureEventFromInfo
virtual void ConfigureEventFromInfo()
Configure a view with event info. Used configuration if present.
Definition: View.cpp:230
PopupMenu.h
dd4hep::PopupMenu::AddEntry
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:60
dd4hep::ViewMenu::BuildView
void BuildView(View *view) const
Import Geometry data and build the view.
Definition: ViewMenu.cpp:97
dd4hep::DisplayConfiguration::ViewConfig
View configuration.
Definition: DisplayConfiguration.h:119
dd4hep::PopupMenu
class PopupMenu PopupMenu.h DDEve/PopupMenu.h
Definition: PopupMenu.h:36
dd4hep::ViewMenu::ViewMenu
ViewMenu(Display *eve, const std::string &title)
Standard constructor.
dd4hep
Namespace for the AIDA detector description toolkit.
Definition: AlignmentsCalib.h:28
dd4hep::View::Initialize
virtual void Initialize()
Initialize the view port.
Definition: View.cpp:63
dd4hep::View
class View View.h DDEve/View.h
Definition: View.h:45
InstanceCount.h
View.h
dd4hep::Display::RegisterEvents
virtual void RegisterEvents(View *view)
Register to the main event scene on new events.
Definition: Display.cpp:259
Printout.h
dd4hep::Display::manager
TEveManager & manager() const
Access to the EVE manager.
Definition: Display.h:131