Belle II Software  release-08-01-10
Display.cc
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 //-----------------------------------------------------------------------------
10 // Description : A class to display CDC trigger information.
11 //-----------------------------------------------------------------------------
12 
13 #ifdef TRGCDC_DISPLAY
14 
15 #include <unistd.h>
16 #include <iostream>
17 #include "trg/cdc/Display.h"
18 #include "trg/cdc/DisplayDrawingArea.h"
19 
20 using namespace std;
21 
22 namespace Belle2 {
28  Gtk::Main* GtkMain = 0;
29  bool TRGCDCDisplay::_skipEvent = false;
30  bool TRGCDCDisplay::_endOfEvent = false;
31  bool TRGCDCDisplay::_endOfEventFlag = false;
32  bool TRGCDCDisplay::_nonStop = false;
33 
34  TRGCDCDisplay::TRGCDCDisplay(const string& name,
35  int,
36  int)
37  : _skip(false),
38  _wireName(false),
39  _oldCDC(false),
40  _box0(false, 2),
41  _menuButtons(true, 2),
42  _buttonNext("Next Step"),
43  _buttonEndOfEvent("End of Event"),
44  _buttonNextEvent("Next Event"),
45  _buttonNonStop("Non Stop"),
46  _label("Stage : TRGing not started\nInformation :",
47  Gtk::ALIGN_LEFT,
48  Gtk::ALIGN_TOP),
49  _buttonPositionReset("Reset position"),
50  _buttonWireName("Wire Name"),
51  _rphi(0)
52  {
53 
54  set_title(name);
55 
56  _buttonWireName.set_active(false);
57  _wireName = _buttonWireName.get_active();
58 
59  _buttonNext
60  .signal_clicked()
61  .connect(sigc::mem_fun(* this, & TRGCDCDisplay::on_next));
62  _menuButtons.pack_start(_buttonNext, Gtk::PACK_EXPAND_WIDGET, 2);
63  _buttonEndOfEvent
64  .signal_clicked()
65  .connect(sigc::mem_fun(* this, & TRGCDCDisplay::on_endOfEvent));
66  _menuButtons.pack_start(_buttonEndOfEvent, Gtk::PACK_EXPAND_WIDGET, 2);
67  _buttonNextEvent
68  .signal_clicked()
69  .connect(sigc::mem_fun(* this, & TRGCDCDisplay::on_nextEvent));
70  _menuButtons.pack_start(_buttonNextEvent, Gtk::PACK_EXPAND_WIDGET, 2);
71 
72  _buttonNonStop
73  .signal_clicked()
74  .connect(sigc::mem_fun(* this, & TRGCDCDisplay::on_nonStop));
75  _menuButtons.pack_start(_buttonNonStop, Gtk::PACK_EXPAND_WIDGET, 2);
76 
77  _buttonPositionReset
78  .signal_clicked()
79  .connect(sigc::mem_fun(* this, & TRGCDCDisplay::on_positionReset));
80  _buttonWireName
81  .signal_clicked()
82  .connect(sigc::mem_fun(* this, & TRGCDCDisplay::on_wireName));
83  }
84 
85  TRGCDCDisplay::~TRGCDCDisplay()
86  {
87  }
88 
89  void
90  TRGCDCDisplay::on_positionReset(void)
91  {
92  area().resetPosition();
93  area().on_expose_event((GdkEventExpose*) NULL);
94  }
95 
96  void
97  TRGCDCDisplay::on_next(void)
98  {
99  Gtk::Main::quit();
100  }
101 
102  void
103  TRGCDCDisplay::on_endOfEvent(void)
104  {
105  _endOfEventFlag = true;
106  _skipEvent = true;
107  Gtk::Main::quit();
108  }
109 
110  void
111  TRGCDCDisplay::on_nextEvent(void)
112  {
113  _skipEvent = true;
114  Gtk::Main::quit();
115  }
116 
117  void
118  TRGCDCDisplay::on_nonStop(void)
119  {
120  _nonStop = true;
121  Gtk::Main::quit();
122  }
123 
124  void
125  TRGCDCDisplay::on_wireName(void)
126  {
127  _wireName = _buttonWireName.get_active();
128  area().wireName(_wireName);
129  area().on_expose_event((GdkEventExpose*) NULL);
130  }
131 
132  void
133  TRGCDCDisplay::run(void)
134  {
135  int argc = 0;
136  char** argv = 0;
137  Gtk::Main main_instance(argc, argv);
138  show();
139  if (_nonStop)
140  sleep(1);
141  else if (((! _skip) && (! _skipEvent)) || (_endOfEventFlag && _endOfEvent))
142  Gtk::Main::run();
143  }
144 
145  void
146  TRGCDCDisplay::clear(void)
147  {
148  area().clear();
149  const string id = "unknown";
150  _stage = id;
151  _info = "";
152  }
153 
154  void
155  TRGCDCDisplay::stop(void)
156  {
157  _nonStop = false;
158  _skip = false;
159  _skipEvent = false;
160  }
161 
163 } // namespace Belle2
164 
165 #endif
Abstract base class for different kinds of events.