GUIModel.cxx
Go to the documentation of this file.
2 #include <iostream>
5 using namespace om;
6 
7 static bool gsLocked = false;
8 
9 //......................................................................
10 
12 {
13  static GUIModel nico;
14  return nico;
15 }
16 
17 //......................................................................
18 
20 {
21  unsigned int whichInit = 0xFFFF;
22 
23  // subtract off things that should NOT be initialized
24  whichInit -= kCurrentHistogramID;
25  whichInit -= kPlotViewRefreshID;
26  whichInit -= kComparisonUpdateID;
27  whichInit -= kPrintID;
28  whichInit -= kRefFileInitID;
29 
30  this->Publish(whichInit);
31 }
32 
33 //......................................................................
34 
35 void GUIModel::Subscribe(GUIModelSubscriber* s, unsigned int which)
36 {
37  fSubscriber.push_back(s);
38  fWhich. push_back(which);
39 }
40 
41 //......................................................................
42 
44 {
45  unsigned int i;
46  for (i=0; i<fSubscriber.size(); ++i) {
47  if (fSubscriber[i]==s) fSubscriber[i]=0;
48  }
49 }
50 
51 //......................................................................
52 
54 
55 //......................................................................
56 
57 void GUIModel::SetDetector(const char* n)
58 {
59  std::string nm(n);
60  if (nm=="NDOS" || nm=="ndos")
62  else if (nm=="FD" || nm=="fd" || nm=="far" || nm=="FarDet" || nm=="fardet")
64  else if (nm=="ND" || nm=="nd" || nm=="near" || nm=="NearDet" || nm=="neardet" || nm=="NDUG")
66  else if (nm=="TB" || nm=="tb" || nm=="test" || nm=="TestBeam"|| nm=="testbeam")
68  else {
69  std::cout << "\nERROR: " << nm << " is not a valid detector type.\n\n";
70  abort();
71  }
72 
73  this->Publish(kDetectorID);
74 }
75 
76 //......................................................................
77 
79 {
80  fData.SetCSVFile(v);
81 }
82 
83 //......................................................................
84 
85 void GUIModel::SetHistogramSource(const char* s)
86 {
87  //
88  // If the histogram source happens to be a .root file, automatically
89  // pause the automatic updates. If its .shm automatically unpause
90  //
91  std::string ss(s);
92  std::string ext(ss.substr(ss.find_last_of(".")+1));
93  if (ext=="root") { this->SetPlotViewRefreshPaused(true); }
94  if (ext=="shm") { this->SetPlotViewRefreshPaused(false); }
95 
98 }
99 
100 //......................................................................
101 
103 {
107  else
109 }
110 
111 //......................................................................
112 
114 {
117 }
118 
119 //......................................................................
120 
122 {
125 }
126 
127 //......................................................................
128 
130 {
133 }
134 
135 //......................................................................
136 
138 {
139  if (fData.fPlotViewRefreshPaused!=paused) {
140  fData.fPlotViewRefreshPaused = paused;
142  }
143 }
144 
145 //......................................................................
146 
147 void GUIModel::SetCompareWhich(unsigned int i)
148 {
151 }
152 
153 //......................................................................
154 
155 void GUIModel::SetReferenceFile(const char* RefFile)
156 {
159 }
160 
161 //......................................................................
162 
164 {
165  // The comparison box returns a number 0 through (n-1) but the look back
166  // number is defined from 1 to n, so we will add 1.
167  fData.fComparisonOpt.fLookBack = lb + 1;
169 }
170 
171 //......................................................................
172 
173 void GUIModel::SetCompareMethod(unsigned int i)
174 {
177 }
178 
179 //......................................................................
180 
181 void GUIModel::SetCompareNorm(unsigned int i)
182 {
185 }
186 
187 //......................................................................
188 
190 {
192 }
193 
194 //......................................................................
195 
197 {
198  this->Publish(kPrintID);
199 }
200 
201 //......................................................................
202 
204 {
206 
209  else
211 
213 }
214 
215 //......................................................................
216 
218 {
221  else
223 }
224 
225 //......................................................................
226 
227 void GUIModel::Publish(unsigned int which) const
228 {
229  if (gsLocked==true) return;
230 
231  gsLocked = true;
232 
233  unsigned int i;
234  for (i=0; i<fSubscriber.size(); ++i) {
235  if ((which&fWhich[i])!=0 && fSubscriber[i]!=0) {
236  fSubscriber[i]->GUIModelDataIssue(fData, which);
237  }
238  }
239 
240  gsLocked = false;
241 }
242 
243 ////////////////////////////////////////////////////////////////////////
int Set(const char *nm)
static bool gsLocked
Definition: GUIModel.cxx:7
unsigned int fWhich
Which histo. to compare to?
unsigned int fLookBack
Which "look back" histogram to compare to?
void SetCompareNorm(unsigned int i)
Definition: GUIModel.cxx:181
static const unsigned int kWatchListUpdateID
Definition: GUIModelData.h:26
void SetDetector(const char *n)
Definition: GUIModel.cxx:57
static const unsigned int kRefFileInitID
Definition: GUIModelData.h:28
static const unsigned int kCurrentHistogramID
Definition: GUIModelData.h:15
void SetCSVFile(std::string v)
Detector_t fDetector
Definition: GUIModelData.h:34
static const unsigned int kHistogramInfoTextID
Definition: GUIModelData.h:16
static constexpr Double_t nm
Definition: Munits.h:133
Float_t ss
Definition: plot.C:24
void Subscribe(GUIModelSubscriber *s, unsigned int which)
Definition: GUIModel.cxx:35
void SetHistogramSource(const char *s)
Definition: GUIModel.cxx:85
void SetReferenceFile(const char *RefFile)
Definition: GUIModel.cxx:155
void SetCompareWhich(unsigned int i)
Definition: GUIModel.cxx:147
void SetLookBack(int lb)
Definition: GUIModel.cxx:163
std::string fHistogramInfoText
Definition: GUIModelData.h:36
const XML_Char * s
Definition: expat.h:262
static const unsigned int kPrintID
Definition: GUIModelData.h:27
void SendUpdates() const
Definition: GUIModel.cxx:217
static const unsigned int kComparisonUpdateID
Definition: GUIModelData.h:24
ComparisonOptions fComparisonOpt
Definition: GUIModelData.h:41
static GUIModel & Instance()
Definition: GUIModel.cxx:11
void SendPrint()
Definition: GUIModel.cxx:196
void HistogramBack()
Definition: GUIModel.cxx:113
base_types push_back(int_type())
void SetHistogramInfoText(const char *t)
Definition: GUIModel.cxx:129
void Publish(unsigned int which) const
Definition: GUIModel.cxx:227
void Unsubscribe(GUIModelSubscriber *s)
Definition: GUIModel.cxx:43
bool fPlotViewRefreshPaused
Definition: GUIModelData.h:39
OStream cout
Definition: OStream.cxx:6
unsigned int fMethod
How to show the comparison?
void DrawContentProjection()
Definition: GUIModel.cxx:203
static const unsigned int kPlotViewRefreshPausedID
Definition: GUIModelData.h:18
static const unsigned int kComparisonOptionsID
Definition: GUIModelData.h:21
static const unsigned int kHistogramSourceID
Definition: GUIModelData.h:22
void SetCurrentHistogram(const char *h)
Definition: GUIModel.cxx:102
void HistogramForward()
Definition: GUIModel.cxx:121
std::string fHistogramSource
Definition: GUIModelData.h:35
GUIModelData fData
Definition: GUIModel.h:47
CurrentHistogram fCurrentHistogram
Definition: GUIModelData.h:37
void Init()
Definition: GUIModel.cxx:19
void SendWatchListUpdate()
Definition: GUIModel.cxx:189
void SetCompareMethod(unsigned int i)
Definition: GUIModel.cxx:173
std::vector< GUIModelSubscriber * > fSubscriber
Definition: GUIModel.h:48
void SetPlotViewRefreshPaused(bool paused)
Definition: GUIModel.cxx:137
unsigned int fContentProjection
Definition: GUIModelData.h:42
unsigned int fNormalize
How to normalize the histos?
std::string fReferenceFile
Reference file for comparison histograms.
static const unsigned int kDetectorID
Definition: GUIModelData.h:25
void SetCSVFile(std::string v)
Definition: GUIModel.cxx:78
Online Monitoring package header.
std::vector< unsigned int > fWhich
Definition: GUIModel.h:49
static const unsigned int kPlotViewRefreshID
Definition: GUIModelData.h:17
enum BeamMode string