ButtonBank.cxx
Go to the documentation of this file.
2 #include <cstdlib>
3 #include <iostream>
4 #include "TGButton.h"
5 #include "TGLayout.h"
6 #include "TTimer.h"
10 using namespace om;
11 
12 //......................................................................
13 
15  TGCompositeFrame(mf,
16  Layout::fButtonBankSizeX,
17  Layout::fButtonBankSizeY,
18  kHorizontalFrame),
20 {
21  fLhint = new TGLayoutHints(kLHintsLeft, 2, 4);
22 
23  fBack = new TGPictureButton(this, Icons::Rewind());
24  fBack->Connect("Clicked()", "om::ButtonBank", this, "Back()");
25  fBack->SetToolTipText("Move backward in history");
26  fBack->SetState(kButtonDisabled);
27  this->AddFrame(fBack, fLhint);
28 
29  fForward = new TGPictureButton(this, Icons::FastForward());
30  fForward->SetToolTipText("Move forward in history");
31  fForward->Connect("Clicked()", "om::ButtonBank", this, "Forward()");
32  fForward->SetState(kButtonDisabled);
33  this->AddFrame(fForward, fLhint);
34 
35  fResume = new TGPictureButton(this, Icons::Play());
36  fResume->SetToolTipText("Resume automatic plot updates");
37  fResume->Connect("Clicked()", "om::ButtonBank", this, "Resume()");
38  fResume->SetState(kButtonDisabled);
39  this->AddFrame(fResume, fLhint);
40 
41  fPause = new TGPictureButton(this, Icons::Pause());
42  fPause->SetToolTipText("Pause automatic plot updates");
43  fPause->Connect("Clicked()", "om::ButtonBank", this, "Pause()");
44  fPause->SetState(kButtonDisabled);
45  this->AddFrame(fPause, fLhint);
46 
47  fUpdate = new TGPictureButton(this, Icons::Repeat());
48  fUpdate->SetToolTipText("Force plot update now");
49  fUpdate->Connect("Clicked()", "om::ButtonBank", this, "Update()");
50  fUpdate->SetState(kButtonDisabled);
51  this->AddFrame(fUpdate, fLhint);
52 
53  fHisto = new TGPictureButton(this, Icons::Histo());
54  fHisto->SetToolTipText("Show 1D histogram of bin contents");
55  fHisto->Connect("Clicked()", "om::ButtonBank", this, "Histo()");
56  fHisto->SetState(kButtonUp);
57  this->AddFrame(fHisto, fLhint);
58 
59  fPrint = new TGPictureButton(this, Icons::Print());
60  fPrint->SetToolTipText("Print to a file");
61  fPrint->Connect("Clicked()", "om::ButtonBank", this, "PrintPlot()");
62  fPrint->SetState(kButtonUp);
63  this->AddFrame(fPrint, fLhint);
64 
65  this->MapSubwindows();
66  this->Resize();
67  this->MapWindow();
68 
69  fTimer = new TTimer;
70  fTimer->SetObject(this);
71  fTimer->Start(GUIModel::Instance().Data().fPlotViewRefreshRate);
72 }
73 
74 //......................................................................
75 
77 {
79 }
80 
81 //......................................................................
82 
84 {
86 }
87 
88 //......................................................................
89 
91 {
93 }
94 
95 //......................................................................
96 
98 {
100 }
101 
102 //......................................................................
103 
105 {
107  fHisto->SetState(kButtonUp);
108 }
109 
110 //......................................................................
111 
113 {
115 }
116 
117 //......................................................................
118 
120 {
122 }
123 
124 //......................................................................
125 
126 Bool_t ButtonBank::HandleTimer(TTimer* t)
127 {
128 
129  if(GUIModel::Instance().Data().fPlotViewRefreshPaused == true) return true;
130 
131  this->Update();
132  fTimer->SetTime(GUIModel::Instance().Data().fPlotViewRefreshRate);
133 
134  return true;
135 
136 }
137 
138 //......................................................................
139 
141 {
142  if(fBack) { delete fBack; fBack = 0; }
143  if(fForward) { delete fForward; fForward = 0; }
144  if(fUpdate) { delete fUpdate; fUpdate = 0; }
145  if(fPause) { delete fPause; fPause = 0; }
146  if(fResume) { delete fResume; fResume = 0; }
147  if(fTimer) { delete fTimer; fTimer = 0; }
148 }
149 
150 //......................................................................
151 
153  unsigned int which)
154 {
155  if (this->GetLock()==false) return;
156 
157  if ((which & kCurrentHistogramID)!=0) {
158  bool back_ok = d.fCurrentHistogram.BackwardOK();
159  bool back_en = (fBack->GetState()!=kButtonDisabled);
160  if ( back_ok && !back_en) fBack->SetState(kButtonUp);
161  if (!back_ok && back_en) fBack->SetState(kButtonDisabled);
162 
163  bool forward_ok = d.fCurrentHistogram.ForwardOK();
164  bool forward_en = (fForward->GetState()!=kButtonDisabled);
165  if ( forward_ok && !forward_en) fForward->SetState(kButtonUp);
166  if (!forward_ok && forward_en) fForward->SetState(kButtonDisabled);
167 
168  bool update_ok = d.fCurrentHistogram.ReloadOK();
169  bool update_en = (fUpdate->GetState()!=kButtonDisabled);
170  if ( update_ok && !update_en) fUpdate->SetState(kButtonUp);
171  if (!update_ok && update_en) fUpdate->SetState(kButtonDisabled);
172  }
173  if ((which | kPlotViewRefreshPausedID)!=0) {
174  bool paused = d.fPlotViewRefreshPaused;
175  bool pause_en = (fPause-> GetState()!=kButtonDisabled);
176  bool resume_en = (fResume->GetState()!=kButtonDisabled);
177  if ( paused && pause_en) fPause-> SetState(kButtonDisabled);
178  if (!paused && !pause_en) fPause-> SetState(kButtonUp);
179  if ( paused && !resume_en) fResume->SetState(kButtonUp);
180  if (!paused && resume_en) fResume->SetState(kButtonDisabled);
181  }
182 
183  this->ReleaseLock();
184 }
185 
186 ////////////////////////////////////////////////////////////////////////
void GUIModelDataIssue(const GUIModelData &d, unsigned int which)
Definition: ButtonBank.cxx:152
TGPictureButton * fForward
Move forward in plot history.
Definition: ButtonBank.h:39
static const unsigned int kCurrentHistogramID
Definition: GUIModelData.h:15
const TGPicture * Print()
Definition: Icons.cxx:91
TGPictureButton * fBack
Move back in plot history.
Definition: ButtonBank.h:38
TTimer * fTimer
The timer to issue plot auto-refresh.
Definition: ButtonBank.h:46
ButtonBank(TGWindow *w)
Definition: ButtonBank.cxx:14
TGPictureButton * fPause
Pause automatic updates.
Definition: ButtonBank.h:41
const TGPicture * Repeat()
Definition: Icons.cxx:71
void SendUpdates() const
Definition: GUIModel.cxx:217
TGLayoutHints * fLhint
Layout hints.
Definition: ButtonBank.h:37
static GUIModel & Instance()
Definition: GUIModel.cxx:11
void SendPrint()
Definition: GUIModel.cxx:196
void HistogramBack()
Definition: GUIModel.cxx:113
const TGPicture * Play()
Definition: Icons.cxx:61
Float_t d
Definition: plot.C:236
bool fPlotViewRefreshPaused
Definition: GUIModelData.h:39
TGPictureButton * fResume
Resume automatic updates.
Definition: ButtonBank.h:42
Bool_t HandleTimer(TTimer *t)
Definition: ButtonBank.cxx:126
const TGPicture * FastForward()
Definition: Icons.cxx:41
TGPictureButton * fUpdate
Update current plot.
Definition: ButtonBank.h:40
void DrawContentProjection()
Definition: GUIModel.cxx:203
static const unsigned int kPlotViewRefreshPausedID
Definition: GUIModelData.h:18
const TGPicture * Rewind()
Definition: Icons.cxx:31
void HistogramForward()
Definition: GUIModel.cxx:121
CurrentHistogram fCurrentHistogram
Definition: GUIModelData.h:37
TGPictureButton * fHisto
Show histogram of 2D contents.
Definition: ButtonBank.h:43
const TGPicture * Histo()
Definition: Icons.cxx:101
void SetPlotViewRefreshPaused(bool paused)
Definition: GUIModel.cxx:137
const TGPicture * Pause()
Definition: Icons.cxx:51
TGPictureButton * fPrint
Print plot to file.
Definition: ButtonBank.h:44
Online Monitoring package header.