GRUTinizer
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
TStripChart.h
Go to the documentation of this file.
1 #ifndef _TSTRIPCHART_H_
2 #define _TSTRIPCHART_H_
3 
4 #ifndef __CINT__
5 # include <thread>
6 # include <atomic>
7 #endif
8 #include <vector>
9 
10 #include "TBits.h"
11 #include "TCanvas.h"
12 #include "THStack.h"
13 #include "TLegend.h"
14 #include "TStopwatch.h"
15 #include "TStyle.h"
16 
17 #include "TStripChartItem.h"
18 
19 
20 
21 class TStripChart : public TObject {
22 public:
23  TStripChart();
24  ~TStripChart();
25 
26  void Update();
27  void Draw(Option_t* opt = "nostack ][");
28 
29  TVirtualPad* GetPad();
30  double GetCurrentTime();
31 
32  void SetPaused(bool flag = true) { bitflags.SetBitNumber(kPaused, flag); }
33  bool IsPaused() { return bitflags.TestBitNumber(kPaused); }
34 
35  void SetRunning(bool flag = true);
36  bool IsRunning() { return bitflags.TestBitNumber(kRunning); }
37 
38  void Attach(const char* title, double* value, int color = 0);
39 
40  size_t NumCharts(){ return charts.size(); }
41  void Fill();
42 
43  void SetColor(size_t chartnum, int color) { GetChart(chartnum).SetColor(color); }
44 
45  TStripChartItem& GetChart(size_t chartnum) { return *charts.at(chartnum).chart; }
46 
47  TH1* GetHist(size_t chartnum) { return GetChart(chartnum).GetHist(); }
48 
49  void StartPoll(int period_milliseconds);
50  void RunPoll(int period_milliseconds);
51  void StopPoll();
52 
53 private:
54 
55  enum {kPaused, kRunning};
56 
57  void Init();
58 
59  TBits bitflags;
60  TCanvas canvas;
61  TStopwatch stopwatch;
62  TLegend legend;
63 
64  static TStyle* style;
65 
66  struct ChartValues{
67  double* value;
69  };
70 
71  std::vector<ChartValues> charts;
72  THStack hstack;
73 
74 #ifndef __CINT__
75  std::thread poll_thread;
76  std::atomic_bool is_polling;
77 #endif
78 
80 };
81 
82 #endif /* _TSTRIPCHART_H_ */