GuiDisplay.h 2.05 KB
Newer Older
Daniel Hynds's avatar
Daniel Hynds committed
1
2
3
#ifndef GUIDISPLAY_H
#define GUIDISPLAY_H 1

4
// Local includes
Daniel Hynds's avatar
Daniel Hynds committed
5
6
#include "TestBeamObject.h"

7
8
// Global includes
#include "signal.h"
Daniel Hynds's avatar
Daniel Hynds committed
9
#include <iostream>
10

Daniel Hynds's avatar
Daniel Hynds committed
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// ROOT includes
#include "TH1F.h"
#include "TH2F.h"
#include "TCanvas.h"
#include "TGCanvas.h"
#include "TGFrame.h"
#include "TGTextEntry.h"
#include "TGDockableFrame.h"
#include "TGMenu.h"
#include "TApplication.h"
#include <RQ_OBJECT.h>
#include "TROOT.h"
#include "TSystem.h"
#include "TRootEmbeddedCanvas.h"

class GuiDisplay : public TestBeamObject {
  
  RQ_OBJECT("GuiDisplay")

public:
  // Constructors and destructors
  GuiDisplay(){};
  ~GuiDisplay(){}

  // Graphics associated with GUI
  TGMainFrame*														m_mainFrame;
37
38
  TRootEmbeddedCanvas*										canvas;
  map<string, vector<TH1*>> 							histograms;
Daniel Hynds's avatar
Daniel Hynds committed
39
40
41
  map<TH1*,string> 												styles;
  map<string, TGTextButton*> 							buttons;
  map<TRootEmbeddedCanvas*, bool>					stackedCanvas;
42
  TGHorizontalFrame* 											buttonMenu;
Daniel Hynds's avatar
Daniel Hynds committed
43
44

  // Button functions
45
46
47
48
  inline void Display(char* canvasNameC){
    string canvasName(canvasNameC);
    if(histograms[canvasName].size() == 0){
      cout<<"Canvas does not have any histograms, exiting"<<endl;
Daniel Hynds's avatar
Daniel Hynds committed
49
50
      return;
    }
51
    int nHistograms = histograms[canvasName].size();
Daniel Hynds's avatar
Daniel Hynds committed
52
53
54
55
56
57
58
59
    canvas->GetCanvas()->Clear();
    canvas->GetCanvas()->cd();
    if(!stackedCanvas[canvas]){
      if(nHistograms < 4) canvas->GetCanvas()->Divide(nHistograms);
      else canvas->GetCanvas()->Divide(ceil(nHistograms/2.),2);
    }
    for(int i=0;i<nHistograms;i++){
      if(!stackedCanvas[canvas]) canvas->GetCanvas()->cd(i+1);
60
      string style = styles[histograms[canvasName][i]];
Daniel Hynds's avatar
Daniel Hynds committed
61
62
      if(stackedCanvas[canvas]){
        style = "same";
63
        histograms[canvasName][i]->SetLineColor(i+1);
Daniel Hynds's avatar
Daniel Hynds committed
64
      }
65
      histograms[canvasName][i]->Draw(style.c_str());
Daniel Hynds's avatar
Daniel Hynds committed
66
    }
67
68
    canvas->GetCanvas()->Paint();
    canvas->GetCanvas()->Update();
Daniel Hynds's avatar
Daniel Hynds committed
69
  };
70
71
72
73
74
  
  // Exit the monitoring
  inline void Exit(){
    raise(SIGQUIT);
  }
Daniel Hynds's avatar
Daniel Hynds committed
75
76
77
78
79
80
81
82

  
  // ROOT I/O class definition - update version number when you change this class!
  ClassDef(GuiDisplay,0)
  
};

#endif // GUIDISPLAY_H