File indexing completed on 2025-01-30 09:17:18
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #include <DD4hep/Plugins.h>
0016 #include <DD4hep/Printout.h>
0017 #include <DD4hep/InstanceCount.h>
0018
0019 #include <DDEve/View.h>
0020 #include <DDEve/ViewMenu.h>
0021 #include <DDEve/PopupMenu.h>
0022
0023
0024 #include <TEveBrowser.h>
0025 #include <TEveManager.h>
0026 #include <TEveElement.h>
0027 #include <TEveWindow.h>
0028 #include <TEveViewer.h>
0029 #include <TGLViewer.h>
0030 #include <TGClient.h>
0031 #include <TGTab.h>
0032
0033
0034 class TEveWindowSlot;
0035
0036 using namespace dd4hep;
0037 using pair_t = std::pair<std::string, std::string>;
0038
0039 ClassImp(ViewMenu)
0040
0041
0042 ViewMenu::ViewMenu(Display* display, const std::string& title)
0043 : PopupMenu(display->client().GetRoot()), m_display(display), m_title(title)
0044 {
0045 InstanceCount::increment(this);
0046 }
0047
0048
0049 ViewMenu::~ViewMenu() {
0050 InstanceCount::decrement(this);
0051 }
0052
0053
0054 void ViewMenu::Build(TGMenuBar* menubar, int hints) {
0055 pair_t* p = 0;
0056 PopupMenu* view_menu = this;
0057 view_menu->AddEntry("3&D View", this, &ViewMenu::CreateView, p=new pair_t("DD4hep_DDEve_View3D","3D"));
0058 view_menu->AddEntry("Rho-&Z Projection", this, &ViewMenu::CreateView, p=new pair_t("DD4hep_DDEve_RhoZProjection","Rho-Z"));
0059 view_menu->AddEntry("Rho-&Phi Projection",this, &ViewMenu::CreateView, p=new pair_t("DD4hep_DDEve_RhoPhiProjection","Rho-Phi"));
0060 const Display::ViewConfigurations& vc = m_display->viewConfigurations();
0061 for(Display::ViewConfigurations::const_iterator i=vc.begin(); i!=vc.end(); ++i) {
0062 const Display::ViewConfig& v = (*i).second;
0063 view_menu->AddEntry(v.name.c_str(), this, &ViewMenu::CreateView,p=new pair_t("DD4hep_DDEve_"+v.type,v.name));
0064 }
0065 menubar->AddPopup(m_title.c_str(),*view_menu, new TGLayoutHints(hints, 0, 4, 0, 0));
0066 }
0067
0068
0069 void ViewMenu::CreateView(TGMenuEntry*, void* ud) {
0070 pair_t* args = (pair_t*)ud;
0071 CreateView(args->first,args->second);
0072 }
0073
0074 View* ViewMenu::CreateView(const std::string& type, const std::string& title) {
0075 pair_t args("DD4hep_DDEve_"+type,title);
0076 View* v = PluginService::Create<View*>(type.c_str(),m_display,title.c_str());
0077 BuildView(v);
0078 return v;
0079 }
0080
0081
0082 View* ViewMenu::CreateView3D(const std::string& title) {
0083 return CreateView("DD4hep_DDEve_View3D",title.c_str());
0084 }
0085
0086
0087 View* ViewMenu::CreateRhoZProjection(const std::string& title ) {
0088 return CreateView("DD4hep_DDEve_RhoZProjection",title.c_str());
0089 }
0090
0091
0092 View* ViewMenu::CreateRhoPhiProjection(const std::string& title ) {
0093 return CreateView("DD4hep_DDEve_RhoPhiProjection",title.c_str());
0094 }
0095
0096
0097 void ViewMenu::BuildView(View* v) const {
0098 TEveManager& mgr = m_display->manager();
0099 TEveBrowser *browser = mgr.GetBrowser();
0100 TGTab *right = browser->GetTabRight();
0101 TEveWindowSlot *slot = TEveWindow::CreateWindowInTab(right);
0102 v->Build(slot);
0103 m_display->RegisterEvents(v);
0104 v->ConfigureGeometryFromInfo();
0105 v->ConfigureEventFromInfo();
0106 v->Initialize();
0107 right->SetTab(right->GetNumberOfTabs()-1);
0108 }