CbmRoot
CbmQaCanvas.h
Go to the documentation of this file.
1 
6 #ifndef CbmQaCanvas_H
7 #define CbmQaCanvas_H
8 
9 #include "TCanvas.h"
10 #include "TROOT.h"
11 
27 class CbmQaCanvas : public TCanvas {
28 public:
30  CbmQaCanvas() : TCanvas() {}
31 
34  template<typename... Types>
35  CbmQaCanvas(Types... args) : CbmQaCanvas(SetBatchModeOn(), args...) {}
36 
38  virtual ~CbmQaCanvas() {}
39 
41  void Divide2D(int nPads);
42 
43 private:
46  enum MyBoolean : Bool_t;
47 
49  template<typename... Types>
50  CbmQaCanvas(MyBoolean oldBatchMode, Types... args) : TCanvas(args...) {
51  // prevent automatic deletion of this canvas
52  // when another canvas with the same name is created somewhere else
53  gROOT->GetListOfCanvases()->Remove(this);
54  // reset the batch mode to its original value
55  gROOT->SetBatch((Bool_t) oldBatchMode);
56  }
57 
59  static MyBoolean SetBatchModeOn() {
60  MyBoolean oldBatchMode = (MyBoolean) gROOT->IsBatch();
61  gROOT->SetBatch(kTRUE);
62  return oldBatchMode;
63  }
64 
66 };
67 
68 #endif
CbmQaCanvas::SetBatchModeOn
static MyBoolean SetBatchModeOn()
Set batch mode ON and return its old value.
Definition: CbmQaCanvas.h:59
CbmQaCanvas::Divide2D
void Divide2D(int nPads)
Divide canvas into nPads in 2D in a nice way.
Definition: CbmQaCanvas.cxx:29
CbmQaCanvas::CbmQaCanvas
CbmQaCanvas()
Default constructor needed by the ROOT streamer.
Definition: CbmQaCanvas.h:30
CbmQaCanvas::~CbmQaCanvas
virtual ~CbmQaCanvas()
Destructor.
Definition: CbmQaCanvas.h:38
CbmQaCanvas::ClassDef
ClassDef(CbmQaCanvas, 1)
CbmQaCanvas
Definition: CbmQaCanvas.h:27
CbmQaCanvas::CbmQaCanvas
enum MyBoolean Bool_t CbmQaCanvas(MyBoolean oldBatchMode, Types... args)
Constructor which calls TCanvas constructor and restores the bach mode.
Definition: CbmQaCanvas.h:50
CbmQaCanvas::CbmQaCanvas
CbmQaCanvas(Types... args)
Definition: CbmQaCanvas.h:35