TEventChangeManager.hxx
Go to the documentation of this file.
1 #ifndef TEventChangeManager_hxx_seen
2 #define TEventChangeManager_hxx_seen
3 
4 #include <TFile.h>
5 #include <TObject.h>
6 
7 namespace EDep {
10 
11 }
12 
13 /// A class to handle a new event becoming available to the event display.
14 /// There is a single instance of this class owned by TEventDisplay. This
15 /// must be created after the GUI has been initialized.
16 class EDep::TEventChangeManager: public TObject {
17 public:
19  virtual ~TEventChangeManager();
20 
21  /// Set or get the event source. When the event source is set, the first
22  /// event is read. @{
23  void SetEventSource(TFile* source);
24  TFile* GetEventSource() {return fEventSource;}
25  /// @}
26 
27  /// Trigger an event change. The argument says how many events to read.
28  /// If it's positive, then it reads forward in the file. If the change is
29  /// zero, then the current event is just redrawn. This is connected to
30  /// the GUI buttons.
31  void ChangeEvent(int change=1);
32 
33  /// Add a handler (taking ownership of the handler) for when the event
34  /// changes (e.g. a new event is read). These handlers are for
35  /// "once-per-event" actions and are executed by the NewEvent() method.
37 
38  /// Add a handler (taking ownership of the handler) for when the event
39  /// needs to be redrawn. These handlers are executed by the UpdateEvent()
40  /// method.
42 
43  /// Set the flag to show (or not show) the geometry
44  void SetShowGeometry(bool f) {fShowGeometry = f;}
45  bool GetShowGeometry() const {return fShowGeometry;}
46 
47  /// Add the name of a volume to be drawn.
49  fVolumesToShow.push_back(name);
50  }
51 
52  /// Clear the list of volumes to be shown.
54  fVolumesToShow.clear();
55  }
56 
57 private:
58 
59  /// This updates the event display for a new event using the event change
60  /// handlers. It is used to do once-per-event initializations and does
61  /// not call UpdateEvent().
62  void NewEvent();
63 
64  /// This updates the event display for an event using the event change
65  /// handlers.
66  void UpdateEvent();
67 
68  /// The input source of events.
69  TFile* fEventSource;
70 
71  typedef std::vector<EDep::TVEventChangeHandler*> Handlers;
72 
73  /// The event update handlers.
74  Handlers fUpdateHandlers;
75 
76  /// The new event handlers.
78 
79  /// Flag to determine if the geometry will be drawn.
81 
82  /// A collection of volume names to be shown if the geometry is being drawn.
83  std::vector<std::string> fVolumesToShow;
84 
86 };
87 
88 #endif
static QCString name
Definition: declinfo.cpp:673
Handlers fNewEventHandlers
The new event handlers.
ClassDef(TEventChangeManager, 0)
void SetShowGeometry(bool f)
Set the flag to show (or not show) the geometry.
std::string string
Definition: nybbler.cc:12
void SetEventSource(TFile *source)
void AddNewEventHandler(EDep::TVEventChangeHandler *handler)
TFile * fEventSource
The input source of events.
void AddVolumeToShow(const std::string &name)
Add the name of a volume to be drawn.
Handlers fUpdateHandlers
The event update handlers.
std::vector< EDep::TVEventChangeHandler * > Handlers
std::vector< std::string > fVolumesToShow
A collection of volume names to be shown if the geometry is being drawn.
static msg_handler handler
Definition: qglobal.cpp:234
void ClearVolumesToShow()
Clear the list of volumes to be shown.
void AddUpdateHandler(EDep::TVEventChangeHandler *handler)
bool fShowGeometry
Flag to determine if the geometry will be drawn.