forked from mcoquet642/AliceO2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEventManagerFrame.cxx
More file actions
167 lines (143 loc) · 5.06 KB
/
EventManagerFrame.cxx
File metadata and controls
167 lines (143 loc) · 5.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
/// \file EventManagerFrame.cxx
/// \brief GUI (bottom buttons) for visualisation
/// \author julian.myrcha@cern.ch
/// \author p.nowakowski@cern.ch
#include <TGButton.h>
#include <TGNumberEntry.h>
#include <TGLabel.h>
#include <TTimer.h>
#include <EventVisualisationView/EventManagerFrame.h>
#include <EventVisualisationView/MultiView.h>
#include <EventVisualisationBase/DataSourceOffline.h>
#include <EventVisualisationDetectors/DataReaderVSD.h>
#include <Rtypes.h>
#include <mutex>
std::mutex mtx; // mutex for critical section
ClassImp(o2::event_visualisation::EventManagerFrame);
namespace o2
{
namespace event_visualisation
{
EventManagerFrame::~EventManagerFrame()
{
this->StopTimer();
}
EventManagerFrame::EventManagerFrame(o2::event_visualisation::EventManager& eventManager)
: TGMainFrame(gClient->GetRoot(), 400, 100, kVerticalFrame)
{
mEventManager = &eventManager;
this->mTimer = new TTimer(); // Auto-load time in seconds
this->mTime = 2;
this->mTimer->Connect("Timeout()", "o2::event_visualisation::EventManagerFrame", this, "DoTimeTick()");
const TString cls("o2::event_visualisation::EventManagerFrame");
TGTextButton* b = nullptr;
TGHorizontalFrame* f = new TGHorizontalFrame(this);
{
Int_t width = 50;
this->AddFrame(f, new TGLayoutHints(kLHintsExpandX, 0, 0, 2, 2));
b = EventManagerFrame::makeButton(f, "First", width);
b->Connect("Clicked()", cls, this, "DoFirstEvent()");
b = EventManagerFrame::makeButton(f, "Prev", width);
b->Connect("Clicked()", cls, this, "DoPrevEvent()");
mEventId = new TGNumberEntry(f, 0, 5, -1, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative,
TGNumberFormat::kNELLimitMinMax, 0, 10000);
f->AddFrame(mEventId, new TGLayoutHints(kLHintsNormal, 10, 5, 0, 0));
mEventId->Connect("ValueSet(Long_t)", cls, this, "DoSetEvent()");
TGLabel* infoLabel = new TGLabel(f);
f->AddFrame(infoLabel, new TGLayoutHints(kLHintsNormal, 5, 10, 4, 0));
b = EventManagerFrame::makeButton(f, "Next", width);
b->Connect("Clicked()", cls, this, "DoNextEvent()");
b = EventManagerFrame::makeButton(f, "Last", width);
b->Connect("Clicked()", cls, this, "DoLastEvent()");
b = EventManagerFrame::makeButton(f, "Screenshot", 2 * width);
b->Connect("Clicked()", cls, this, "DoScreenshot()");
}
SetCleanup(kDeepCleanup);
Layout();
MapSubwindows();
MapWindow();
}
TGTextButton* EventManagerFrame::makeButton(TGCompositeFrame* p, const char* txt,
Int_t width, Int_t lo, Int_t ro, Int_t to, Int_t bo)
{
TGTextButton* b = new TGTextButton(p, txt);
//b->SetFont("-adobe-helvetica-bold-r-*-*-48-*-*-*-*-*-iso8859-1");
if (width > 0) {
b->SetWidth(width);
b->ChangeOptions(b->GetOptions() | kFixedWidth);
}
p->AddFrame(b, new TGLayoutHints(kLHintsNormal, lo, ro, to, bo));
return b;
}
void EventManagerFrame::DoFirstEvent()
{
mEventManager->GotoEvent(0);
mEventId->SetIntNumber(mEventManager->getDataSource()->getCurrentEvent());
}
void EventManagerFrame::DoPrevEvent()
{
mEventManager->PrevEvent();
mEventId->SetIntNumber(mEventManager->getDataSource()->getCurrentEvent());
}
void EventManagerFrame::DoNextEvent()
{
mEventManager->NextEvent();
mEventId->SetIntNumber(mEventManager->getDataSource()->getCurrentEvent());
}
void EventManagerFrame::DoLastEvent()
{
mEventManager->GotoEvent(-1); /// -1 means last available
mEventId->SetIntNumber(mEventManager->getDataSource()->getCurrentEvent());
}
void EventManagerFrame::DoSetEvent()
{
}
void EventManagerFrame::DoScreenshot()
{
}
void EventManagerFrame::DoTimeTick()
{
std::unique_lock<std::mutex> lck(mtx, std::defer_lock);
bool inTick;
lck.lock();
inTick = this->inTick;
this->inTick = true;
lck.unlock();
if (inTick) {
return;
}
if (mEventManager->getDataSource()->refresh()) {
mEventManager->displayCurrentEvent();
}
lck.lock();
this->inTick = false;
lck.unlock();
}
void EventManagerFrame::StopTimer()
{
this->mTimerRunning = kFALSE;
if (this->mTimer != nullptr) {
this->mTimer->TurnOff();
}
}
void EventManagerFrame::StartTimer()
{
if (this->mTimer != nullptr) {
this->mTimer->SetTime((Long_t)(1000 * this->mTime));
this->mTimer->Reset();
this->mTimer->TurnOn();
}
this->mTimerRunning = kTRUE;
}
} // namespace event_visualisation
}