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