27 #include "TEveBrowser.h"
28 #include "TEveManager.h"
29 #include "TEveElement.h"
30 #include "TEveWindow.h"
31 #include "TEveViewer.h"
32 #include "TGLViewer.h"
40 using namespace DD4hep;
46 :
PopupMenu(display->client().GetRoot()), m_display(display), m_evtCtrl(0)
48 InstanceCount::increment(
this);
52 DD4hepMenu::~DD4hepMenu() {
54 InstanceCount::decrement(
this);
58 void DD4hepMenu::Build(TGMenuBar*
bar,
int hints) {
61 m.
AddEntry(
"&Load XML",
this, &DD4hepMenu::OnLoadXML);
63 id = m.
AddEntry(
"&Show Event I/O",
this, &DD4hepMenu::OnCreateEventIO);
64 m.
menu().DisableEntry(
id);
65 id = m.
AddEntry(
"&Open Event Data",
this, &DD4hepMenu::OnOpenEventData);
66 m.
menu().DisableEntry(
id);
67 id = m.
AddEntry(
"&Next Event",
this, &DD4hepMenu::OnNextEvent);
68 m.
menu().DisableEntry(
id);
69 id = m.
AddEntry(
"&Previous Event",
this, &DD4hepMenu::OnPreviousEvent);
70 m.
menu().DisableEntry(
id);
71 m.
AddEntry(
"&Exit",
this, &DD4hepMenu::OnExit);
72 bar->AddPopup(
"&DD4hep",*
this,
new TGLayoutHints(hints, 0, 4, 0, 0));
76 void DD4hepMenu::OnGeometryLoaded() {
77 TGPopupMenu&
m = menu();
78 m.DisableEntry(m.GetEntry(
"Load XML")->GetEntryId());
79 m.EnableEntry(m.GetEntry(
"Show Event I/O")->GetEntryId());
80 m.EnableEntry(m.GetEntry(
"Open Event Data")->GetEntryId());
81 m.DisableEntry(m.GetEntry(
"Next Event")->GetEntryId());
82 m.DisableEntry(m.GetEntry(
"Previous Event")->GetEntryId());
86 void DD4hepMenu::OnLoadXML(TGMenuEntry* ,
void* ) {
87 std::string fname = m_display->OpenXmlFileDialog(
".");
88 if ( !fname.empty() ) {
89 m_display->LoadXML(fname.c_str());
95 void DD4hepMenu::OnLoadRootGeometry(TGMenuEntry* ,
void* ) {
96 std::string fname = m_display->OpenEventFileDialog(
".");
97 if ( !fname.empty() ) {
98 m_display->LoadGeometryRoot(fname.c_str());
103 void DD4hepMenu::OnCreateEventIO(TGMenuEntry* ,
void* ) {
104 if ( 0 == m_evtCtrl ) {
105 TEveBrowser* browser = m_display->manager().GetBrowser();
106 browser->StartEmbedding(TRootBrowser::kLeft);
109 browser->SetTabTitle(
"Evt I/O", 0);
110 browser->StopEmbedding();
111 menu().DisableEntry(menu().GetEntry(
"Show Event I/O")->GetEntryId());
116 void DD4hepMenu::OnOpenEventData(TGMenuEntry* ,
void* ) {
117 if ( 0 == m_evtCtrl ) {
118 OnCreateEventIO(0,0);
120 if ( m_evtCtrl->Open() ) {
121 TGPopupMenu&
m = menu();
122 m.EnableEntry(m.GetEntry(
"Open Event Data")->GetEntryId());
123 m.EnableEntry(m.GetEntry(
"Next Event")->GetEntryId());
124 m.EnableEntry(m.GetEntry(
"Previous Event")->GetEntryId());
129 void DD4hepMenu::OnNextEvent(TGMenuEntry* ,
void* ) {
130 m_display->eventHandler().NextEvent();
134 void DD4hepMenu::OnPreviousEvent(TGMenuEntry* ,
void* ) {
135 m_display->eventHandler().PreviousEvent();
139 void DD4hepMenu::OnExit(TGMenuEntry* ,
void* ) {
141 printout(
INFO,
"DDEve",
"+++ The life of this display instance ended.... good bye!");
142 gSystem->Exit(0,kTRUE);
void deletePtr(T *&p)
Helper to delete objects from heap and reset the pointer. Saves many many lines of code...
int printout(PrintLevel severity, const char *src, const char *fmt,...)
Calls the display action with a given severity level.
The main class of the DDEve display.