DD4hep  1.30.0
Detector Description Toolkit for High Energy Physics
Display.h
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 #ifndef DDEVE_DISPLAY_H
14 #define DDEVE_DISPLAY_H
15 
16 // Framework include files
17 #include "DD4hep/Detector.h"
18 #include "DD4hep/Printout.h"
19 #include "DDEve/PopupMenu.h"
20 #include "DDEve/EventHandler.h"
22 
23 // C/C++ include files
24 #include <set>
25 
26 // Forward declarations
27 class TEveCalo3D;
28 class TEveCaloDataHist;
29 class TEveElementList;
30 class TEveManager;
31 class TEveElement;
32 class TEveCaloViz;
33 class TGMenuBar;
34 class TGClient;
35 class TFile;
36 
38 namespace dd4hep {
39 
40  // Forward declarations
41  class View;
42  class ViewMenu;
43  class DD4hepMenu;
44  class EventHandler;
45  class ViewConfiguration;
46  class CalodataConfiguration;
47  class GenericEventHandler;
48  class DisplayConfiguration;
49 
51  /*
52  * \author M.Frank
53  * \version 1.0
54  * \ingroup DD4HEP_EVE
55  */
56  class Display : public EventConsumer {
57  public:
60  typedef std::set<View*> Views;
61  typedef std::set<DisplayConfiguration*> Configurations;
62  typedef std::set<PopupMenu*> Menus;
63  typedef std::map<std::string, TEveElementList*> Topics;
64  typedef std::map<std::string, ViewConfig> ViewConfigurations;
65  typedef std::map<std::string, DataConfig> DataConfigurations;
66 
68  struct CalodataContext {
69  int slice = 0;
70  TEveCalo3D* calo3D = 0;
71  TEveCaloViz* caloViz = 0;
72  TEveCaloDataHist* eveHist = 0;
75  CalodataContext() = default;
77  CalodataContext(const CalodataContext& c) = default;
80  };
81 
82  typedef std::map<std::string, CalodataContext> Calodata;
83 
84  protected:
86  TEveManager* m_eve = 0;
120  std::string m_eventHandlerName;
121 
122  public:
124  Display(TEveManager* eve);
126  virtual ~Display();
127 
129  Detector& detectorDescription() const;
131  TEveManager& manager() const { return *m_eve; }
135  void setVisLevel(int new_level) { m_visLevel = new_level; }
137  void setLoadLevel(int new_level) { m_loadLevel = new_level; }
139  std::string getEventHandlerName() { return m_eventHandlerName; }
141  void setEventHandlerName(const std::string& nam) { m_eventHandlerName = nam; }
142 
144  TGClient& client() const;
145 
147  void ChooseGeometry();
149  void LoadXML(const char* xmlFile);
151  void LoadGeometryRoot(const char* rootFile);
153  TFile* Open(const char* rootFile) const;
154 
157 
159  void MessageBox(PrintLevel level, const std::string& text, const std::string& title="") const;
160 
162  std::string OpenXmlFileDialog(const std::string& default_dir) const;
163 
165  std::string OpenEventFileDialog(const std::string& default_dir) const;
166 
168  void LoadGeoChildren(TEveElement* start, int levels, bool redraw);
170  void MakeNodesVisible(TEveElement* e, bool visible, int level);
171 
173  void ImportConfiguration(const DisplayConfiguration& config);
174 
176  const ViewConfig* GetViewConfiguration(const std::string& name) const;
178  const DataConfig* GetCalodataConfiguration(const std::string& name) const;
180  CalodataContext& GetCaloHistogram(const std::string& name);
181 
183  virtual void RegisterEvents(View* view);
185  virtual void UnregisterEvents(View* view);
186 
190  virtual TEveElementList& GetGeoTopic(const std::string& name);
192  virtual TEveElementList& GetGeoTopic(const std::string& name) const;
193 
195  void ImportGeo(TEveElement* el);
197  void ImportGeo(const std::string& topic, TEveElement* el);
198 
200  virtual TEveElementList& GetEveTopic(const std::string& name);
202  virtual TEveElementList& GetEveTopic(const std::string& name) const;
203 
205  void ImportEvent(TEveElement* el);
207  void ImportEvent(const std::string& topic, TEveElement* el);
208 
210  virtual void OnFileOpen(EventHandler& handler) override;
212  virtual void OnNewEvent(EventHandler& handler) override;
213 
215  virtual void BuildMenus(TGMenuBar* menuBar=0);
217  virtual void AddMenu(TGMenuBar* menuBar, PopupMenu* menu, int hints=kLHintsNormal);
218 
220  };
221 } /* End namespace dd4hep */
222 #endif // DDEVE_DISPLAY_H
223 
dd4hep::Display::GetCalodataConfiguration
const DataConfig * GetCalodataConfiguration(const std::string &name) const
Access a data filter by name. Data filters are used to customize views.
Definition: Display.cpp:253
dd4hep::Display::MakeNodesVisible
void MakeNodesVisible(TEveElement *e, bool visible, int level)
Make a set of nodes starting from a top element (in-)visible with a given depth.
Definition: Display.cpp:591
dd4hep::Display
The main class of the DDEve display.
Definition: Display.h:56
dd4hep::Display::MessageBox
void MessageBox(PrintLevel level, const std::string &text, const std::string &title="") const
Open standard message box.
Definition: Display.cpp:272
dd4hep::GenericEventHandler
Event handler base class. Interface to all DDEve I/O actions.
Definition: GenericEventHandler.h:30
dd4hep::Display::getEventHandlerName
std::string getEventHandlerName()
Get Event Handler Plugin name.
Definition: Display.h:139
dd4hep::Display::m_eveTopics
Topics m_eveTopics
Event data topics.
Definition: Display.h:102
dd4hep::Display::m_viewConfigs
ViewConfigurations m_viewConfigs
Container with view configurations.
Definition: Display.h:108
dd4hep::Display::CalodataContext::calo3D
TEveCalo3D * calo3D
Definition: Display.h:70
dd4hep::Display::m_menus
Menus m_menus
Container with top level menues.
Definition: Display.h:106
Detector.h
dd4hep::EventHandler
Event handler base class: Interface to all DDEve I/O actions.
Definition: EventHandler.h:67
dd4hep::Display::ImportGeo
void ImportGeo(TEveElement *el)
Call to import geometry elements.
Definition: Display.cpp:507
DisplayConfiguration.h
dd4hep::Display::m_viewMenu
ViewMenu * m_viewMenu
Reference to the view menu.
Definition: Display.h:96
dd4hep::Display::ClassDefOverride
ClassDefOverride(Display, 0)
dd4hep::Display::GetGeoTopic
virtual TEveElementList & GetGeoTopic(const std::string &name)
Access/Create an geometry topic by name.
Definition: Display.cpp:465
dd4hep::Display::OpenEventFileDialog
std::string OpenEventFileDialog(const std::string &default_dir) const
Popup ROOT file chooser. returns chosen file name; empty on cancel.
Definition: Display.cpp:313
dd4hep::Display::LoadGeoChildren
void LoadGeoChildren(TEveElement *start, int levels, bool redraw)
Load 'levels' Children into the geometry scene.
Definition: Display.cpp:527
dd4hep::Display::setLoadLevel
void setLoadLevel(int new_level)
Set Eve Geometry load level in manager (either from XML or BEFORE XML file was loaded)
Definition: Display.h:137
dd4hep::Display::DataConfigurations
std::map< std::string, DataConfig > DataConfigurations
Definition: Display.h:65
dd4hep::Display::m_visLevel
int m_visLevel
TGeoManager visualisation level.
Definition: Display.h:116
dd4hep::ViewMenu
class ViewMenu ViewMenu.h DDEve/ViewMenu.h
Definition: ViewMenu.h:36
dd4hep::Display::m_calodataConfigs
DataConfigurations m_calodataConfigs
Container with calorimeter data display configurations.
Definition: Display.h:110
dd4hep::Display::GetViewConfiguration
const ViewConfig * GetViewConfiguration(const std::string &name) const
Access a data filter by name. Data filters are used to customize views.
Definition: Display.cpp:247
TEveElementList
Class of the ROOT toolkit. See http://root.cern.ch/root/htmldoc/ClassIndex.html.
Definition: ROOTClasses.h:13
dd4hep::Display::m_eveViews
Views m_eveViews
Container with configured event views.
Definition: Display.h:104
dd4hep::Display::OpenXmlFileDialog
std::string OpenXmlFileDialog(const std::string &default_dir) const
Popup XML file chooser. returns chosen file name; empty on cancel.
Definition: Display.cpp:292
dd4hep::Display::m_eventHandlerName
std::string m_eventHandlerName
Name of the event handler plugin.
Definition: Display.h:120
dd4hep::EventConsumer
Event event consumer base class for DDEve: Interface class for event I/O.
Definition: EventHandler.h:127
dd4hep::Display::ViewConfig
DisplayConfiguration::ViewConfig ViewConfig
Definition: Display.h:58
dd4hep::Display::CalodataContext::CalodataContext
CalodataContext()=default
Default constructor.
dd4hep::Display::CalodataContext::slice
int slice
Definition: Display.h:69
dd4hep::Display::Views
std::set< View * > Views
Definition: Display.h:60
dd4hep::Display::GetCaloHistogram
CalodataContext & GetCaloHistogram(const std::string &name)
Access to calo data histograms by name as defined in the configuration.
Definition: Display.cpp:196
dd4hep::Display::CalodataContext::eveHist
TEveCaloDataHist * eveHist
Definition: Display.h:72
dd4hep::Display::ViewConfigurations
std::map< std::string, ViewConfig > ViewConfigurations
Definition: Display.h:64
dd4hep::Display::Menus
std::set< PopupMenu * > Menus
Definition: Display.h:62
dd4hep::Display::viewConfigurations
const ViewConfigurations & viewConfigurations() const
Access View configurations.
Definition: Display.h:133
dd4hep::Display::LoadXML
void LoadXML(const char *xmlFile)
Load geometry from compact xml file.
Definition: Display.cpp:131
dd4hep::Display::m_eveGlobal
TEveElementList * m_eveGlobal
Event item element list.
Definition: Display.h:94
dd4hep::Display::detectorDescription
Detector & detectorDescription() const
Access to geometry hub.
Definition: Display.cpp:158
dd4hep::Display::CalodataContext::CalodataContext
CalodataContext(const CalodataContext &c)=default
Copy constructor.
EventHandler.h
dd4hep::Display::client
TGClient & client() const
Access to X-client.
Definition: Display.cpp:163
dd4hep::Display::CalodataContext::config
DisplayConfiguration::Config config
Definition: Display.h:73
dd4hep::Display::m_loadLevel
int m_loadLevel
Load level for the eve geometry.
Definition: Display.h:118
dd4hep::Display::~Display
virtual ~Display()
Default destructor.
Definition: Display.cpp:111
dd4hep::Display::m_detDesc
Detector * m_detDesc
Reference to geometry hub.
Definition: Display.h:88
dd4hep::Display::m_evtHandler
GenericEventHandler * m_evtHandler
Reference to the event reader object.
Definition: Display.h:90
dd4hep::DisplayConfiguration::Config
Container with full display configuration.
Definition: DisplayConfiguration.h:92
dd4hep::Display::GetGeo
TEveElementList & GetGeo()
Access / Create global geometry element.
Definition: Display.cpp:456
PopupMenu.h
dd4hep::Display::setEventHandlerName
void setEventHandlerName(const std::string &nam)
Set Event Handler Plugin name.
Definition: Display.h:141
dd4hep::Display::m_calodata
Calodata m_calodata
Container with calorimeter data (projections)
Definition: Display.h:114
dd4hep::Display::Display
Display(TEveManager *eve)
Standard constructor.
Definition: Display.cpp:88
dd4hep::Display::CalodataContext::operator=
CalodataContext & operator=(const CalodataContext &c)=default
Assignment operator.
dd4hep::Display::LoadGeometryRoot
void LoadGeometryRoot(const char *rootFile)
Load geometry from compact xml file.
Definition: Display.cpp:148
dd4hep::DisplayConfiguration::ViewConfig
View configuration.
Definition: DisplayConfiguration.h:119
dd4hep::Display::GetEveTopic
virtual TEveElementList & GetEveTopic(const std::string &name)
Access/Create an event topic by name.
Definition: Display.cpp:486
dd4hep::Display::ChooseGeometry
void ChooseGeometry()
Load geometry with panel.
Definition: Display.cpp:153
dd4hep::PopupMenu
class PopupMenu PopupMenu.h DDEve/PopupMenu.h
Definition: PopupMenu.h:36
dd4hep::Display::eventHandler
GenericEventHandler & eventHandler() const
Access to the event reader.
Definition: Display.cpp:168
dd4hep::Display::m_geoTopics
Topics m_geoTopics
Geometry data topics.
Definition: Display.h:100
dd4hep::DisplayConfiguration
Generic display configuration structure for DDEve.
Definition: DisplayConfiguration.h:40
dd4hep::Display::Calodata
std::map< std::string, CalodataContext > Calodata
Definition: Display.h:82
dd4hep::Display::AddMenu
virtual void AddMenu(TGMenuBar *menuBar, PopupMenu *menu, int hints=kLHintsNormal)
Add new menu to the main menu bar.
Definition: Display.cpp:176
dd4hep::DD4hepMenu
dd4hep Menu for the ROOT browser
Definition: DD4hepMenu.h:37
dd4hep
Namespace for the AIDA detector description toolkit.
Definition: AlignmentsCalib.h:28
dd4hep::Display::ImportEvent
void ImportEvent(TEveElement *el)
Call to import top level event elements.
Definition: Display.cpp:522
dd4hep::Display::Configurations
std::set< DisplayConfiguration * > Configurations
Definition: Display.h:61
dd4hep::Display::OnFileOpen
virtual void OnFileOpen(EventHandler &handler) override
Consumer overload: open file.
Definition: Display.cpp:355
dd4hep::Display::Open
TFile * Open(const char *rootFile) const
Open ROOT file.
Definition: Display.cpp:348
dd4hep::Detector
The main interface to the dd4hep detector description package.
Definition: Detector.h:90
dd4hep::Display::BuildMenus
virtual void BuildMenus(TGMenuBar *menuBar=0)
Build the DDEve specific menues. Default bar is the ROOT browser's bar.
Definition: Display.cpp:333
dd4hep::View
class View View.h DDEve/View.h
Definition: View.h:45
dd4hep::Display::CalodataContext
Calorimeter data context for the DDEve event display.
Definition: Display.h:68
dd4hep::Display::CalodataContext::caloViz
TEveCaloViz * caloViz
Definition: Display.h:71
dd4hep::Display::UnregisterEvents
virtual void UnregisterEvents(View *view)
Unregister from the main event scene.
Definition: Display.cpp:264
dd4hep::Display::Topics
std::map< std::string, TEveElementList * > Topics
Definition: Display.h:63
dd4hep::Display::RegisterEvents
virtual void RegisterEvents(View *view)
Register to the main event scene on new events.
Definition: Display.cpp:259
dd4hep::Display::ImportConfiguration
void ImportConfiguration(const DisplayConfiguration &config)
Import configuration parameters.
Definition: Display.cpp:183
Printout.h
dd4hep::Display::m_dd4Menu
DD4hepMenu * m_dd4Menu
Reference to the specialized ddeve menu.
Definition: Display.h:98
dd4hep::Display::OnNewEvent
virtual void OnNewEvent(EventHandler &handler) override
EventConsumer overload: Consumer event data.
Definition: Display.cpp:359
dd4hep::Display::manager
TEveManager & manager() const
Access to the EVE manager.
Definition: Display.h:131
dd4hep::Display::m_geoGlobal
TEveElementList * m_geoGlobal
Geometry item element list.
Definition: Display.h:92
dd4hep::Display::setVisLevel
void setVisLevel(int new_level)
Set Vis level in geo manager (either from XML or BEFORE XML file was loaded)
Definition: Display.h:135
dd4hep::Display::DataConfig
DisplayConfiguration::Config DataConfig
Definition: Display.h:59
dd4hep::Display::m_eve
TEveManager * m_eve
Reference to TEve manager.
Definition: Display.h:86
dd4hep::Display::m_collectionsConfigs
DataConfigurations m_collectionsConfigs
Container with non-calorimeter data display configurations.
Definition: Display.h:112