12 #include <TGeoManager.h> 14 #include <TGeoVolume.h> 15 #include <TEveGeoShape.h> 16 #include <TEveGeoNode.h> 17 #include <TEveManager.h> 26 TEveGeoShape* GeometryClone(TGeoVolume* currVolume) {
28 TGeoShape* currShape = currVolume->GetShape();
29 TEveGeoShape *fakeShape =
new TEveGeoShape(currShape->GetName());
31 TGeoMatrix* currMat = gGeoManager->GetCurrentMatrix();
32 TGeoMatrix* mat = currMat->MakeClone();
33 fakeShape->SetTransMatrix(*mat);
40 TGeoManager* saveGeom = gGeoManager;
41 gGeoManager = fakeShape->GetGeoMangeur();
42 TGeoShape* clonedShape
43 =
dynamic_cast<TGeoShape*
> (currShape->Clone(
"fakeShape"));
44 fakeShape->SetShape(clonedShape);
45 gGeoManager = saveGeom;
51 std::vector<std::string> fVolumesToShow;
52 TEveElementList* fEveList;
53 PickVolumes(TEveElementList* eveList) : fEveList(eveList) {}
55 if (!fEveList)
return true;
56 TGeoNode* node = gGeoManager->GetCurrentNode();
59 v != fVolumesToShow.end(); ++v) {
60 if (
name.
find(*v) == std::string::npos)
continue;
61 std::cout <<
"Show volume " << node->GetName() <<
std::endl;
62 TEveGeoShape *shape = GeometryClone(node->GetVolume());
63 shape->SetMainColor(node->GetVolume()->GetLineColor());
64 shape->SetMainTransparency(90);
65 fEveList->AddElement(shape);
80 button->Connect(
"Clicked()",
81 "EDep::TEventChangeManager",
88 button->Connect(
"Clicked()",
89 "EDep::TEventChangeManager",
96 button->Connect(
"Clicked()",
97 "EDep::TEventChangeManager",
102 ClearVolumesToShow();
109 std::cout <<
"Invalid event source" <<
std::endl;
112 fEventSource = source;
113 gEDepSimTree = (TTree*) fEventSource->Get(
"EDepSimEvents");
115 std::cout <<
"Missing the event tree" <<
std::endl;
122 fEventSource->Get(
"EDepSimGeometry");
124 if (GetShowGeometry() && !fVolumesToShow.empty()) {
125 TEveElementList*
simple =
new TEveElementList(
"simplifiedGeometry");
126 PickVolumes visitor(simple);
127 visitor.fVolumesToShow.clear();
128 visitor.fVolumesToShow.reserve(fVolumesToShow.size());
129 std::copy(fVolumesToShow.begin(), fVolumesToShow.end(),
130 std::back_inserter(visitor.fVolumesToShow));
132 gEve->AddGlobalElement(simple);
141 fNewEventHandlers.push_back(handler);
146 fUpdateHandlers.push_back(handler);
150 std::cout <<
"Change Event by " << change <<
" entries" <<
std::endl;
151 if (!GetEventSource()) {
152 std::cout <<
"Event source is not available" <<
std::endl;
163 if (change != 0) NewEvent();
175 h != fNewEventHandlers.end(); ++
h) {
184 std::cout <<
"Invalid event" <<
std::endl;;
190 h != fUpdateHandlers.end(); ++
h) {
195 gEve->Redraw3D(kTRUE);
EDep::TGUIManager & GUI()
Return a reference to the gui manager.
void SetEventSource(TFile *source)
void AddNewEventHandler(EDep::TVEventChangeHandler *handler)
int find(char c, int index=0, bool cs=TRUE) const
void ChangeEvent(int change=1)
TGButton * GetNextEventButton()
Get the next event button widget.
TTree * gEDepSimTree
The tree containing the event.
static TEventDisplay & Get(void)
TGButton * GetPrevEventButton()
Get the previous event button widget.
TG4Event * gEDepSimEvent
The event being displayed.
ClassImp(EDep::TEventChangeManager) namespace
virtual ~TEventChangeManager()
static msg_handler handler
virtual bool Action(int depth)
TGButton * GetDrawEventButton()
Get the redraw current event button widget.
QTextStream & endl(QTextStream &s)
void AddUpdateHandler(EDep::TVEventChangeHandler *handler)