28 #include <TGFileDialog.h>
40 m_display(display), m_dataGroup(0), m_dataFrame(0), m_eventGroup(0),
41 m_numEvtFrame(0), m_input1(0), m_input2(0), m_numEvtLabel(0),
42 m_open(0), m_prev(0), m_next(0), m_goto(0)
44 SetWindowName(
"XX GUI");
45 m_display->eventHandler().Subscribe(
this);
46 InstanceCount::increment(
this);
50 EventControl::~EventControl() {
61 return new TGVerticalFrame(
this);
83 if ( !fname.empty() ) {
91 char text[1024], fname[1024];
92 ::strncpy(fname, handler.
datasourceName().c_str(),
sizeof(fname)-1);
93 fname[
sizeof(fname)-1] = 0;
96 ::snprintf(text,
sizeof(text),
"Number of events: %ld",handler.
numEvents());
97 m_input1->SetText(::basename(fname));
101 ::snprintf(text,
sizeof(text),
"Currently NO input defined");
112 typedef std::vector<EventHandler::Collection> Collections;
113 const Types& types = handler.
data();
115 m_lines[0].second.first->SetText(
"Hit collection name");
116 m_lines[0].second.second->SetText(
"No.Hits");
117 for(
const auto& t : types) {
118 const Collections& colls = t.second;
120 std::string cl = t.first;
121 std::size_t idx = cl.rfind(
"Geant4");
122 if ( idx != std::string::npos ) {
124 cl = cl.substr(0,cl.find(
'*'));
126 else if ( (idx=cl.rfind(
"::")) != std::string::npos ) {
127 cl = cl.substr(idx+2);
128 if ( (idx=cl.rfind(
'*')) != std::string::npos ) cl = cl.substr(0,idx);
129 if ( (idx=cl.rfind(
'>')) != std::string::npos ) cl = cl.substr(0,idx);
131 line.second.first->SetTextColor(kRed);
132 line.second.second->SetTextColor(kRed);
133 line.second.first->SetText((
"Coll.Type: "+cl).c_str());
134 line.second.second->SetText(
"");
135 for(
const auto& c : colls) {
137 ::snprintf(text,
sizeof(text),
"%ld",
long(c.second));
139 line.second.first->SetText(c.first);
140 line.second.second->SetText(text);
141 line.second.first->SetTextColor(kBlack);
142 line.second.second->SetTextColor(kBlack);
147 line.second.first->SetText(
"");
148 line.second.second->SetText(
"");
156 std::string icondir = TString::Format(
"%s/", TROOT::GetIconPath().Data()).Data();
157 TGGroupFrame* group =
new TGGroupFrame(
m_frame,
"Event I/O Control");
158 TGCompositeFrame* top =
new TGHorizontalFrame(group);
159 TGPictureButton* b = 0;
162 group->SetTitlePos(TGGroupFrame::kLeft);
163 m_frame->AddFrame(group,
new TGLayoutHints(kLHintsExpandX|kLHintsCenterX, 2, 2, 2, 2));
173 ::snprintf(text,
sizeof(text),
"Currently NO input defined");
179 group->AddFrame(
m_numEvtFrame,
new TGLayoutHints(kLHintsExpandX|kLHintsCenterX, 2, 2, 2, 2));
181 top->AddFrame(
new TGLabel(top,
"Open event file:"),
new TGLayoutHints(kLHintsLeft|kLHintsCenterY, 2, 2, 2, 2));
183 b->Connect(
"Clicked()",
"dd4hep::EventControl",
this,
"Open()");
184 b->SetSize(TGDimension(32,32));
185 top->AddFrame(b,
new TGLayoutHints(kLHintsRight, 2, 2, 2, 2));
186 group->AddFrame(top,
new TGLayoutHints(kLHintsExpandX|kLHintsCenterX, 2, 2, 2, 2));
188 top =
new TGHorizontalFrame(group);
189 top->AddFrame(
new TGLabel(top,
"Previous:"),
new TGLayoutHints(kLHintsLeft|kLHintsCenterY, 2, 2, 2, 2));
191 b->Connect(
"Clicked()",
"dd4hep::EventControl",
this,
"PreviousEvent()");
192 b->SetSize(TGDimension(32,32));
193 top->AddFrame(b,
new TGLayoutHints(kLHintsLeft, 2, 2, 2, 2));
195 top->AddFrame(
new TGLabel(top,
""),
new TGLayoutHints(kLHintsExpandX|kLHintsCenterY, 2, 2, 2, 2));
196 top->AddFrame(
new TGLabel(top,
"Next:"),
new TGLayoutHints(kLHintsLeft|kLHintsCenterY, 2, 2, 2, 2));
198 b->Connect(
"Clicked()",
"dd4hep::EventControl",
this,
"NextEvent()");
199 b->SetSize(TGDimension(32,32));
200 top->AddFrame(b,
new TGLayoutHints(kLHintsRight, 2, 2, 2, 2));
201 group->AddFrame(top,
new TGLayoutHints(kLHintsExpandX|kLHintsCenterX, 2, 2, 2, 2));
203 top =
new TGHorizontalFrame(group);
204 top->AddFrame(
new TGLabel(top,
"Goto event:"),
new TGLayoutHints(kLHintsLeft|kLHintsCenterY, 2, 2, 2, 2));
206 b->Connect(
"Clicked()",
"dd4hep::EventControl",
this,
"GotoEvent()");
207 b->SetSize(TGDimension(32,32));
208 top->AddFrame(b,
new TGLayoutHints(kLHintsRight, 2, 2, 2, 2));
209 group->AddFrame(top,
new TGLayoutHints(kLHintsExpandX|kLHintsCenterX, 2, 2, 2, 2));
211 group =
new TGGroupFrame(
m_frame,
"Event data",200);
212 m_frame->AddFrame(group,
new TGLayoutHints(kLHintsLeft|kLHintsExpandX|kLHintsExpandY, 0, 0, 2, 2));
216 TGCompositeFrame* fr =
new TGHorizontalFrame(
m_dataFrame);
217 fr->AddFrame(line.second.first=
new TGLabel(fr,
""),
new TGLayoutHints(kLHintsNormal, 2, 0, 2, 2));
218 fr->AddFrame(line.second.second=
new TGLabel(fr,
""),
new TGLayoutHints(kLHintsRight, 20, 1, 2, 2));
221 m_dataFrame->AddFrame(fr,
new TGLayoutHints(kLHintsExpandX));
223 group->AddFrame(
m_dataFrame,
new TGLayoutHints(kLHintsNormal|kLHintsExpandX|kLHintsExpandY));