Belle II Software development
DisplayUI.h
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#pragma once
10
11#include <TQObject.h>
12
13#include <string>
14#include <vector>
15
16class TEveElement;
17class TEveElementList;
18class TGButton;
19class TGCheckButton;
20class TGPictureButton;
21class TGLabel;
22class TGNumberEntry;
23class TGTextEntry;
24struct Event_t;
25
26namespace Belle2 {
31 template <class T> class ModuleParam;
32 class SplitGLView;
33 class DisplayData;
34
41 class DisplayUI : public TQObject {
42 public:
48 explicit DisplayUI(bool automatic = false, bool advance = false);
49
51 ~DisplayUI();
52
59 void addParameter(const std::string& label, ModuleParam<bool>& param, int level);
60
62 void next();
63
65 void prev();
66
68 void goToEvent(Long_t id);
69
71 void goToEvent(Long_t event, Long_t run, Long_t experiment);
72
74 void goToEventWidget();
75
78
80 void togglePlayPause();
81
84
86 void clearEvent();
87
89 void startAutomaticRun();
90
92 void automaticEvent();
93
100 bool startDisplay();
101
103 void setTitle(const std::string& fileName = "");
104
106 void allowFlaggingEvents(const std::string& description = "");
107
109 bool getReturnValue() const;
110
112 void hideObjects(const std::vector<std::string>& names) { m_hideObjects = names; }
113
115 void toggleColorScheme();
116
118 void toggleUndock();
119
121 void handleParameterChange(int id);
122
127 void savePicture(bool highres = false);
128
131
134
139 void pollNewEvents();
140
142 void closeAndExit();
143
145 void showUserData(const DisplayData& displayData);
146
148 bool cumulativeIsOn() const { return m_cumulative; }
149
152
153 public: // slots, don't call these manually
155 void selectionHandler(TEveElement* eveObj);
156
158 void handleEvent(Event_t* event);
159
160
161 private:
162
164 struct Parameter {
165 std::string m_label;
168 };
169
171 void makeGui();
172
174 void updateUI();
175
178
180 bool m_guiInitialized{false};
181
184
186 bool m_automatic{false};
187
189 bool m_advance{false};
190
192 bool m_cumulative{false};
193
195 std::vector<Parameter> m_paramList;
196
198 TGButton* m_prevButton{nullptr};
199
201 TGButton* m_nextButton{nullptr};
202
204 TGNumberEntry* m_eventNumberWidget{nullptr};
205
207 TGNumberEntry* m_autoAdvanceDelay{nullptr};
208
210 TGPictureButton* m_playPauseButton{nullptr};
211
213 TGCheckButton* m_flagEvent{nullptr};
214
216 TGLabel* m_eventLabel{nullptr};
217
219 TGTextEntry* m_autoFileNamePrefix{nullptr};
220
222 TGNumberEntry* m_autoPictureWidth{nullptr};
223
225 TEveElementList* m_eventData{nullptr};
226
229
231 TTimer* m_timer{nullptr};
232
234 std::vector<std::string> m_hideObjects;
235
237 ClassDef(DisplayUI, 0)
238 };
240}
Add custom information to the display.
Definition: DisplayData.h:55
Control TEve browser user interface.
Definition: DisplayUI.h:41
void clearEvent()
remove all event data in current event.
Definition: DisplayUI.cc:282
void next()
Go to next event.
Definition: DisplayUI.cc:96
TGLabel * m_eventLabel
show event/run/exp number for current event.
Definition: DisplayUI.h:216
void hideObjects(const std::vector< std::string > &names)
hide objects with the given names.
Definition: DisplayUI.h:112
void handleEvent(Event_t *event)
Handles keyboard shortcuts.
Definition: DisplayUI.cc:312
long m_currentEntry
Current entry id.
Definition: DisplayUI.h:177
std::vector< Parameter > m_paramList
List of run time configurable module parameters.
Definition: DisplayUI.h:195
void startAutomaticRun()
switch to automatic mode, where visualisations are saved for each event, with no interactive control.
Definition: DisplayUI.cc:752
void autoAdvanceDelayChanged()
m_autoAdvanceDelay was changed, update m_timer if enabled.
Definition: DisplayUI.cc:233
~DisplayUI()
Destructor.
Definition: DisplayUI.cc:82
void togglePlayPause()
Handle Play/Pause button clicks.
Definition: DisplayUI.cc:241
TGButton * m_prevButton
Button to switch to previous event.
Definition: DisplayUI.h:198
void closeAndExit()
Close window and exit immediately.
Definition: DisplayUI.cc:803
bool m_automatic
If true, disable interactive control and call automaticEvent() instead.
Definition: DisplayUI.h:186
bool getReturnValue() const
Return value for current event, only makes sense if allowFlaggingEvents(true) was called.
Definition: DisplayUI.cc:134
void setTitle(const std::string &fileName="")
Set title of Eve window.
Definition: DisplayUI.cc:113
TEveElementList * m_eventData
List of event data, including projections.
Definition: DisplayUI.h:225
void automaticEvent()
The actual per-event functionality for automatic saving.
Definition: DisplayUI.cc:763
void selectionHandler(TEveElement *eveObj)
Handle special actions when objects are selected.
Definition: DisplayUI.cc:297
void makeGui()
Build the buttons for event navigation.
Definition: DisplayUI.cc:406
bool cumulativeIsOn() const
If true, DisplayModule shouldn't clear previous data (i.e.
Definition: DisplayUI.h:148
void pollNewEvents()
Check if new events are available, and go to next event.
Definition: DisplayUI.cc:789
SplitGLView * getViewPane()
return right-side pane with viewers.
Definition: DisplayUI.h:133
TGButton * m_nextButton
Button to switch to next event.
Definition: DisplayUI.h:201
void toggleCumulative()
toggle cumulative mode.
Definition: DisplayUI.h:151
TGPictureButton * m_playPauseButton
Play / Pause button.
Definition: DisplayUI.h:210
TTimer * m_timer
Polling/auto-advance timer.
Definition: DisplayUI.h:231
void handleParameterChange(int id)
Called when one of the module parameters is changed via UI.
Definition: DisplayUI.cc:641
bool m_guiInitialized
Was GUI already built?
Definition: DisplayUI.h:180
void toggleUndock()
dock/undock active viewer.
Definition: DisplayUI.cc:674
void updateUI()
Update UI after a new event was loaded, as well as m_currentEntry.
Definition: DisplayUI.cc:139
TGNumberEntry * m_autoAdvanceDelay
Delay for automatic advance, in seconds.
Definition: DisplayUI.h:207
void goToEvent(Long_t id)
Go to event with index id.
Definition: DisplayUI.cc:182
TGNumberEntry * m_eventNumberWidget
Event switcher with numeric entry.
Definition: DisplayUI.h:204
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:87
void savePicture(bool highres=false)
Save the current view to a user-defined filename.
Definition: DisplayUI.cc:703
TGCheckButton * m_flagEvent
Show control for flagging events (to set module return value).
Definition: DisplayUI.h:213
void toggleColorScheme()
Toggle between light and dark color scheme for viewers.
Definition: DisplayUI.cc:655
bool startDisplay()
Start interactive display for current event.
Definition: DisplayUI.cc:337
void showUserData(const DisplayData &displayData)
Add user-defined data (histograms, etc.).
Definition: DisplayUI.cc:831
void prev()
Go to previous event.
Definition: DisplayUI.cc:104
TGNumberEntry * m_autoPictureWidth
width of saved PNGs.
Definition: DisplayUI.h:222
void goToEventWidget()
go to the event given by m_eventNumberWidget.
Definition: DisplayUI.cc:228
bool m_reshowCurrentEvent
Show current event again after startDisplay() returns?
Definition: DisplayUI.h:183
bool m_advance
If true, start advancing through the events on startup.
Definition: DisplayUI.h:189
TGTextEntry * m_autoFileNamePrefix
File name prefix (prefix + event number + "_" + projection + ".png").
Definition: DisplayUI.h:219
void showJumpToEventDialog()
Show a dialog to to enter exp, run, event numbers.
Definition: DisplayUI.cc:259
void saveHiResPicture()
alias for savePicture(true).
Definition: DisplayUI.h:130
SplitGLView * m_viewPane
pointer to right-side pane with viewers.
Definition: DisplayUI.h:228
std::vector< std::string > m_hideObjects
objects which are to be hidden (can be manually re-enabled in tree view).
Definition: DisplayUI.h:234
void allowFlaggingEvents(const std::string &description="")
Show control for flagging events (to set module return value).
Definition: DisplayUI.cc:124
bool m_cumulative
If true, DisplayModule shouldn't clear previous data (i.e.
Definition: DisplayUI.h:192
A single parameter of the module.
Definition: ModuleParam.h:34
Responsible for arranging the GL viewers and providing related functionality.
Definition: SplitGLView.h:30
Abstract base class for different kinds of events.
Wraps a module parameter that can be toggled from the UI.
Definition: DisplayUI.h:164
int m_level
Level this parameter is shown at (0 is highest).
Definition: DisplayUI.h:167
std::string m_label
Label shown in UI.
Definition: DisplayUI.h:165
ModuleParam< bool > * m_param
wrapped parameter.
Definition: DisplayUI.h:166