Belle II Software  release-05-02-19
DisplayUI.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2012 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Christian Pulvermacher *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #ifndef DISPLAYUI_H
12 #define DISPLAYUI_H
13 
14 #include <TQObject.h>
15 
16 #include <string>
17 #include <vector>
18 
19 class TEveElement;
20 class TEveElementList;
21 class TGButton;
22 class TGCheckButton;
23 class TGPictureButton;
24 class TGLabel;
25 class TGNumberEntry;
26 class TGTextEntry;
27 struct Event_t;
28 
29 namespace Belle2 {
34  template <class T> class ModuleParam;
35  class SplitGLView;
36  class DisplayData;
37 
44  class DisplayUI : public TQObject {
45  public:
50  explicit DisplayUI(bool automatic = false);
51 
53  ~DisplayUI();
54 
61  void addParameter(const std::string& label, ModuleParam<bool>& param, int level);
62 
64  void next();
65 
67  void prev();
68 
70  void goToEvent(Long_t id);
71 
73  void goToEvent(Long_t event, Long_t run, Long_t experiment);
74 
76  void goToEventWidget();
77 
80 
82  void togglePlayPause();
83 
85  void showJumpToEventDialog();
86 
88  void clearEvent();
89 
91  void startAutomaticRun();
92 
94  void automaticEvent();
95 
102  bool startDisplay();
103 
105  void setTitle(const std::string& fileName = "");
106 
108  void allowFlaggingEvents(const std::string& description = "");
109 
111  bool getReturnValue() const;
112 
114  void hideObjects(const std::vector<std::string>& names) { m_hideObjects = names; }
115 
117  void toggleColorScheme();
118 
120  void toggleUndock();
121 
123  void handleParameterChange(int id);
124 
129  void savePicture(bool highres = false);
130 
132  void saveHiResPicture() { savePicture(true); }
133 
136 
141  void pollNewEvents();
142 
144  void exit();
145 
147  void showUserData(const DisplayData& displayData);
148 
150  bool cumulativeIsOn() const { return m_cumulative; }
151 
154 
155  public: // slots, don't call these manually
157  void selectionHandler(TEveElement* eveObj);
158 
160  void handleEvent(Event_t* event);
161 
162 
163  private:
164 
166  struct Parameter {
167  std::string m_label;
169  int m_level;
170  };
171 
173  void makeGui();
174 
176  void updateUI();
177 
179  long m_currentEntry{0};
180 
182  bool m_guiInitialized{false};
183 
185  bool m_reshowCurrentEvent{false};
186 
188  bool m_automatic{false};
189 
191  bool m_cumulative{false};
192 
194  std::vector<Parameter> m_paramList;
195 
197  TGButton* m_prevButton{nullptr};
198 
200  TGButton* m_nextButton{nullptr};
201 
203  TGNumberEntry* m_eventNumberWidget{nullptr};
204 
206  TGNumberEntry* m_autoAdvanceDelay{nullptr};
207 
209  TGPictureButton* m_playPauseButton{nullptr};
210 
212  TGCheckButton* m_flagEvent{nullptr};
213 
215  TGLabel* m_eventLabel{nullptr};
216 
218  TGTextEntry* m_autoFileNamePrefix{nullptr};
219 
221  TGNumberEntry* m_autoPictureWidth{nullptr};
222 
224  TEveElementList* m_eventData{nullptr};
225 
228 
230  TTimer* m_timer{nullptr};
231 
233  std::vector<std::string> m_hideObjects;
234 
236  ClassDef(DisplayUI, 0)
237  };
239 }
240 #endif
Belle2::DisplayUI::next
void next()
Go to next event.
Definition: DisplayUI.cc:98
Belle2::DisplayUI::hideObjects
void hideObjects(const std::vector< std::string > &names)
hide objects with the given names.
Definition: DisplayUI.h:114
Belle2::DisplayUI::getReturnValue
bool getReturnValue() const
Return value for current event, only makes sense if allowFlaggingEvents(true) was called.
Definition: DisplayUI.cc:135
Belle2::DisplayUI::m_guiInitialized
bool m_guiInitialized
Was GUI already built?
Definition: DisplayUI.h:182
Belle2::DisplayUI::showJumpToEventDialog
void showJumpToEventDialog()
Show a dialog to to enter exp, run, event numbers.
Definition: DisplayUI.cc:262
Belle2::DisplayUI::startDisplay
bool startDisplay()
Start interactive display for current event.
Definition: DisplayUI.cc:340
Belle2::DisplayUI::m_playPauseButton
TGPictureButton * m_playPauseButton
Play / Pause button.
Definition: DisplayUI.h:209
Belle2::DisplayUI::autoAdvanceDelayChanged
void autoAdvanceDelayChanged()
m_autoAdvanceDelay was changed, update m_timer if enabled.
Definition: DisplayUI.cc:236
Belle2::DisplayUI::startAutomaticRun
void startAutomaticRun()
switch to automatic mode, where visualisations are saved for each event, with no interactive control.
Definition: DisplayUI.cc:754
Belle2::DisplayUI::allowFlaggingEvents
void allowFlaggingEvents(const std::string &description="")
Show control for flagging events (to set module return value).
Definition: DisplayUI.cc:125
Belle2::DisplayUI::m_autoFileNamePrefix
TGTextEntry * m_autoFileNamePrefix
File name prefix (prefix + #event + "_" + projection + ".png").
Definition: DisplayUI.h:218
Belle2::DisplayUI::m_cumulative
bool m_cumulative
If true, DisplayModule shouldn't clear previous data (i.e.
Definition: DisplayUI.h:191
Belle2::DisplayUI
Control TEve browser user interface.
Definition: DisplayUI.h:44
Belle2::DisplayUI::m_hideObjects
std::vector< std::string > m_hideObjects
objects which are to be hidden (can be manually re-enabled in tree view).
Definition: DisplayUI.h:233
Belle2::DisplayUI::clearEvent
void clearEvent()
remove all event data in current event.
Definition: DisplayUI.cc:285
Belle2::DisplayUI::automaticEvent
void automaticEvent()
The actual per-event functionality for automatic saving.
Definition: DisplayUI.cc:765
Belle2::DisplayUI::m_eventLabel
TGLabel * m_eventLabel
show event/run/exp number for current event.
Definition: DisplayUI.h:215
Belle2::DisplayUI::m_timer
TTimer * m_timer
Polling/auto-advance timer.
Definition: DisplayUI.h:230
Belle2::DisplayUI::handleEvent
void handleEvent(Event_t *event)
Handles keyboard shortcuts.
Definition: DisplayUI.cc:315
Belle2::DisplayUI::makeGui
void makeGui()
Build the buttons for event navigation.
Definition: DisplayUI.cc:406
Belle2::DisplayUI::setTitle
void setTitle(const std::string &fileName="")
Set title of Eve window.
Definition: DisplayUI.cc:115
Belle2::DisplayUI::Parameter::m_label
std::string m_label
Label shown in UI.
Definition: DisplayUI.h:167
Belle2::DisplayUI::m_viewPane
SplitGLView * m_viewPane
pointer to right-side pane with viewers.
Definition: DisplayUI.h:227
Belle2::DisplayUI::goToEvent
void goToEvent(Long_t id)
Go to event with index id.
Definition: DisplayUI.cc:183
Belle2::DisplayUI::Parameter
Wraps a module parameter that can be toggled from the UI.
Definition: DisplayUI.h:166
Belle2::DisplayUI::Parameter::m_level
int m_level
Level this parameter is shown at (0 is highest).
Definition: DisplayUI.h:169
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::DisplayUI::m_flagEvent
TGCheckButton * m_flagEvent
Show control for flagging events (to set module return value).
Definition: DisplayUI.h:212
Belle2::DisplayUI::exit
void exit()
Close window and exit immediately.
Definition: DisplayUI.cc:805
Belle2::DisplayUI::handleParameterChange
void handleParameterChange(int id)
Called when one of the module parameters is changed via UI.
Definition: DisplayUI.cc:643
Belle2::DisplayUI::m_nextButton
TGButton * m_nextButton
Button to switch to next event.
Definition: DisplayUI.h:200
Belle2::DisplayUI::m_paramList
std::vector< Parameter > m_paramList
List of run time configurable module parameters.
Definition: DisplayUI.h:194
Belle2::DisplayUI::addParameter
void addParameter(const std::string &label, ModuleParam< bool > &param, int level)
Generate UI elements so the given module parameter can be changed at run time.
Definition: DisplayUI.cc:89
Belle2::ModuleParam
A single parameter of the module.
Definition: DisplayUI.h:34
Belle2::DisplayUI::cumulativeIsOn
bool cumulativeIsOn() const
If true, DisplayModule shouldn't clear previous data (i.e.
Definition: DisplayUI.h:150
Belle2::DisplayUI::m_reshowCurrentEvent
bool m_reshowCurrentEvent
Show current event again after startDisplay() returns?
Definition: DisplayUI.h:185
Belle2::DisplayUI::togglePlayPause
void togglePlayPause()
Handle Play/Pause button clicks.
Definition: DisplayUI.cc:244
Belle2::DisplayUI::m_automatic
bool m_automatic
If true, disable interactive control and call automaticEvent() instead.
Definition: DisplayUI.h:188
Belle2::DisplayUI::toggleCumulative
void toggleCumulative()
toggle cumulative mode.
Definition: DisplayUI.h:153
Belle2::DisplayUI::m_prevButton
TGButton * m_prevButton
Button to switch to previous event.
Definition: DisplayUI.h:197
Belle2::DisplayUI::toggleUndock
void toggleUndock()
dock/undock active viewer.
Definition: DisplayUI.cc:676
Belle2::DisplayUI::showUserData
void showUserData(const DisplayData &displayData)
Add user-defined data (histograms, etc.).
Definition: DisplayUI.cc:828
Belle2::DisplayUI::m_autoPictureWidth
TGNumberEntry * m_autoPictureWidth
width of saved PNGs.
Definition: DisplayUI.h:221
Belle2::DisplayUI::Parameter::m_param
ModuleParam< bool > * m_param
wrapped parameter.
Definition: DisplayUI.h:168
Belle2::DisplayUI::m_eventData
TEveElementList * m_eventData
List of event data, including projections.
Definition: DisplayUI.h:224
Belle2::DisplayData
Add custom information to the display.
Definition: DisplayData.h:65
Belle2::DisplayUI::getViewPane
SplitGLView * getViewPane()
return right-side pane with viewers.
Definition: DisplayUI.h:135
Belle2::DisplayUI::prev
void prev()
Go to previous event.
Definition: DisplayUI.cc:106
Belle2::DisplayUI::selectionHandler
void selectionHandler(TEveElement *eveObj)
Handle special actions when objects are selected.
Definition: DisplayUI.cc:300
Belle2::DisplayUI::m_eventNumberWidget
TGNumberEntry * m_eventNumberWidget
Event switcher with numeric entry.
Definition: DisplayUI.h:203
Belle2::DisplayUI::goToEventWidget
void goToEventWidget()
go to the event given by m_eventNumberWidget.
Definition: DisplayUI.cc:231
Belle2::DisplayUI::saveHiResPicture
void saveHiResPicture()
alias for savePicture(true).
Definition: DisplayUI.h:132
Belle2::DisplayUI::m_autoAdvanceDelay
TGNumberEntry * m_autoAdvanceDelay
Delay for automatic advance, in seconds.
Definition: DisplayUI.h:206
Belle2::DisplayUI::pollNewEvents
void pollNewEvents()
Check if new events are available, and go to next event.
Definition: DisplayUI.cc:791
Belle2::DisplayUI::updateUI
void updateUI()
Update UI after a new event was loaded, as well as m_currentEntry.
Definition: DisplayUI.cc:140
Belle2::DisplayUI::toggleColorScheme
void toggleColorScheme()
Toggle between light and dark color scheme for viewers.
Definition: DisplayUI.cc:657
Belle2::DisplayUI::DisplayUI
DisplayUI(bool automatic=false)
Constructor.
Definition: DisplayUI.cc:59
Belle2::DisplayUI::m_currentEntry
long m_currentEntry
Current entry id.
Definition: DisplayUI.h:179
Belle2::DisplayUI::savePicture
void savePicture(bool highres=false)
Save the current view to a user-defined filename.
Definition: DisplayUI.cc:705
Belle2::SplitGLView
Responsible for arranging the GL viewers and providing related functionality.
Definition: SplitGLView.h:24
Belle2::DisplayUI::~DisplayUI
~DisplayUI()
Destructor.
Definition: DisplayUI.cc:84